Changeset View
Changeset View
Standalone View
Standalone View
src/httpserver.cpp
Show First 20 Lines • Show All 432 Lines • ▼ Show 20 Lines | #endif | ||||
eventHTTP = http_ctr.release(); | eventHTTP = http_ctr.release(); | ||||
return true; | return true; | ||||
} | } | ||||
std::thread threadHTTP; | std::thread threadHTTP; | ||||
std::future<bool> threadResult; | std::future<bool> threadResult; | ||||
static std::vector<std::thread> g_thread_http_workers; | static std::vector<std::thread> g_thread_http_workers; | ||||
bool StartHTTPServer() { | void StartHTTPServer() { | ||||
LogPrint(BCLog::HTTP, "Starting HTTP server\n"); | LogPrint(BCLog::HTTP, "Starting HTTP server\n"); | ||||
int rpcThreads = | int rpcThreads = | ||||
std::max((long)gArgs.GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L); | std::max((long)gArgs.GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L); | ||||
LogPrintf("HTTP: starting %d worker threads\n", rpcThreads); | LogPrintf("HTTP: starting %d worker threads\n", rpcThreads); | ||||
std::packaged_task<bool(event_base *)> task(ThreadHTTP); | std::packaged_task<bool(event_base *)> task(ThreadHTTP); | ||||
threadResult = task.get_future(); | threadResult = task.get_future(); | ||||
threadHTTP = std::thread(std::move(task), eventBase); | threadHTTP = std::thread(std::move(task), eventBase); | ||||
for (int i = 0; i < rpcThreads; i++) { | for (int i = 0; i < rpcThreads; i++) { | ||||
g_thread_http_workers.emplace_back(HTTPWorkQueueRun, workQueue); | g_thread_http_workers.emplace_back(HTTPWorkQueueRun, workQueue); | ||||
} | } | ||||
return true; | |||||
} | } | ||||
void InterruptHTTPServer() { | void InterruptHTTPServer() { | ||||
LogPrint(BCLog::HTTP, "Interrupting HTTP server\n"); | LogPrint(BCLog::HTTP, "Interrupting HTTP server\n"); | ||||
if (eventHTTP) { | if (eventHTTP) { | ||||
// Unlisten sockets | // Unlisten sockets | ||||
for (evhttp_bound_socket *socket : boundSockets) { | for (evhttp_bound_socket *socket : boundSockets) { | ||||
evhttp_del_accept_socket(eventHTTP, socket); | evhttp_del_accept_socket(eventHTTP, socket); | ||||
▲ Show 20 Lines • Show All 224 Lines • Show Last 20 Lines |