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

Matthijs Mekking matthijs at nlnetlabs.nl
Tue Oct 12 16:00:04 CEST 2010


Author: matthijs
Date: 2010-10-12 16:00:04 +0200 (Tue, 12 Oct 2010)
New Revision: 4089

Modified:
   trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
   trunk/OpenDNSSEC/signer/src/daemon/engine.c
   trunk/OpenDNSSEC/signer/src/daemon/engine.h
   trunk/OpenDNSSEC/signer/src/daemon/worker.c
   trunk/OpenDNSSEC/signer/src/daemon/worker.h
Log:
search workers for zone



Modified: trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-10-12 13:33:09 UTC (rev 4088)
+++ trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-10-12 14:00:04 UTC (rev 4089)
@@ -165,7 +165,8 @@
         se_writen(sockfd, buf, strlen(buf));
         tbd = NULL;
     }
-    se_log_info("cmdhandler: updating signer configuration (%s)", tbd?tbd:"--all");
+    se_log_info("cmdhandler: updating signer configuration (%s)",
+        tbd?tbd:"--all");
     ret = engine_update_zones(cmdc->engine, tbd, buf, 1);
     se_writen(sockfd, buf, strlen(buf));
 
@@ -269,15 +270,21 @@
         (void)snprintf(buf, ODS_SE_MAXLINE, "Failed to schedule signing for "
              "zone %s\n", tbd?tbd:"(null)");
         se_writen(sockfd, buf, strlen(buf));
-        se_log_error("cmdhandler: zone %s was found in task queu but "
+        se_log_error("cmdhandler: zone %s was found in task queue but "
             "rescheduling failed", tbd?tbd:"(null)");
+    } else if (engine_search_workers(cmdc->engine, tbd)) {
+        se_log_warning("cmdhandler: not working on zone %s, updating "
+            "zone list", tbd?tbd:"(null");
+        (void)snprintf(buf, ODS_SE_MAXLINE, "Zone %s not not being signed "
+            "yet, updating sign configuration\n", tbd?tbd:"(null)");
+        se_writen(sockfd, buf, strlen(buf));
+        cmdhandler_handle_cmd_update(sockfd, cmdc, tbd);
     } else {
-        (void)snprintf(buf, ODS_SE_MAXLINE, "Zone %s not in task queue, "
-            "\n", tbd?tbd:"(null)");
+        se_log_warning("cmdhandler: already performing task for zone %s",
+            tbd?tbd:"(null");
+        (void)snprintf(buf, ODS_SE_MAXLINE, "Signer is already working on "
+            "zone %s, sign command ignored\n", tbd?tbd:"(null)");
         se_writen(sockfd, buf, strlen(buf));
-        se_log_warning("cmdhandler: zone %s not found in zone list",
-            tbd?tbd:"(null)");
-        cmdhandler_handle_cmd_update(sockfd, cmdc, tbd);
     }
     return;
 }

Modified: trunk/OpenDNSSEC/signer/src/daemon/engine.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/engine.c	2010-10-12 13:33:09 UTC (rev 4088)
+++ trunk/OpenDNSSEC/signer/src/daemon/engine.c	2010-10-12 14:00:04 UTC (rev 4089)
@@ -329,7 +329,7 @@
  * Start workers.
  *
  */
-void
+static void
 engine_start_workers(engine_type* engine)
 {
     size_t i = 0;
@@ -374,6 +374,34 @@
 
 
 /**
+ * Search for zone in workers
+ *
+ */
+int
+engine_search_workers(engine_type* engine, const char* zone_name)
+{
+    size_t i = 0;
+
+    se_log_assert(engine);
+    se_log_assert(engine->config);
+
+    if (!zone_name) {
+        return 1;
+    }
+
+    for (i=0; i < (size_t) engine->config->num_worker_threads; i++) {
+        if (engine->workers[i]->task &&
+            se_strcmp(engine->workers[i]->task->who, zone_name) == 0) {
+            /* ba-da bing */
+            return 0;
+        }
+    }
+    /* no potato */
+    return 1;
+}
+
+
+/**
  * Set up engine.
  *
  */

Modified: trunk/OpenDNSSEC/signer/src/daemon/engine.h
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/engine.h	2010-10-12 13:33:09 UTC (rev 4088)
+++ trunk/OpenDNSSEC/signer/src/daemon/engine.h	2010-10-12 14:00:04 UTC (rev 4089)
@@ -106,7 +106,7 @@
 
 /**
  * Update zones.
- * \param[in] the signer engine
+ * \param[in] engine the signer engine
  * \paran[in] zone_name update only this zone
  * \param[in] buf response message
  * \param[in] first_try if true, update zone list if zone not found
@@ -116,7 +116,16 @@
 int engine_update_zones(engine_type* engine, const char* zone_name, char* buf,
     int first_try);
 
+/**
+ * Search for zone in workers
+ * \param[in] engine the signer engine
+ * \paran[in] zone_name search for this zone
+ * \return int 1 if zone was not found
+ *
+ */
+int engine_search_workers(engine_type* engine, const char* zone_name);
 
+
 /**
  * Clean up engine.
  * \param[in] engine engine

Modified: trunk/OpenDNSSEC/signer/src/daemon/worker.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/worker.c	2010-10-12 13:33:09 UTC (rev 4088)
+++ trunk/OpenDNSSEC/signer/src/daemon/worker.c	2010-10-12 14:00:04 UTC (rev 4089)
@@ -54,6 +54,8 @@
     se_log_debug("create worker[%i]", num +1);
     worker->thread_num = num +1;
     worker->engineptr = NULL;
+    worker->tasklist = NULL;
+    worker->task = NULL;
     worker->need_to_exit = 0;
     worker->type = type;
     worker->sleeping = 0;
@@ -95,6 +97,7 @@
             lock_basic_unlock(&worker->tasklist->tasklist_lock);
             se_log_debug("worker[%i]: unlocked tasklist", worker->thread_num);
 
+            worker->task = task;
             se_log_debug("worker[%i]: lock zone %s", worker->thread_num,
                 task->who);
             lock_basic_lock(&zone->zone_lock);
@@ -107,6 +110,7 @@
             lock_basic_unlock(&zone->zone_lock);
             se_log_debug("worker[%i]: unlocked zone %s", worker->thread_num,
                 task->who);
+            worker->task = NULL;
 
             if (task->what == TASK_NONE) {
                 zone->in_progress = 0;

Modified: trunk/OpenDNSSEC/signer/src/daemon/worker.h
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/worker.h	2010-10-12 13:33:09 UTC (rev 4088)
+++ trunk/OpenDNSSEC/signer/src/daemon/worker.h	2010-10-12 14:00:04 UTC (rev 4089)
@@ -49,6 +49,7 @@
     int thread_num;
     se_thread_type thread_id;
     tasklist_type* tasklist;
+    task_type* task;
     struct engine_struct* engineptr;
     int type;
     int sleeping;




More information about the Opendnssec-commits mailing list