summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.h
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-05-22 13:24:29 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-05-29 10:27:55 -0400
commit5c2d133871b2ad2adf6c617364d036ca25261f2d (patch)
treee3e28fa7bd0e56fa95802bb5770c9bbd4bee6da3 /src/mongo/db/client.h
parent1f4188fbdc733aa1cb08403d75f13a04d2279817 (diff)
downloadmongo-5c2d133871b2ad2adf6c617364d036ca25261f2d.tar.gz
SERVER-18277 Clarify locking of Client when accessing its stored OperationContext.
As a side-effect, clean up operation killing in ServiceContextMongoD.
Diffstat (limited to 'src/mongo/db/client.h')
-rw-r--r--src/mongo/db/client.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index 63750b69523..597ed07dd70 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -86,11 +86,29 @@ namespace mongo {
void lock() { _lock.lock(); }
void unlock() { _lock.unlock(); }
- // Changes the currently active operation context on this client. There can only be one
- // active OperationContext at a time.
+ /**
+ * Sets the active operation context on this client to "txn", which must be non-NULL.
+ *
+ * It is an error to call this method if there is already an operation context on Client.
+ * It is an error to call this on an unlocked client.
+ */
void setOperationContext(OperationContext* txn);
+
+ /**
+ * Clears the active operation context on this client.
+ *
+ * There must already be such a context set on this client.
+ * It is an error to call this on an unlocked client.
+ */
void resetOperationContext();
- const OperationContext* getOperationContext() const { return _txn; }
+
+ /**
+ * Gets the operation context active on this client, or nullptr if there is no such context.
+ *
+ * It is an error to call this method on an unlocked client, or to use the value returned
+ * by this method while the client is not locked.
+ */
+ OperationContext* getOperationContext() { return _txn; }
// TODO(spencer): SERVER-10228 SERVER-14779 Remove this/move it fully into OperationContext.
bool isInDirectClient() const { return _inDirectClient; }