mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
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.
This commit is contained in:
parent
6d2bc22146
commit
3a174cd400
3 changed files with 26 additions and 11 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue