aboutsummaryrefslogtreecommitdiff
path: root/src/httpserver.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2018-11-07 09:10:07 +0000
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2018-11-23 16:54:22 +0000
commit6b13580f4e3842c11abd9b8bee7255fb2472b6fe (patch)
tree25be2a420acdc03d64ff89a256cbaffa6b6a2c55 /src/httpserver.cpp
parent18e968581697078c36a3c3818f8906cf134ccadd (diff)
downloadbitcoin-6b13580f4e3842c11abd9b8bee7255fb2472b6fe.tar.xz
http: Unlisten sockets after all workers quit
This (almost) move only ensures the event base loop doesn't exit before HTTP worker threads exit. This way events registered by HTTP workers are processed and not discarded.
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 342956f7a3..0ab9d966dc 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -443,10 +443,6 @@ void InterruptHTTPServer()
{
LogPrint(BCLog::HTTP, "Interrupting HTTP server\n");
if (eventHTTP) {
- // Unlisten sockets
- for (evhttp_bound_socket *socket : boundSockets) {
- evhttp_del_accept_socket(eventHTTP, socket);
- }
// Reject requests on current connections
evhttp_set_gencb(eventHTTP, http_reject_request_cb, nullptr);
}
@@ -466,6 +462,12 @@ void StopHTTPServer()
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.
+ for (evhttp_bound_socket *socket : boundSockets) {
+ evhttp_del_accept_socket(eventHTTP, socket);
+ }
+ boundSockets.clear();
if (eventBase) {
LogPrint(BCLog::HTTP, "Waiting for HTTP event thread to exit\n");
// Exit the event loop as soon as there are no active events.