diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2015-06-01 17:32:33 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2015-06-02 12:05:59 -0400 |
commit | 754f482c204160bf0c74373b64ba3406604f0731 (patch) | |
tree | 479fe9e9afd65bf78ae30b73d00649d41d67389b /src/mongo/db/operation_context.h | |
parent | 908d0cedf82b50c93932916685c4f8fa4748cc6f (diff) | |
download | mongo-754f482c204160bf0c74373b64ba3406604f0731.tar.gz |
SERVER-14995 Move _killPending from CurOp to OperationContext.
Also, limit the lifetime of OperationContext in MongoD so that it goes out of
scope before sending a reply to the client. This is necessary so that
operations do not appear in the currentOp command result after the server
sends a response to the client.
Diffstat (limited to 'src/mongo/db/operation_context.h')
-rw-r--r-- | src/mongo/db/operation_context.h | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index e3c28ef2c05..291fd3b6923 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -33,6 +33,7 @@ #include "mongo/db/storage/recovery_unit.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/write_concern_options.h" +#include "mongo/platform/atomic_word.h" #include "mongo/util/decorable.h" namespace mongo { @@ -106,12 +107,14 @@ namespace mongo { // --- operation level info? --- /** - * If the thread is not interrupted, returns Status::OK(), otherwise returns the cause - * for the interruption. The throw variant returns a user assertion corresponding to the - * interruption status. + * Raises a UserAssertion if this operation is in a killed state. */ - virtual void checkForInterrupt() const = 0; - virtual Status checkForInterruptNoAssert() const = 0; + virtual void checkForInterrupt() = 0; + + /** + * Returns Status::OK() unless this operation is in a killed state. + */ + virtual Status checkForInterruptNoAssert() = 0; /** * Delegates to CurOp, but is included here to break dependencies. @@ -167,6 +170,25 @@ namespace mongo { */ virtual bool writesAreReplicated() const = 0; + /** + * Marks this operation as killed. + * + * Subsequent calls to checkForInterrupt and checkForInterruptNoAssert by the thread + * executing the operation will indicate that the operation has been killed. + * + * May be called by any thread that has locked the Client owning this operation context, + * or by the thread executing on behalf of this operation context. + */ + void markKilled(); + + /** + * Returns true if markKilled has been called on this operation context. + * + * May be called by any thread that has locked the Client owning this operation context, + * or by the thread executing on behalf of this operation context. + */ + bool isKillPending() const; + protected: OperationContext(Client* client, unsigned int opId, @@ -183,6 +205,7 @@ namespace mongo { // safe to access _locker in the destructor of OperationContext. Locker* const _locker; + AtomicInt32 _killPending{0}; WriteConcernOptions _writeConcern; }; |