From 4cc1e854c1fa6bd3f60d01930c2f157034e52f4f Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 5 May 2015 17:58:10 +0200 Subject: [PATCH] fixed segfaults when running cluster AQL queries in console thread --- arangod/Aql/ExecutionBlock.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arangod/Aql/ExecutionBlock.cpp b/arangod/Aql/ExecutionBlock.cpp index a78940b7da..fe74706800 100644 --- a/arangod/Aql/ExecutionBlock.cpp +++ b/arangod/Aql/ExecutionBlock.cpp @@ -6803,7 +6803,12 @@ ClusterCommResult* RemoteBlock::sendRequest ( headers.emplace(make_pair("Shard-Id", _ownName)); } - triagens::rest::DispatcherThread::currentDispatcherThread->blockThread(); + auto currentThread = triagens::rest::DispatcherThread::currentDispatcherThread; + + if (currentThread != nullptr) { + triagens::rest::DispatcherThread::currentDispatcherThread->blockThread(); + } + auto result = cc->syncRequest(clientTransactionId, coordTransactionId, _server, @@ -6814,7 +6819,10 @@ ClusterCommResult* RemoteBlock::sendRequest ( body, headers, defaultTimeOut); - triagens::rest::DispatcherThread::currentDispatcherThread->unblockThread(); + + if (currentThread != nullptr) { + triagens::rest::DispatcherThread::currentDispatcherThread->unblockThread(); + } return result; LEAVE_BLOCK