Don't try to handle SIGINT

[?]
Jun 10, 2015, 1:55 PM
C6HOMHZWMSC7ORGFUF5YG2ACKV2SCP26HL3UH6VXH6RNDYRXH5DAC

Dependencies

  • [2] 5AIYUMTB Basic remote building
  • [3] T2EIYJNG On SIGINT, shut down the builder threads
  • [4] 24BMQDZA Start of single-process hydra-queue-runner
  • [5] NJJ7H64S Very basic multi-threaded queue runner
  • [6] YZAI5GQU Implement a database connection pool
  • [7] ENXUSMSV Make 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
    [3.1503][3.227:256]()
    while (!exitRequested) {
    [3.1503]
    [3.448]
    while (true) {
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 654
    [3.2532][2.10307:10336]()
    while (!exitRequested) {
    [3.2532]
    [2.10336]
    while (true) {
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 972
    [2.14778][2.14778:14845]()
    auto dispatcherThread = std::thread(&State::dispatcher, this);
    [2.14778]
    [3.771]
    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); } // barrier
    queueMonitorWakeup.notify_all();
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 976
    [3.1131][2.14846:14897](),[2.14897][3.811:812](),[3.1272][3.811:812]()
    wakeDispatcher();
    dispatcherThread.join();
    [3.1131]
    [3.812]
    printMsg(lvlError, "exiting...");
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 986
    [3.3512][3.3512:3556]()
    std::thread(signalThread).detach();
    [3.3512]
    [3.19176]
    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
    [3.19177][3.3557:3821]()
    /* 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);