[Opendnssec-commits] [svn.opendnssec.org/svn/dnssec] r5497 - in branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src: enforcer signconf

rene at xpt.nl rene at xpt.nl
Wed Aug 31 08:27:59 CEST 2011


Author: rene
Date: 2011-08-31 08:27:58 +0200 (Wed, 31 Aug 2011)
New Revision: 5497

Modified:
   branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/autostart_cmd.cpp
   branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_cmd.cpp
   branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_task.cpp
   branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_task.h
   branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/signconf/signconf_task.cpp
Log:
Launch a signer configuration writer task after calling the enforcer update function for all the zones that needed to be enforced.

Modified: branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/autostart_cmd.cpp
===================================================================
--- branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/autostart_cmd.cpp	2011-08-31 06:27:53 UTC (rev 5496)
+++ branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/autostart_cmd.cpp	2011-08-31 06:27:58 UTC (rev 5497)
@@ -82,7 +82,7 @@
                   "resalt");
 
     schedule_task(sockfd,engine,
-                  enforce_task(engine->config,"enforce","next zone"),
+                  enforce_task(engine,"enforce","next zone"),
                   "enforce");
 
     (void)snprintf(buf, ODS_SE_MAXLINE, "%s completed in %ld seconds.\n",

Modified: branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_cmd.cpp
===================================================================
--- branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_cmd.cpp	2011-08-31 06:27:53 UTC (rev 5496)
+++ branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_cmd.cpp	2011-08-31 06:27:58 UTC (rev 5497)
@@ -54,7 +54,7 @@
 	/* perform tasks immediately */
 	time_t tstart = time(NULL);
 
-	perform_enforce(sockfd, engine->config, 1, NULL);
+	perform_enforce(sockfd, engine, 1, NULL);
 	
 	(void)snprintf(buf, ODS_SE_MAXLINE, "%s completed in %ld seconds.\n",
 				   scmd,time(NULL)-tstart);

Modified: branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_task.cpp
===================================================================
--- branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_task.cpp	2011-08-31 06:27:53 UTC (rev 5496)
+++ branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_task.cpp	2011-08-31 06:27:58 UTC (rev 5497)
@@ -15,7 +15,9 @@
 // Interface of this cpp file is used by C code, we need to declare
 // extern "C" to prevent linking errors.
 extern "C" {
+#include "daemon/engine.h"
 #include "enforcer/enforce_task.h"
+#include "signconf/signconf_task.h"
 #include "shared/duration.h"
 #include "shared/file.h"
 #include "shared/allocator.h"
@@ -50,11 +52,11 @@
 }
 
 
-time_t perform_enforce(int sockfd, engineconfig_type *config, int bForceUpdate,
+time_t perform_enforce(int sockfd, engine_type *engine, int bForceUpdate,
                        task_type* task)
 {
     char buf[ODS_SE_MAXLINE];
-    const char *datastore = config->datastore;
+    const char *datastore = engine->config->datastore;
     int fd;
 
     GOOGLE_PROTOBUF_VERIFY_VERSION;
@@ -134,6 +136,7 @@
 
     // Go through all the zones and call enforcer update for the zone when 
     // its schedule time is earlier or identical to time_now.
+    bool bSignerConfNeedsWriting = false;
     for (int z=0; z<keystateDoc->zones_size(); ++z) {
         // Update zone when scheduled time is earlier or identical to time_now.
         time_t t_next = keystateDoc->zones(z).next_change();
@@ -149,7 +152,10 @@
             EnforcerZonePB enfZone(keystateDoc->mutable_zones(z), policy);
             if (policy) {
                 t_next = update(enfZone, time_now(), keyfactory);
-            
+                
+                if (enfZone.signerConfNeedsWriting())
+                    bSignerConfNeedsWriting = true;
+                
                 if (t_next == -1) {
                     // Enforcer update could not find a date to 
                     // schedule next.
@@ -249,6 +255,35 @@
     delete keystateDoc;
     delete hsmkeyDoc;
 
+    
+    // Launch signer configuration writer task when one of the 
+    // zones indicated that it needs to be written.
+    if (bSignerConfNeedsWriting) {
+        task_type *signconf = signconf_task(engine->config, "signconf",
+                                            "signer configurations");
+        if (!signconf) {
+            ods_log_crit("[%s] failed to create %s task", module_str,
+                         "signconf");
+        } else {
+            char buf[ODS_SE_MAXLINE];
+            ods_status status = schedule_task_from_thread(engine->taskq, 
+                                                          signconf, 0);
+            if (status != ODS_STATUS_OK) {
+                ods_log_crit("[%s] failed to create %s task", module_str,
+                             "signconf");
+                (void)snprintf(buf, ODS_SE_MAXLINE,
+                               "Unable to schedule %s task.\n",
+                               "signconf");
+                ods_writen(sockfd, buf, strlen(buf));
+            } else {
+                (void)snprintf(buf, ODS_SE_MAXLINE,
+                               "Scheduled %s task.\n","signconf");
+                ods_writen(sockfd, buf, strlen(buf));
+                engine_wakeup_workers(engine);
+            }
+        }
+    }
+    
     if (!task)
         return -1;
     
@@ -266,7 +301,7 @@
 static task_type *
 enforce_task_perform(task_type *task)
 {
-    if (perform_enforce(-1, (engineconfig_type *)task->context, 0, task) != -1)
+    if (perform_enforce(-1, (engine_type *)task->context, 0, task) != -1)
         return task;
 
     task_cleanup(task);
@@ -274,10 +309,10 @@
 }
 
 task_type *
-enforce_task(engineconfig_type *config, const char *what, const char *who)
+enforce_task(engine_type *engine, const char *what, const char *who)
 {
     task_id what_id = task_register(what, 
                                  "enforce_task_perform",
                                  enforce_task_perform);
-    return task_create(what_id, time_now(), who, (void*)config);
+    return task_create(what_id, time_now(), who, (void*)engine);
 }

Modified: branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_task.h
===================================================================
--- branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_task.h	2011-08-31 06:27:53 UTC (rev 5496)
+++ branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/enforcer/enforce_task.h	2011-08-31 06:27:58 UTC (rev 5497)
@@ -4,10 +4,10 @@
 #include "daemon/cfg.h"
 #include "scheduler/task.h"
 
-time_t perform_enforce(int sockfd, engineconfig_type *config, int bForce,
+time_t perform_enforce(int sockfd, engine_type *engine, int bForce,
                        task_type *task);
 
-task_type *enforce_task(engineconfig_type *config, const char *what,
+task_type *enforce_task(engine_type *engine, const char *what,
                         const char *who);
 
 #endif

Modified: branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/signconf/signconf_task.cpp
===================================================================
--- branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/signconf/signconf_task.cpp	2011-08-31 06:27:53 UTC (rev 5496)
+++ branches/OpenDNSSEC-enforcer-ng/enforcer-ng/src/signconf/signconf_task.cpp	2011-08-31 06:27:58 UTC (rev 5497)
@@ -233,10 +233,8 @@
 signconf_task_perform(task_type *task)
 {
     perform_signconf(-1,(engineconfig_type *)task->context);
-    
-	task->backoff = 0;
-    task->when = time_now() + 60;
-    return task;
+    task_cleanup(task);
+    return NULL;
 }
 
 task_type *




More information about the Opendnssec-commits mailing list