Finish shutting down after getting a signal in server mode
Summary:
In server mode, after we get a SIGTERM, SIGUSR1, or SIGHUP we attempt to shut down gracefully. However, since HttpServer::stopOnSignal never sets m_stopped or notifies in the graceful path, we end up asleep in the wait() on http-server.cpp:375 forever. This is noticeable in hphp/test/run --server and hphp/test/run --cli-server modes: they send a single SIGTERM to the server via proc_terminate and then hang forever in the proc_close at hphp/test/run:3442.
Fix it by setting m_stopped and notifying at the end of HttpServer::stopOnSignal.
Also, stop doing redundant work in HttpServer::stopOnSignal and add an atomic bool to prevent entering shutdown code twice.
Reviewed By: markw65
Differential Revision:
D7685353
fbshipit-source-id:
687fcc8cd68dc55bb9a388dc9bfdb416c666d075