mirror of https://gitee.com/bigwinds/arangodb
Make shure we leave all contexts we open in the propper sequence.
This commit is contained in:
parent
26b51b35b8
commit
aa1cdc09e2
|
@ -117,7 +117,7 @@ void ConsoleThread::run () {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void ConsoleThread::inner () {
|
void ConsoleThread::inner () {
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent(); // TODO: this may go away.
|
v8::Isolate* isolate = _context->isolate;
|
||||||
v8::HandleScope globalScope(isolate);
|
v8::HandleScope globalScope(isolate);
|
||||||
|
|
||||||
// run the shell
|
// run the shell
|
||||||
|
@ -127,6 +127,7 @@ void ConsoleThread::inner () {
|
||||||
|
|
||||||
auto localContext = v8::Local<v8::Context>::New(isolate, _context->_context);
|
auto localContext = v8::Local<v8::Context>::New(isolate, _context->_context);
|
||||||
localContext->Enter();
|
localContext->Enter();
|
||||||
|
{
|
||||||
v8::Context::Scope contextScope(localContext);
|
v8::Context::Scope contextScope(localContext);
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
@ -163,14 +164,13 @@ void ConsoleThread::inner () {
|
||||||
if (input != nullptr) {
|
if (input != nullptr) {
|
||||||
TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, input);
|
TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, input);
|
||||||
}
|
}
|
||||||
throw "user aborted";
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input == nullptr) {
|
if (input == nullptr) {
|
||||||
_userAborted = true;
|
_userAborted = true;
|
||||||
|
localContext->Exit();
|
||||||
// this will be caught by "run"
|
break;
|
||||||
throw "user aborted";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*input == '\0') {
|
if (*input == '\0') {
|
||||||
|
@ -181,6 +181,7 @@ void ConsoleThread::inner () {
|
||||||
nrCommands++;
|
nrCommands++;
|
||||||
console.addHistory(input);
|
console.addHistory(input);
|
||||||
|
|
||||||
|
{
|
||||||
v8::TryCatch tryCatch;
|
v8::TryCatch tryCatch;
|
||||||
v8::HandleScope scope(isolate);
|
v8::HandleScope scope(isolate);
|
||||||
|
|
||||||
|
@ -191,7 +192,9 @@ void ConsoleThread::inner () {
|
||||||
std::cout << TRI_StringifyV8Exception(isolate, &tryCatch);
|
std::cout << TRI_StringifyV8Exception(isolate, &tryCatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
localContext->Exit();
|
||||||
throw "user aborted";
|
throw "user aborted";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -374,6 +374,7 @@ ApplicationV8::V8Context* ApplicationV8::enterContext (std::string const& name,
|
||||||
v8::HandleScope scope(isolate);
|
v8::HandleScope scope(isolate);
|
||||||
auto localContext = v8::Local<v8::Context>::New(isolate, context->_context);
|
auto localContext = v8::Local<v8::Context>::New(isolate, context->_context);
|
||||||
localContext->Enter();
|
localContext->Enter();
|
||||||
|
{
|
||||||
v8::Context::Scope contextScope(localContext);
|
v8::Context::Scope contextScope(localContext);
|
||||||
|
|
||||||
TRI_ASSERT(context->_locker->IsLocked(isolate));
|
TRI_ASSERT(context->_locker->IsLocked(isolate));
|
||||||
|
@ -397,7 +398,7 @@ ApplicationV8::V8Context* ApplicationV8::enterContext (std::string const& name,
|
||||||
TRI_V8_ASCII_STRING("global context method"),
|
TRI_V8_ASCII_STRING("global context method"),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,6 +506,7 @@ void ApplicationV8::exitContext (V8Context* context) {
|
||||||
|
|
||||||
delete context->_locker;
|
delete context->_locker;
|
||||||
context->_locker = nullptr;
|
context->_locker = nullptr;
|
||||||
|
|
||||||
TRI_ASSERT(! v8::Locker::IsLocked(isolate));
|
TRI_ASSERT(! v8::Locker::IsLocked(isolate));
|
||||||
|
|
||||||
guard.broadcast();
|
guard.broadcast();
|
||||||
|
|
Loading…
Reference in New Issue