MCPcopy Create free account
hub / github.com/ElementsProject/elements / StopHTTPServer

Function StopHTTPServer

src/httpserver.cpp:448–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448void StopHTTPServer()
449{
450 LogPrint(BCLog::HTTP, "Stopping HTTP server\n");
451 if (g_work_queue) {
452 LogPrint(BCLog::HTTP, "Waiting for HTTP worker threads to exit\n");
453 for (auto& thread : g_thread_http_workers) {
454 thread.join();
455 }
456 g_thread_http_workers.clear();
457 }
458 // Unlisten sockets, these are what make the event loop running, which means
459 // that after this and all connections are closed the event loop will quit.
460 for (evhttp_bound_socket *socket : boundSockets) {
461 evhttp_del_accept_socket(eventHTTP, socket);
462 }
463 boundSockets.clear();
464 if (eventBase) {
465 LogPrint(BCLog::HTTP, "Waiting for HTTP event thread to exit\n");
466 if (g_thread_http.joinable()) g_thread_http.join();
467 }
468 if (eventHTTP) {
469 evhttp_free(eventHTTP);
470 eventHTTP = nullptr;
471 }
472 if (eventBase) {
473 event_base_free(eventBase);
474 eventBase = nullptr;
475 }
476 g_work_queue.reset();
477 LogPrint(BCLog::HTTP, "Stopped HTTP server\n");
478}
479
480struct event_base* EventBase()
481{

Callers 1

ShutdownFunction · 0.85

Calls 3

joinMethod · 0.45
clearMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected