@@ -322,7 +322,7 @@ V8Context* V8DealerFeature::addContext() {
322
322
323
323
// no other thread can use the context when we are here, as the
324
324
// context has not been added to the global list of contexts yet
325
- loadJavaScriptFileInContext (database->systemDatabase (), " server/initialize.js" , context, nullptr );
325
+ loadJavaScriptFileInContextNoLock (database->systemDatabase (), " server/initialize.js" , context);
326
326
return context;
327
327
} catch (...) {
328
328
delete context;
@@ -1342,6 +1342,31 @@ bool V8DealerFeature::loadJavaScriptFileInContext(TRI_vocbase_t* vocbase,
1342
1342
return true ;
1343
1343
}
1344
1344
1345
+ bool V8DealerFeature::loadJavaScriptFileInContextNoLock (TRI_vocbase_t* vocbase,
1346
+ std::string const & file, V8Context* context) {
1347
+ TRI_ASSERT (vocbase != nullptr );
1348
+ TRI_ASSERT (context != nullptr );
1349
+
1350
+ if (_stopping) {
1351
+ return false ;
1352
+ }
1353
+
1354
+ if (!vocbase->use ()) {
1355
+ return false ;
1356
+ }
1357
+
1358
+ prepareLockedContext (vocbase, context, true );
1359
+
1360
+ try {
1361
+ loadJavaScriptFileInternal (file, context, nullptr );
1362
+ } catch (...) {
1363
+ LOG_TOPIC (WARN, Logger::V8) << " caught exception while executing JavaScript file '" << file << " ' in context #" << context->id ();
1364
+ throw ;
1365
+ }
1366
+
1367
+ return true ;
1368
+ }
1369
+
1345
1370
void V8DealerFeature::loadJavaScriptFileInternal (std::string const & file, V8Context* context, VPackBuilder* builder) {
1346
1371
v8::HandleScope scope (context->_isolate );
1347
1372
auto localContext =
@@ -1368,6 +1393,8 @@ void V8DealerFeature::loadJavaScriptFileInternal(std::string const& file, V8Cont
1368
1393
}
1369
1394
}
1370
1395
1396
+ localContext->Exit ();
1397
+
1371
1398
LOG_TOPIC (TRACE, arangodb::Logger::V8) << " loaded Javascript file '" << file << " ' for V8 context #" << context->id ();
1372
1399
}
1373
1400
0 commit comments