|
22 | 22 | #include <sys/types.h> |
23 | 23 | #include <sys/stat.h> |
24 | 24 | #include <signal.h> |
25 | | -#include <future> |
26 | 25 |
|
27 | 26 | #include <event2/thread.h> |
28 | 27 | #include <event2/buffer.h> |
@@ -422,17 +421,14 @@ bool UpdateHTTPServerLogging(bool enable) { |
422 | 421 | } |
423 | 422 |
|
424 | 423 | std::thread threadHTTP; |
425 | | -std::future<bool> threadResult; |
426 | 424 | static std::vector<std::thread> g_thread_http_workers; |
427 | 425 |
|
428 | 426 | void StartHTTPServer() |
429 | 427 | { |
430 | 428 | LogPrint(BCLog::HTTP, "Starting HTTP server\n"); |
431 | 429 | int rpcThreads = std::max((long)gArgs.GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L); |
432 | 430 | LogPrintf("HTTP: starting %d worker threads\n", rpcThreads); |
433 | | - std::packaged_task<bool(event_base*)> task(ThreadHTTP); |
434 | | - threadResult = task.get_future(); |
435 | | - threadHTTP = std::thread(std::move(task), eventBase); |
| 431 | + threadHTTP = std::thread(ThreadHTTP, eventBase); |
436 | 432 |
|
437 | 433 | for (int i = 0; i < rpcThreads; i++) { |
438 | 434 | g_thread_http_workers.emplace_back(HTTPWorkQueueRun, workQueue); |
@@ -470,16 +466,6 @@ void StopHTTPServer() |
470 | 466 | boundSockets.clear(); |
471 | 467 | if (eventBase) { |
472 | 468 | LogPrint(BCLog::HTTP, "Waiting for HTTP event thread to exit\n"); |
473 | | - // Give event loop a few seconds to exit (to send back last RPC responses), then break it |
474 | | - // Before this was solved with event_base_loopexit, but that didn't work as expected in |
475 | | - // at least libevent 2.0.21 and always introduced a delay. In libevent |
476 | | - // master that appears to be solved, so in the future that solution |
477 | | - // could be used again (if desirable). |
478 | | - // (see discussion in https://github.com/bitcoin/bitcoin/pull/6990) |
479 | | - if (threadResult.valid() && threadResult.wait_for(std::chrono::milliseconds(2000)) == std::future_status::timeout) { |
480 | | - LogPrintf("HTTP event loop did not exit within allotted time, sending loopbreak\n"); |
481 | | - event_base_loopbreak(eventBase); |
482 | | - } |
483 | 469 | threadHTTP.join(); |
484 | 470 | } |
485 | 471 | if (eventHTTP) { |
|
0 commit comments