summaryrefslogtreecommitdiff
path: root/src/mongo/scripting/mozjs/proxyscope.cpp
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2019-02-27 13:40:18 -0500
committerJason Carey <jcarey@argv.me>2019-03-05 10:05:45 -0500
commit32a067938731d184b271ba3d7f43ca6727e3109c (patch)
tree759f22c263da841521a1653701a94e4b7c05c8f0 /src/mongo/scripting/mozjs/proxyscope.cpp
parent602bfb9c52b2274d55492f73eeac8513d9048d10 (diff)
downloadmongo-32a067938731d184b271ba3d7f43ca6727e3109c.tar.gz
SERVER-39427 Modify interrupt semantics for opCtx
* rename opCtx->runWithoutInterruption to runWithoutInterruptionExceptAtGlobalShutdown * add a opCtx->setIsExecutingShutdown method which makes the op immune to all forms of interruption, including global shutdown This clarifies what opCtx->runWithoutInterruption actually did and offers an escape hatch that turns off interruption at process exit for the thread doing cleanup.
Diffstat (limited to 'src/mongo/scripting/mozjs/proxyscope.cpp')
-rw-r--r--src/mongo/scripting/mozjs/proxyscope.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/scripting/mozjs/proxyscope.cpp b/src/mongo/scripting/mozjs/proxyscope.cpp
index 3eeccd732e2..afc21eca1eb 100644
--- a/src/mongo/scripting/mozjs/proxyscope.cpp
+++ b/src/mongo/scripting/mozjs/proxyscope.cpp
@@ -83,7 +83,7 @@ void MozJSProxyScope::init(const BSONObj* data) {
void MozJSProxyScope::reset() {
unregisterOperation();
- runWithoutInterruption([&] { _implScope->reset(); });
+ runWithoutInterruptionExceptAtGlobalShutdown([&] { _implScope->reset(); });
}
bool MozJSProxyScope::isKillPending() const {
@@ -104,13 +104,14 @@ void MozJSProxyScope::externalSetup() {
std::string MozJSProxyScope::getError() {
std::string out;
- runWithoutInterruption([&] { out = _implScope->getError(); });
+ runWithoutInterruptionExceptAtGlobalShutdown([&] { out = _implScope->getError(); });
return out;
}
bool MozJSProxyScope::hasOutOfMemoryException() {
bool out;
- runWithoutInterruption([&] { out = _implScope->hasOutOfMemoryException(); });
+ runWithoutInterruptionExceptAtGlobalShutdown(
+ [&] { out = _implScope->hasOutOfMemoryException(); });
return out;
}
@@ -119,11 +120,11 @@ void MozJSProxyScope::gc() {
}
void MozJSProxyScope::advanceGeneration() {
- runWithoutInterruption([&] { _implScope->advanceGeneration(); });
+ runWithoutInterruptionExceptAtGlobalShutdown([&] { _implScope->advanceGeneration(); });
}
void MozJSProxyScope::requireOwnedObjects() {
- runWithoutInterruption([&] { _implScope->requireOwnedObjects(); });
+ runWithoutInterruptionExceptAtGlobalShutdown([&] { _implScope->requireOwnedObjects(); });
}
double MozJSProxyScope::getNumber(const char* field) {
@@ -274,11 +275,11 @@ void MozJSProxyScope::run(Closure&& closure) {
}
template <typename Closure>
-void MozJSProxyScope::runWithoutInterruption(Closure&& closure) {
+void MozJSProxyScope::runWithoutInterruptionExceptAtGlobalShutdown(Closure&& closure) {
auto toRun = [&] { run(std::forward<Closure>(closure)); };
if (_opCtx) {
- return _opCtx->runWithoutInterruption(toRun);
+ return _opCtx->runWithoutInterruptionExceptAtGlobalShutdown(toRun);
} else {
return toRun();
}