From 5f225a7464862686a8422bb02d1f638d5568d529 Mon Sep 17 00:00:00 2001 From: Andy Schwerin Date: Mon, 1 Jun 2015 17:26:06 -0400 Subject: Reapply "SERVER-18277 Clarify locking of Client when accessing its stored OperationContext." This reverts commit 993fc5e4ed9264965f16a948d3732d3fc55d1255. --- src/mongo/db/client.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/mongo/db/client.h') 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; } -- cgit v1.2.1