[Opendnssec-commits] [svn.opendnssec.org/svn/dnssec] r5422 - trunk/OpenDNSSEC/signer/src/daemon

Matthijs Mekking matthijs at nlnetlabs.nl
Wed Aug 17 10:15:46 CEST 2011


Author: matthijs
Date: 2011-08-17 10:15:46 +0200 (Wed, 17 Aug 2011)
New Revision: 5422

Modified:
   trunk/OpenDNSSEC/signer/src/daemon/worker.c
Log:
https://www.pivotaltracker.com/story/show/17052469   



Modified: trunk/OpenDNSSEC/signer/src/daemon/worker.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/worker.c	2011-08-16 14:57:27 UTC (rev 5421)
+++ trunk/OpenDNSSEC/signer/src/daemon/worker.c	2011-08-17 08:15:46 UTC (rev 5422)
@@ -291,13 +291,21 @@
                     task_who2str(task->who), worker->jobs_appointed);
 
                 /* sleep until work is done */
-                worker_sleep_unless(worker, 0);
-                if (worker->jobs_failed > 0) {
+                if (!worker->need_to_exit) {
+                    worker_sleep_unless(worker, 0);
+                }
+                if (worker->jobs_failed) {
                     ods_log_error("[%s[%i]] sign zone %s failed: %u of %u "
                         "signatures failed", worker2str(worker->type),
                         worker->thread_num, task_who2str(task->who),
                         worker->jobs_failed, worker->jobs_appointed);
                     status = ODS_STATUS_ERR;
+                } else if (!worker_fulfilled(worker)) {
+                    ods_log_error("[%s[%i]] sign zone %s failed: %u of %u "
+                        "signatures completed", worker2str(worker->type),
+                        worker->thread_num, task_who2str(task->who),
+                        worker->jobs_completed, worker->jobs_appointed);
+                    status = ODS_STATUS_ERR;
                 } else {
                     ods_log_debug("[%s[%i]] sign zone %s ok: %u of %u "
                        "signatures succeeded", worker2str(worker->type),
@@ -592,6 +600,9 @@
     while (worker->need_to_exit == 0) {
         ods_log_debug("[%s[%i]] report for duty", worker2str(worker->type),
             worker->thread_num);
+        chief = NULL;
+        zone = NULL;
+        task = NULL;
 
         lock_basic_lock(&worker->engine->signq->q_lock);
         /* [LOCK] schedule */
@@ -639,12 +650,10 @@
                         worker2str(worker->type), worker->thread_num,
                         chief->thread_num);
                     worker_wakeup(chief);
+                    chief = NULL;
                 }
             }
             rrset = NULL;
-            zone = NULL;
-            task = NULL;
-            chief = NULL;
         } else {
             ods_log_debug("[%s[%i]] nothing to do", worker2str(worker->type),
                 worker->thread_num);
@@ -652,6 +661,12 @@
                 &worker->engine->signq->q_threshold);
         }
     }
+    /* wake up chief */
+    if (chief && chief->sleeping) {
+        ods_log_debug("[%s[%i]] wake up chief[%u], i am exiting",
+            worker2str(worker->type), worker->thread_num, chief->thread_num);
+         worker_wakeup(chief);
+    }
 
     /* cleanup open HSM sessions */
     hsm_destroy_context(ctx);
@@ -712,7 +727,7 @@
     ods_log_assert(worker);
     lock_basic_lock(&worker->worker_lock);
     /* [LOCK] worker */
-    while (!worker_fulfilled(worker)) {
+    while (!worker->need_to_exit && !worker_fulfilled(worker)) {
         worker->sleeping = 1;
         lock_basic_sleep(&worker->worker_alarm, &worker->worker_lock,
             timeout);




More information about the Opendnssec-commits mailing list