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.

Zcash: cherry-picked from commit ec908d5f7aa9ad7e3487018e06a24cb6449cc58b
This commit is contained in:
Wladimir J. van der Laan 2015-09-25 15:35:37 +02:00 committed by Jason Davies
parent dbf7057f7a
commit 2abe8ef721
1 changed files with 7 additions and 0 deletions

View File

@ -461,6 +461,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();
}