From 41e3268ccde9b97f15514a55af1a06f49ebbb049 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Wed, 25 Jan 2017 10:26:30 +0100 Subject: [PATCH 1/2] clean up job queues on shutdown --- arangod/Scheduler/JobQueue.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arangod/Scheduler/JobQueue.cpp b/arangod/Scheduler/JobQueue.cpp index 68c88971ef..228ccf89cc 100644 --- a/arangod/Scheduler/JobQueue.cpp +++ b/arangod/Scheduler/JobQueue.cpp @@ -90,6 +90,14 @@ class JobQueueThread final : public Thread { _jobQueue->waitForWork(); } } + + // clear all non-processed jobs + for (size_t i = 0; i < JobQueue::SYSTEM_QUEUE_SIZE; ++i) { + Job* job = nullptr; + while (_jobQueue->pop(i, job)) { + delete job; + } + } } private: From 208729ae103d489731cc9bb48a1867d204461cac Mon Sep 17 00:00:00 2001 From: jsteemann Date: Wed, 25 Jan 2017 10:26:48 +0100 Subject: [PATCH 2/2] use make_unique --- arangod/GeneralServer/GeneralCommTask.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arangod/GeneralServer/GeneralCommTask.cpp b/arangod/GeneralServer/GeneralCommTask.cpp index 49963dd8c6..ae6dad8657 100644 --- a/arangod/GeneralServer/GeneralCommTask.cpp +++ b/arangod/GeneralServer/GeneralCommTask.cpp @@ -242,14 +242,13 @@ bool GeneralCommTask::handleRequestAsync(std::shared_ptr handler, size_t queue = handler->queue(); auto self = shared_from_this(); - std::unique_ptr job( - new Job(_server, std::move(handler), + auto job = std::make_unique(_server, std::move(handler), [self, this](std::shared_ptr h) { JobGuard guard(_loop); guard.work(); h->asyncRunEngine(); - })); + }); return SchedulerFeature::SCHEDULER->jobQueue()->queue(queue, std::move(job)); }