[Opendnssec-commits] matthijs r6986 - in branches/OpenDNSSEC-1.3/signer/src: scheduler signer

commits at svn.opendnssec.org commits at svn.opendnssec.org
Fri Jan 25 12:10:32 CET 2013


Author: matthijs
Date: Fri Jan 25 12:10:32 2013
New Revision: 6986
URL: http://fisheye.opendnssec.org/changelog/opendnssec?cs=6986

Log:
another backport fix.

Modified:
   branches/OpenDNSSEC-1.3/signer/src/scheduler/fifoq.c
   branches/OpenDNSSEC-1.3/signer/src/signer/rrset.c

Modified: branches/OpenDNSSEC-1.3/signer/src/scheduler/fifoq.c
==============================================================================
--- branches/OpenDNSSEC-1.3/signer/src/scheduler/fifoq.c	Fri Jan 25 11:03:59 2013	(r6985)
+++ branches/OpenDNSSEC-1.3/signer/src/scheduler/fifoq.c	Fri Jan 25 12:10:32 2013	(r6986)
@@ -131,16 +131,9 @@
 ods_status
 fifoq_push(fifoq_type* q, void* item, worker_type* worker, int* tries)
 {
-    if (!item) {
-        ods_log_error("[%s] unable to push item: no item", fifoq_str);
-        return ODS_STATUS_ASSERT_ERR;
-    }
-    ods_log_assert(item);
-    if (!q) {
-        ods_log_error("[%s] unable to push item: no queue", fifoq_str);
-        return ODS_STATUS_ASSERT_ERR;
-    }
     ods_log_assert(q);
+    ods_log_assert(item);
+    ods_log_assert(worker);
 
     if (q->count >= FIFOQ_MAX_COUNT) {
         /* #262 if drudgers remain on hold, do additional broadcast */

Modified: branches/OpenDNSSEC-1.3/signer/src/signer/rrset.c
==============================================================================
--- branches/OpenDNSSEC-1.3/signer/src/signer/rrset.c	Fri Jan 25 11:03:59 2013	(r6985)
+++ branches/OpenDNSSEC-1.3/signer/src/signer/rrset.c	Fri Jan 25 12:10:32 2013	(r6986)
@@ -1146,26 +1146,29 @@
     }
     ods_log_assert(q);
 
-    while (status == ODS_STATUS_UNCHANGED && !worker->need_to_exit) {
+    lock_basic_lock(&q->q_lock);
+    status = fifoq_push(q, (void*) rrset, worker, &tries);
+    while (status == ODS_STATUS_UNCHANGED) {
         tries++;
-        lock_basic_lock(&q->q_lock);
-        status = fifoq_push(q, (void*) rrset, worker, &tries);
+        if (worker->need_to_exit) {
+            lock_basic_unlock(&q->q_lock);
+            return;
+        }
         /**
-         * If tries are 0 they we have tries FIFOQ_TRIES_COUNT times,
-         * lets take a small break to not hog CPU.
+         * Apparently the queue is full. Lets take a small break to not hog CPU.
+         * The worker will release the signq lock while sleeping and will
+         * automatically grab the lock when the queue is nonfull.
+         * Queue is nonfull at 10% of the queue size.
          */
-        if (status == ODS_STATUS_UNCHANGED) {
-            worker_wait_timeout_locked(&q->q_lock, &q->q_nonfull, 60);
-        }
-        lock_basic_unlock(&q->q_lock);
-    }
-    if (status == ODS_STATUS_OK) {
-        lock_basic_lock(&worker->worker_lock);
-        /* [LOCK] worker */
-        worker->jobs_appointed += 1;
-        /* [UNLOCK] worker */
-        lock_basic_unlock(&worker->worker_lock);
+        lock_basic_sleep(&q->q_nonfull, &q->q_lock, 5);
+        status = fifoq_push(q, (void*) rrset, worker, &tries);
     }
+    lock_basic_unlock(&q->q_lock);
+
+    ods_log_assert(status == ODS_STATUS_OK);
+    lock_basic_lock(&worker->worker_lock);
+    worker->jobs_appointed += 1;
+    lock_basic_unlock(&worker->worker_lock);
     return status;
 }
 



More information about the Opendnssec-commits mailing list