[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r3814 - trunk/OpenDNSSEC/signer/src/daemon

Matthijs Mekking matthijs at nlnetlabs.nl
Fri Aug 27 09:14:35 CEST 2010


Author: matthijs
Date: 2010-08-27 09:14:35 +0200 (Fri, 27 Aug 2010)
New Revision: 3814

Modified:
   trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
   trunk/OpenDNSSEC/signer/src/daemon/engine.c
Log:
signal lock only protects engine->signal

Modified: trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-08-26 15:15:32 UTC (rev 3813)
+++ trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-08-27 07:14:35 UTC (rev 3814)
@@ -385,8 +385,9 @@
     se_log_assert(cmdc);
     se_log_assert(cmdc->engine);
 
+    cmdc->engine->need_to_reload = 1;
+
     lock_basic_lock(&cmdc->engine->signal_lock);
-    cmdc->engine->need_to_reload = 1;
     lock_basic_alarm(&cmdc->engine->signal_cond);
     lock_basic_unlock(&cmdc->engine->signal_lock);
 
@@ -408,8 +409,9 @@
     se_log_assert(cmdc);
     se_log_assert(cmdc->engine);
 
+    cmdc->engine->need_to_exit = 1;
+
     lock_basic_lock(&cmdc->engine->signal_lock);
-    cmdc->engine->need_to_exit = 1;
     lock_basic_alarm(&cmdc->engine->signal_cond);
     lock_basic_unlock(&cmdc->engine->signal_lock);
 
@@ -447,10 +449,8 @@
     se_log_assert(cmdc->engine);
     se_log_assert(cmdc->engine->config);
 
-    lock_basic_lock(&cmdc->engine->signal_lock);
     se_log_init(cmdc->engine->config->log_filename,
         cmdc->engine->config->use_syslog, val);
-    lock_basic_unlock(&cmdc->engine->signal_lock);
 
     (void)snprintf(buf, ODS_SE_MAXLINE, "Verbosity level set to %i.\n", val);
     se_writen(sockfd, buf, strlen(buf));

Modified: trunk/OpenDNSSEC/signer/src/daemon/engine.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/engine.c	2010-08-26 15:15:32 UTC (rev 3813)
+++ trunk/OpenDNSSEC/signer/src/daemon/engine.c	2010-08-27 07:14:35 UTC (rev 3814)
@@ -487,15 +487,19 @@
 static void
 engine_run(engine_type* engine, int single_run)
 {
+    sig_atomic_t signal = SIGNAL_RUN;
+
     se_log_assert(engine);
 
     lock_basic_lock(&engine->signal_lock);
     engine->signal = SIGNAL_RUN;
     lock_basic_unlock(&engine->signal_lock);
+
     while (engine->need_to_exit == 0 && engine->need_to_reload == 0) {
         lock_basic_lock(&engine->signal_lock);
-        engine->signal = signal_capture(engine->signal);
-        switch (engine->signal) {
+        signal = signal_capture(engine->signal);
+        lock_basic_unlock(&engine->signal_lock);
+        switch (signal) {
             case SIGNAL_RUN:
                 se_log_assert(1);
                 break;
@@ -508,13 +512,17 @@
             default:
                 se_log_warning("invalid signal captured: %d, keep running",
                     engine->signal);
-                engine->signal = SIGNAL_RUN;
+                signal = SIGNAL_RUN;
                 break;
         }
 
         if (single_run) {
            engine->need_to_exit = 1;
-        } else if (engine->signal == SIGNAL_RUN) {
+        }
+
+        lock_basic_lock(&engine->signal_lock);
+        engine->signal = signal;
+        if (engine->signal == SIGNAL_RUN && !single_run) {
            se_log_debug("engine taking a break");
            lock_basic_sleep(&engine->signal_cond, &engine->signal_lock, 3600);
         }




More information about the Opendnssec-commits mailing list