summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2016-03-29 08:39:26 -0400
committerAndrew Morrow <acm@mongodb.com>2016-03-29 08:40:47 -0400
commit01adcbbd2bd1664d7e03284ea417f02727cb1030 (patch)
treed8d23d97d57ebd5c7429a7a2d82fc00a6dace9ab
parent9ec38146e8ccdd1d2ab2e4f2f4c03d40554d2dce (diff)
downloadmongo-01adcbbd2bd1664d7e03284ea417f02727cb1030.tar.gz
SERVER-23382 Drop JS scope cache when shutting down dbtests
-rw-r--r--src/mongo/dbtests/framework.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/dbtests/framework.cpp b/src/mongo/dbtests/framework.cpp
index 6ba11c289e0..a201ddfe79a 100644
--- a/src/mongo/dbtests/framework.cpp
+++ b/src/mongo/dbtests/framework.cpp
@@ -45,6 +45,7 @@
#include "mongo/dbtests/framework_options.h"
#include "mongo/s/catalog/catalog_manager.h"
#include "mongo/s/grid.h"
+#include "mongo/scripting/engine.h"
#include "mongo/stdx/mutex.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/exit.h"
@@ -60,6 +61,20 @@ int runDbTests(int argc, char** argv) {
frameworkGlobalParams.seed = time(0);
frameworkGlobalParams.runsPerTest = 1;
+ registerShutdownTask([] {
+ // We drop the scope cache because leak sanitizer can't see across the
+ // thread we use for proxying MozJS requests. Dropping the cache cleans up
+ // the memory and makes leak sanitizer happy.
+ ScriptEngine::dropScopeCache();
+
+ // We may be shut down before we have a global storage
+ // engine.
+ if (!getGlobalServiceContext()->getGlobalStorageEngine())
+ return;
+
+ getGlobalServiceContext()->shutdownGlobalStorageEngineCleanly();
+ });
+
Client::initThread("testsuite");
srand((unsigned)frameworkGlobalParams.seed);