diff options
author | James Wahlin <james@mongodb.com> | 2020-03-06 15:33:37 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-09 13:35:51 +0000 |
commit | 8a9d5677f500293448311e6c551549b60cbfc780 (patch) | |
tree | 24abe32ca873be2453c4ac4d2c7cab38b27537ce /src/mongo/scripting | |
parent | 340c085a7fd3e589442bce69db86d51cae1e82a6 (diff) | |
download | mongo-8a9d5677f500293448311e6c551549b60cbfc780.tar.gz |
SERVER-46227 MozJSImplScope::kill() check for "correct thread" will always fail
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r-- | src/mongo/scripting/mozjs/implscope.cpp | 3 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/implscope.h | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp index 34729b87a33..f06a20bfc0a 100644 --- a/src/mongo/scripting/mozjs/implscope.cpp +++ b/src/mongo/scripting/mozjs/implscope.cpp @@ -136,6 +136,7 @@ void MozJSImplScope::registerOperation(OperationContext* opCtx) { _opCtx = opCtx; _opId = opCtx->getOpID(); + _opCtxThreadId = stdx::this_thread::get_id(); _engine->registerOperation(opCtx, this); } @@ -153,7 +154,7 @@ void MozJSImplScope::kill() { // If we are on the right thread, in the middle of an operation, and we have a registered // opCtx, then we should check the opCtx for interrupts. - if (_mr._thread.get_id() == stdx::this_thread::get_id() && _inOp > 0 && _opCtx) { + if (_opCtxThreadId == stdx::this_thread::get_id() && _inOp > 0 && _opCtx) { _killStatus = _opCtx->checkForInterruptNoAssert(); } diff --git a/src/mongo/scripting/mozjs/implscope.h b/src/mongo/scripting/mozjs/implscope.h index c774efd3bd3..b842ae3cbef 100644 --- a/src/mongo/scripting/mozjs/implscope.h +++ b/src/mongo/scripting/mozjs/implscope.h @@ -379,7 +379,6 @@ private: public: MozRuntime(const MozJSScriptEngine* engine, boost::optional<int> jsHeapLimitMB); - std::thread _thread; // NOLINT std::unique_ptr<JSRuntime, std::function<void(JSRuntime*)>> _runtime; std::unique_ptr<JSContext, std::function<void(JSContext*)>> _context; }; @@ -417,8 +416,9 @@ private: mutable Mutex _mutex = MONGO_MAKE_LATCH("MozJSImplScope::_mutex"); stdx::condition_variable _sleepCondition; std::string _error; - unsigned int _opId; // op id for this scope - OperationContext* _opCtx; // Op context for DbEval + unsigned int _opId; // op id for this scope + OperationContext* _opCtx; // Op context for DbEval + stdx::thread::id _opCtxThreadId; // Id of the thread that owns '_opCtx' std::size_t _inOp; std::atomic<bool> _pendingGC; // NOLINT ConnectState _connectState; |