aboutsummaryrefslogtreecommitdiff
path: root/src/httpserver.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-08-28 16:55:16 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-09-03 10:59:19 +0200
commit3a174cd400c6c239539d4c0c10b557c3e0615212 (patch)
tree3a7b26b9218f9e3d17d8a3f5f77e032b35f6e416 /src/httpserver.h
parent6d2bc221463ffe3ed3a99e8c682b090983b2e7b5 (diff)
downloadbitcoin-3a174cd400c6c239539d4c0c10b557c3e0615212.tar.xz
Fix race condition between starting HTTP server thread and setting EventBase()
Split StartHTTPServer into InitHTTPServer and StartHTTPServer to give clients a window to register their handlers without race conditions. Thanks @ajweiss for figuring this out.
Diffstat (limited to 'src/httpserver.h')
-rw-r--r--src/httpserver.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/httpserver.h b/src/httpserver.h
index 1b0d77ad4d..459c60c047 100644
--- a/src/httpserver.h
+++ b/src/httpserver.h
@@ -20,7 +20,14 @@ struct event_base;
class CService;
class HTTPRequest;
-/** Start HTTP server */
+/** Initialize HTTP server.
+ * Call this before RegisterHTTPHandler or EventBase().
+ */
+bool InitHTTPServer();
+/** Start HTTP server.
+ * This is separate from InitHTTPServer to give users race-condition-free time
+ * to register their handlers between InitHTTPServer and StartHTTPServer.
+ */
bool StartHTTPServer(boost::thread_group& threadGroup);
/** Interrupt HTTP server threads */
void InterruptHTTPServer();