Changeset d2e12b284f29fd7104b23c22bf78a332d9591400

Show
Ignore:
Timestamp:
03/05/08 03:13:50 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1204686830 +0000
git-parent:

[9a6060c147e3f375f75141efe7884a911021d87e]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1204686830 +0000
Message:

initialize the two per-queue pthread keys and allow override of the signal

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/eventer/eventer_jobq.c

    r171d8ed rd2e12b2  
    1313#include <signal.h> 
    1414 
     15#ifndef JOBQ_SIGNAL 
     16#define JOBQ_SIGNAL SIGALRM 
     17#endif 
     18 
    1519static noit_atomic32_t threads_jobq_inited = 0; 
    1620static pthread_key_t threads_jobq; 
     
    3943 
    4044    sigemptyset(&alarm_mask); 
    41     sigaddset(&alarm_mask, SIGALRM); 
     45    sigaddset(&alarm_mask, JOBQ_SIGNAL); 
    4246    act.sa_handler = eventer_jobq_handler; 
    4347    act.sa_flags = 0; 
    4448    sigemptyset(&act.sa_mask); 
    4549 
    46     if(sigaction(SIGALRM, &act, NULL) < 0) { 
     50    if(sigaction(JOBQ_SIGNAL, &act, NULL) < 0) { 
    4751      noitL(noit_error, "Cannot initialize signal handler: %s\n", 
    4852            strerror(errno)); 
     
    5155 
    5256    if(pthread_key_create(&threads_jobq, NULL)) { 
    53       noitL(noit_error, "Cannot initialize thread-specific jmp environment: %s\n", 
     57      noitL(noit_error, "Cannot initialize thread-specific jobq: %s\n", 
    5458            strerror(errno)); 
    5559      return -1; 
     
    6872  if(sem_init(&jobq->semaphore, 0, 0) != 0) { 
    6973    noitL(noit_error, "Cannot initialize semaphore: %s\n", 
     74          strerror(errno)); 
     75    return -1; 
     76  } 
     77  if(pthread_key_create(&jobq->activejob, NULL)) { 
     78    noitL(noit_error, "Cannot initialize thread-specific activejob: %s\n", 
     79          strerror(errno)); 
     80    return -1; 
     81  } 
     82  if(pthread_key_create(&jobq->threadenv, NULL)) { 
     83    noitL(noit_error, "Cannot initialize thread-specific sigsetjmp env: %s\n", 
    7084          strerror(errno)); 
    7185    return -1; 
     
    137151  job->timeout_triggered = 1; 
    138152  job->timeout_event = NULL; 
    139   if(job->inflight) pthread_kill(job->executor, SIGALRM); 
     153  if(job->inflight) pthread_kill(job->executor, JOBQ_SIGNAL); 
    140154  return 0; 
    141155} 
     
    202216    pthread_mutex_unlock(&job->lock); 
    203217 
    204     /* Run the job, if we timeout, will be killed with an ALRM from the 
    205      * master thread.  We handle the alarm by longjmp'd out back here. 
     218    /* Run the job, if we timeout, will be killed with a JOBQ_SIGNAL from 
     219     * the master thread.  We handle the alarm by longjmp'd out back here. 
    206220     */ 
    207221    job->executor = pthread_self();