diff options
-rw-r--r-- | debug.c | 9 | ||||
-rw-r--r-- | syslogd.c | 16 | ||||
-rw-r--r-- | threads.c | 27 |
3 files changed, 18 insertions, 34 deletions
@@ -988,13 +988,18 @@ static void sigusr2Hdlr(int __attribute__((unused)) signum) rsRetVal dbgClassInit(void) { struct sigaction sigAct; + sigset_t sigSet; (void) pthread_key_create(&keyCallStack, dbgCallStackDestruct); /* MUST be the first action done! */ + memset(&sigAct, 0, sizeof (sigAct)); sigemptyset(&sigAct.sa_mask); sigAct.sa_handler = sigusr2Hdlr; - //sigaction(SIGUSR2, &sigAct, NULL); - sigaction(SIGUSR1, &sigAct, NULL); + sigaction(SIGUSR2, &sigAct, NULL); + + sigemptyset(&sigSet); + sigaddset(&sigSet, SIGUSR2); + pthread_sigmask(SIG_UNBLOCK, &sigSet, NULL); pszAltDbgFileName = getenv("RSYSLOG_DEBUGLOG"); @@ -2264,8 +2264,13 @@ static void debug_switch() { struct sigaction sigAct; - dbgprintf("Switching debugging_on to %s\n", (debugging_on == 0) ? "true" : "false"); - debugging_on = (debugging_on == 0) ? 1 : 0; + if(debugging_on == 0) { + debugging_on = 1; + dbgprintf("Switching debugging_on to true\n"); + } else { + dbgprintf("Switching debugging_on to false\n"); + debugging_on = 0; + } memset(&sigAct, 0, sizeof (sigAct)); sigemptyset(&sigAct.sa_mask); @@ -4768,8 +4773,8 @@ int realMain(int argc, char **argv) sigAct.sa_handler = sigsegvHdlr; sigaction(SIGSEGV, &sigAct, NULL); -sigAct.sa_handler = sigsegvHdlr; -sigaction(SIGABRT, &sigAct, NULL); + sigAct.sa_handler = sigsegvHdlr; + sigaction(SIGABRT, &sigAct, NULL); sigAct.sa_handler = doDie; sigaction(SIGTERM, &sigAct, NULL); sigAct.sa_handler = Debug ? doDie : SIG_IGN; @@ -4778,8 +4783,7 @@ sigaction(SIGABRT, &sigAct, NULL); sigAct.sa_handler = reapchild; sigaction(SIGCHLD, &sigAct, NULL); sigAct.sa_handler = Debug ? debug_switch : SIG_IGN; - /* TODO: use signal 2 */ - /*sigaction(SIGUSR1, &sigAct, NULL);*/ + sigaction(SIGUSR1, &sigAct, NULL); sigAct.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sigAct, NULL); sigaction(SIGXFSZ, &sigAct, NULL); /* do not abort if 2gig file limit is hit */ @@ -1,7 +1,3 @@ -/* TODO: we should guard the individual thread actions with a mutex. Else, we may - * run into race conditions on thread termination. - */ - /* threads.c * * This file implements threading support helpers (and maybe the thread object) @@ -128,13 +124,10 @@ static void* thrdStarter(void *arg) assert(pThis != NULL); assert(pThis->pUsrThrdMain != NULL); - /* block all signals except the one we need for graceful termination */ + /* block all signalsi */ sigset_t sigSet; sigfillset(&sigSet); pthread_sigmask(SIG_BLOCK, &sigSet, NULL); - sigemptyset(&sigSet); - sigaddset(&sigSet, SIGUSR2); - pthread_sigmask(SIG_UNBLOCK, &sigSet, NULL); /* setup complete, we are now ready to execute the user code. We will not * regain control until the user code is finished, in which case we terminate @@ -171,31 +164,13 @@ finalize_it: } -/* This is a dummy handler. We user SIGUSR2 to interrupt blocking system calls - * if we are in termination mode 1. - */ -static void sigusr2Dummy(int __attribute__((unused)) sig) -{ - dbgprintf("sigusr2Dummy called!\n"); -} - - /* initialize the thread-support subsystem * must be called once at the start of the program */ rsRetVal thrdInit(void) { DEFiRet; - struct sigaction sigAct; - iRet = llInit(&llThrds, thrdDestruct, NULL, NULL); - - /* set up our termination subsystem */ - memset(&sigAct, 0, sizeof (sigAct)); - sigemptyset(&sigAct.sa_mask); - sigAct.sa_handler = sigusr2Dummy; - sigaction(SIGUSR2, &sigAct, NULL); - RETiRet; } |