Don't try to handle SIGINT
[?]
Jun 10, 2015, 1:55 PM
C6HOMHZWMSC7ORGFUF5YG2ACKV2SCP26HL3UH6VXH6RNDYRXH5DACDependencies
- [2]
5AIYUMTBBasic remote building - [3]
T2EIYJNGOn SIGINT, shut down the builder threads - [4]
24BMQDZAStart of single-process hydra-queue-runner - [5]
NJJ7H64SVery basic multi-threaded queue runner - [6]
YZAI5GQUImplement a database connection pool - [7]
ENXUSMSVMake concurrency more robust
Change contents
- edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 27[3.121]→[3.121:123](∅→∅),[3.123]→[3.288:356](∅→∅),[3.5058]→[3.288:356](∅→∅),[3.356]→[3.0:40](∅→∅),[3.40]→[3.5058:5059](∅→∅),[3.383]→[3.5058:5059](∅→∅),[3.5058]→[3.5058:5059](∅→∅),[3.5059]→[3.384:416](∅→∅),[3.416]→[3.5059:5060](∅→∅),[3.5059]→[3.5059:5060](∅→∅),[3.5060]→[3.417:905](∅→∅)
}std::mutex exitRequestMutex;std::condition_variable exitRequest;std::atomic<bool> exitRequested(false);static std::atomic_int _int(0);void sigintHandler(int signo){_int = 1;}void signalThread(){struct sigaction act;act.sa_handler = sigintHandler;sigemptyset(&act.sa_mask);act.sa_flags = 0;if (sigaction(SIGINT, &act, 0))throw SysError("installing handler for SIGINT");while (true) {sleep(1000000);if (_int) break;}{std::lock_guard<std::mutex> lock(exitRequestMutex);exitRequested = true;}exitRequest.notify_all(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 371
while (!exitRequested) {while (true) { - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 654
while (!exitRequested) {while (true) { - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 972
auto dispatcherThread = std::thread(&State::dispatcher, this);std::thread(&State::dispatcher, this).detach(); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 974[3.772]→[3.772:978](∅→∅),[3.978]→[3.3478:3479](∅→∅),[3.3478]→[3.3478:3479](∅→∅),[3.3479]→[3.979:1129](∅→∅)
/* Wait for SIGINT. */{std::unique_lock<std::mutex> lock(exitRequestMutex);while (!exitRequested)exitRequest.wait(lock);}printMsg(lvlError, "exiting...");/* Shut down the various threads. */{ std::lock_guard<std::mutex> lock(queueMonitorMutex); } // barrierqueueMonitorWakeup.notify_all(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 976
wakeDispatcher();dispatcherThread.join();printMsg(lvlError, "exiting..."); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 986
std::thread(signalThread).detach();signal(SIGINT, SIG_DFL);signal(SIGTERM, SIG_DFL);signal(SIGHUP, SIG_DFL); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 990
/* Ignore signals. This is inherited by the other threads. */sigset_t set;sigemptyset(&set);sigaddset(&set, SIGHUP);sigaddset(&set, SIGINT);sigaddset(&set, SIGTERM);sigprocmask(SIG_BLOCK, &set, NULL);