Skip to content

Commit

Permalink
http: Force-exit event loop after predefined time
Browse files Browse the repository at this point in the history
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 ec908d5
  • Loading branch information
laanwj authored and jasondavies committed Aug 1, 2017
1 parent dbf7057 commit 2abe8ef
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 2abe8ef

Please sign in to comment.