Finish shutting down after getting a signal in server mode
commitcb19f10e74f722b1cd4929343a708f8438e89859
authorAlexey Toptygin <alexeyt@fb.com>
Fri, 20 Apr 2018 22:58:10 +0000 (20 15:58 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 20 Apr 2018 23:00:12 +0000 (20 16:00 -0700)
tree3bf85a50e56cf9b9aaf90613f5530e3870c177e4
parent4b5119c533cf8887a7ae2f52298c7e3ac2acd387
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
hphp/runtime/server/http-server.cpp
hphp/runtime/server/http-server.h