[Opendnssec-develop] Fwd: [Opendnssec-commits] [svn.opendnssec.org/svn/dnssec] r6500 - branches/OpenDNSSEC-1.3/signer/src/daemon

Jerry Lundström jerry at opendnssec.org
Wed Aug 8 08:45:54 UTC 2012


Hi Matthijs,

This "fix" isn't the best it seems, it now leaks file descriptors:

After start:
# lsof|grep ods-sign|wc -l
92

After a while:
# lsof|grep ods-sign|wc -l
218

when forcing signing:

# ods-signer sign example.com
Zone example.com scheduled for immediate re-sign.

# lsof|grep ods-sign|wc -l
281

# ods-signer sign example.com
Zone example.com scheduled for immediate re-sign.

# lsof|grep ods-sign|wc -l
344


---------- Forwarded message ----------
From:  <matthijs at nlnetlabs.nl>
Date: Mon, Aug 6, 2012 at 8:49 AM
Subject: [Opendnssec-commits] [svn.opendnssec.org/svn/dnssec] r6500 -
branches/OpenDNSSEC-1.3/signer/src/daemon
To:


Author: matthijs
Date: 2012-08-06 08:49:54 +0200 (Mon, 06 Aug 2012)
New Revision: 6500

Modified:
   branches/OpenDNSSEC-1.3/signer/src/daemon/worker.c
Log:
create context within while loop (will reload engine on creating
libhsm context error)



Modified: branches/OpenDNSSEC-1.3/signer/src/daemon/worker.c
===================================================================
--- branches/OpenDNSSEC-1.3/signer/src/daemon/worker.c  2012-08-02
22:11:39 UTC (rev 6499)
+++ branches/OpenDNSSEC-1.3/signer/src/daemon/worker.c  2012-08-06
06:49:54 UTC (rev 6500)
@@ -591,7 +591,9 @@
 static void
 worker_drudge(worker_type* worker)
 {
+    engine_type* engine = NULL;
     zone_type* zone = NULL;
+    task_type* task = NULL;
     rrset_type* rrset = NULL;
     ods_status status = ODS_STATUS_OK;
     worker_type* chief = NULL;
@@ -600,19 +602,13 @@
     ods_log_assert(worker);
     ods_log_assert(worker->type == WORKER_DRUDGER);

-    ods_log_debug("[%s[%i]] create hsm context",
-        worker2str(worker->type), worker->thread_num);
-    ctx = hsm_create_context();
-    if (!ctx) {
-        ods_log_crit("[%s[%i]] error creating libhsm context",
-            worker2str(worker->type), worker->thread_num);
-    }
-
+    engine = (engine_type*) worker->engine;
     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 */
@@ -620,45 +616,43 @@
         /* [UNLOCK] schedule */
         lock_basic_unlock(&worker->engine->signq->q_lock);
         if (rrset) {
-            /* set up the work */
-            if (chief && chief->task) {
-                zone = chief->task->zone;
-            }
-            if (!zone) {
-                ods_log_error("[%s[%i]] unable to drudge: no zone reference",
+            ods_log_assert(chief);
+            ods_log_debug("[%s[%i]] create hsm context",
+                worker2str(worker->type), worker->thread_num);
+            ctx = hsm_create_context();
+            if (!ctx) {
+                ods_log_crit("[%s[%i]] error creating libhsm context",
                     worker2str(worker->type), worker->thread_num);
-            }
-            if (zone && ctx) {
-                ods_log_assert(rrset);
-                ods_log_assert(zone->dname);
+                engine->need_to_reload = 1;
+                chief->jobs_failed++;
+            } else {
+                ods_log_assert(ctx);
+                lock_basic_lock(&chief->worker_lock);
+                task = chief->task;
+                ods_log_assert(task);
+                zone = task->zone;
+                lock_basic_unlock(&chief->worker_lock);
+                ods_log_assert(zone);
                 ods_log_assert(zone->signconf);
+                ods_log_assert(rrset);

                 worker->clock_in = time(NULL);
                 status = rrset_sign(ctx, rrset, zone->dname, zone->signconf,
                     chief->clock_in, zone->stats);
-            } else {
-                status = ODS_STATUS_ASSERT_ERR;
-            }
-
-            if (chief) {
                 lock_basic_lock(&chief->worker_lock);
                 if (status == ODS_STATUS_OK) {
                     chief->jobs_completed += 1;
                 } else {
                     chief->jobs_failed += 1;
-                    /* destroy context? */
                 }
                 lock_basic_unlock(&chief->worker_lock);
-
-                if (worker_fulfilled(chief) && chief->sleeping) {
-                    ods_log_debug("[%s[%i]] wake up chief[%u], work is done",
-                        worker2str(worker->type), worker->thread_num,
-                        chief->thread_num);
-                    worker_wakeup(chief);
-                    chief = NULL;
-                }
             }
-            rrset = NULL;
+            if (worker_fulfilled(chief) && chief->sleeping) {
+                ods_log_debug("[%s[%i]] wake up chief[%u], work is done",
+                    worker2str(worker->type), worker->thread_num,
+                    chief->thread_num);
+                worker_wakeup(chief);
+            }
         } else {
             ods_log_debug("[%s[%i]] nothing to do", worker2str(worker->type),
                 worker->thread_num);

_______________________________________________
Opendnssec-commits mailing list
Opendnssec-commits at lists.opendnssec.org
https://lists.opendnssec.org/mailman/listinfo/opendnssec-commits



More information about the Opendnssec-develop mailing list