aboutsummaryrefslogtreecommitdiff
path: root/src/httpserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/httpserver.cpp')
-rw-r--r--src/httpserver.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 45c049c3be..b3984a43bb 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -83,7 +83,7 @@ public:
bool Enqueue(WorkItem* item)
{
LOCK(cs);
- if (queue.size() >= maxDepth) {
+ if (!running || queue.size() >= maxDepth) {
return false;
}
queue.emplace_back(std::unique_ptr<WorkItem>(item));
@@ -99,7 +99,7 @@ public:
WAIT_LOCK(cs, lock);
while (running && queue.empty())
cond.wait(lock);
- if (!running)
+ if (!running && queue.empty())
break;
i = std::move(queue.front());
queue.pop_front();
@@ -448,8 +448,6 @@ void StopHTTPServer()
thread.join();
}
g_thread_http_workers.clear();
- delete workQueue;
- workQueue = nullptr;
}
// Unlisten sockets, these are what make the event loop running, which means
// that after this and all connections are closed the event loop will quit.
@@ -469,6 +467,10 @@ void StopHTTPServer()
event_base_free(eventBase);
eventBase = nullptr;
}
+ if (workQueue) {
+ delete workQueue;
+ workQueue = nullptr;
+ }
LogPrint(BCLog::HTTP, "Stopped HTTP server\n");
}