From ec908d5f7aa9ad7e3487018e06a24cb6449cc58b Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 25 Sep 2015 15:35:37 +0200 Subject: [PATCH] http: Force-exit event loop after predefined time This makes sure that the event loop eventually terminates, even if an event (like an open timeout, or a hanging connection) happens to be holding it up. --- src/httpserver.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 9f079aedfeb..0a7f903e9f7 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -457,6 +457,13 @@ void InterruptHTTPServer() // Reject requests on current connections evhttp_set_gencb(eventHTTP, http_reject_request_cb, NULL); } + if (eventBase) { + // Force-exit event loop after predefined time + struct timeval tv; + tv.tv_sec = 10; + tv.tv_usec = 0; + event_base_loopexit(eventBase, &tv); + } if (workQueue) workQueue->Interrupt(); }