yuri r7631 - trunk/OpenDNSSEC/enforcer-ng/src/daemon

commits at svn.opendnssec.org commits at svn.opendnssec.org
Fri Feb 7 10:42:07 CET 2014


Author: yuri
Date: Fri Feb  7 10:42:07 2014
New Revision: 7631
URL: http://fisheye.opendnssec.org/changelog/opendnssec?cs=7631

Log:
Delete everything related to drudgers, we never used it. This will make it easier to manage libhsm connections.

Modified:
   trunk/OpenDNSSEC/enforcer-ng/src/daemon/engine.c
   trunk/OpenDNSSEC/enforcer-ng/src/daemon/engine.h
   trunk/OpenDNSSEC/enforcer-ng/src/daemon/worker.c
   trunk/OpenDNSSEC/enforcer-ng/src/daemon/worker.h

Modified: trunk/OpenDNSSEC/enforcer-ng/src/daemon/engine.c
==============================================================================
--- trunk/OpenDNSSEC/enforcer-ng/src/daemon/engine.c	Fri Feb  7 08:11:26 2014	(r7630)
+++ trunk/OpenDNSSEC/enforcer-ng/src/daemon/engine.c	Fri Feb  7 10:42:07 2014	(r7631)
@@ -88,7 +88,6 @@
     engine->allocator = allocator;
     engine->config = NULL;
     engine->workers = NULL;
-    engine->drudgers = NULL;
     engine->cmdhandler = NULL;
     engine->cmdhandler_done = 0;
     engine->pid = -1;
@@ -257,30 +256,11 @@
     engine->workers = (worker_type**) allocator_alloc(engine->allocator,
         ((size_t)engine->config->num_worker_threads) * sizeof(worker_type*));
     for (i=0; i < (size_t) engine->config->num_worker_threads; i++) {
-        engine->workers[i] = worker_create(engine->allocator, i,
-            WORKER_WORKER);
+        engine->workers[i] = worker_create(engine->allocator, i);
     }
     return;
 }
-static void
-engine_create_drudgers(engine_type* engine)
-{
-#if HAVE_DRUDGERS
-    size_t i = 0;
-#endif
-    ods_log_assert(engine);
-    ods_log_assert(engine->config);
-    ods_log_assert(engine->allocator);
-#if HAVE_DRUDGERS
-    engine->drudgers = (worker_type**) allocator_alloc(engine->allocator,
-        ((size_t)engine->config->num_signer_threads) * sizeof(worker_type*));
-    for (i=0; i < (size_t) engine->config->num_signer_threads; i++) {
-        engine->drudgers[i] = worker_create(engine->allocator, i,
-            WORKER_DRUDGER);
-    }
-#endif
-    return;
-}
+
 static void*
 worker_thread_start(void* arg)
 {
@@ -305,26 +285,7 @@
     }
     return;
 }
-static void
-engine_start_drudgers(engine_type* engine)
-{
-#if HAVE_DRUDGERS
-    size_t i = 0;
-#endif
 
-    ods_log_assert(engine);
-    ods_log_assert(engine->config);
-    ods_log_debug("[%s] start drudgers", engine_str);
-#if HAVE_DRUDGERS
-    for (i=0; i < (size_t) engine->config->num_signer_threads; i++) {
-        engine->drudgers[i]->need_to_exit = 0;
-        engine->drudgers[i]->engine = (struct engine_struct*) engine;
-        ods_thread_create(&engine->drudgers[i]->thread_id, worker_thread_start,
-            engine->drudgers[i]);
-    }
-#endif
-    return;
-}
 static void
 engine_stop_workers(engine_type* engine)
 {
@@ -346,33 +307,6 @@
     }
     return;
 }
-static void
-engine_stop_drudgers(engine_type* engine)
-{
-#if HAVE_DRUDGERS
-    size_t i = 0;
-#endif
-
-    ods_log_assert(engine);
-    ods_log_assert(engine->config);
-    ods_log_debug("[%s] stop drudgers", engine_str);
-#if HAVE_DRUDGERS
-    /* tell them to exit and wake up sleepyheads */
-    for (i=0; i < (size_t) engine->config->num_signer_threads; i++) {
-        engine->drudgers[i]->need_to_exit = 1;
-    }
-    worker_notify_all(&engine->signq->q_lock, &engine->signq->q_threshold);
-
-    /* head count */
-    for (i=0; i < (size_t) engine->config->num_signer_threads; i++) {
-        ods_log_debug("[%s] join drudger %i", engine_str, i+1);
-        ods_thread_join(engine->drudgers[i]->thread_id);
-        engine->drudgers[i]->engine = NULL;
-    }
-#endif
-    return;
-}
-
 
 /**
  * Wake up all workers.
@@ -500,7 +434,6 @@
 
     /* create workers */
     engine_create_workers(engine);
-    engine_create_drudgers(engine);
 
     /* start command handler */
     engine_start_cmdhandler(engine);
@@ -552,7 +485,6 @@
     ods_log_assert(engine);
 
     engine_start_workers(engine);
-    engine_start_drudgers(engine);
 
     lock_basic_lock(&engine->signal_lock);
     /* [LOCK] signal */
@@ -601,7 +533,6 @@
         lock_basic_unlock(&engine->signal_lock);
     }
     ods_log_debug("[%s] enforcer halted", engine_str);
-    engine_stop_drudgers(engine);
     engine_stop_workers(engine);
     return;
 }
@@ -749,14 +680,6 @@
         }
         allocator_deallocate(allocator, (void*) engine->workers);
     }
-#if HAVE_DRUDGERS
-    if (engine->drudgers && engine->config) {
-       for (i=0; i < (size_t) engine->config->num_signer_threads; i++) {
-           worker_cleanup(engine->drudgers[i]);
-       }
-        allocator_deallocate(allocator, (void*) engine->drudgers);
-    }
-#endif
     schedule_cleanup(engine->taskq);
     fifoq_cleanup(engine->signq);
     cmdhandler_cleanup(engine->cmdhandler);

Modified: trunk/OpenDNSSEC/enforcer-ng/src/daemon/engine.h
==============================================================================
--- trunk/OpenDNSSEC/enforcer-ng/src/daemon/engine.h	Fri Feb  7 08:11:26 2014	(r7630)
+++ trunk/OpenDNSSEC/enforcer-ng/src/daemon/engine.h	Fri Feb  7 10:42:07 2014	(r7631)
@@ -66,7 +66,6 @@
     allocator_type* allocator;
     engineconfig_type* config;
     worker_type** workers;
-    worker_type** drudgers;
     schedule_type* taskq;
     fifoq_type* signq;
     help_xxxx_cmd_type *help;

Modified: trunk/OpenDNSSEC/enforcer-ng/src/daemon/worker.c
==============================================================================
--- trunk/OpenDNSSEC/enforcer-ng/src/daemon/worker.c	Fri Feb  7 08:11:26 2014	(r7630)
+++ trunk/OpenDNSSEC/enforcer-ng/src/daemon/worker.c	Fri Feb  7 10:42:07 2014	(r7631)
@@ -45,19 +45,12 @@
 
 #include <time.h> /* time() */
 
-ods_lookup_table worker_str[] = {
-    { WORKER_WORKER, "worker" },
-    { WORKER_DRUDGER, "drudger" },
-    { 0, NULL }
-};
-
-
 /**
  * Create worker.
  *
  */
 worker_type*
-worker_create(allocator_type* allocator, int num, worker_id type)
+worker_create(allocator_type* allocator, int num)
 {
     worker_type* worker;
 
@@ -77,7 +70,6 @@
     worker->engine = NULL;
     worker->task = NULL;
     worker->need_to_exit = 0;
-    worker->type = type;
     worker->clock_in = 0;
     worker->jobs_appointed = 0;
     worker->jobs_completed = 0;
@@ -89,22 +81,6 @@
     return worker;
 }
 
-
-/**
- * Convert worker type to string.
- *
- */
-static const char*
-worker2str(worker_id type)
-{
-    ods_lookup_table *lt = ods_lookup_by_id(worker_str, type);
-    if (lt) {
-        return lt->name;
-    }
-    return NULL;
-}
-
-
 /**
  * Has this worker measured up to all appointed jobs?
  *
@@ -116,7 +92,6 @@
         worker->jobs_appointed;
 }
 
-
 /**
  * Perform task.
  *
@@ -134,8 +109,8 @@
     ods_log_assert(worker->task->context);
 
     task = (task_type*) worker->task;
-    ods_log_debug("[%s[%i]]: perform task [%s] for %s at %u",
-       worker2str(worker->type), worker->thread_num, task_what2str(task->what),
+    ods_log_debug("[worker[%i]]: perform task [%s] for %s at %u",
+       worker->thread_num, task_what2str(task->what),
        task_who2str(task->who), (uint32_t) worker->clock_in);
 
 	worker->task = task_perform(task);
@@ -146,18 +121,16 @@
  * Work.
  *
  */
-static void
-worker_work(worker_type* worker)
+void
+worker_start(worker_type* worker)
 {
     time_t now, timeout = 1;
     task_type *task_that_was_worked_on;
 
     ods_log_assert(worker);
-    ods_log_assert(worker->type == WORKER_WORKER);
 
     while (worker->need_to_exit == 0) {
-        ods_log_debug("[%s[%i]]: report for duty", worker2str(worker->type),
-            worker->thread_num);
+        ods_log_debug("[worker[%i]]: report for duty", worker->thread_num);
 
         lock_basic_lock(&worker->engine->taskq->schedule_lock);
         /* [LOCK] schedule */
@@ -168,8 +141,7 @@
             /* [UNLOCK] schedule */
             lock_basic_unlock(&worker->engine->taskq->schedule_lock);
 
-            ods_log_debug("[%s[%i]] start working",
-                          worker2str(worker->type), worker->thread_num);
+            ods_log_debug("[worker[%i]] start working", worker->thread_num);
 
             worker->clock_in = time(NULL);
             worker_perform_task(worker);
@@ -177,8 +149,7 @@
             task_that_was_worked_on = worker->task;
             worker->task = NULL;
             
-            ods_log_debug("[%s[%i]] finished working",
-                          worker2str(worker->type), worker->thread_num);
+            ods_log_debug("[worker[%i]] finished working", worker->thread_num);
             
             if (task_that_was_worked_on)
                 (void) lock_and_schedule_task(worker->engine->taskq,
@@ -186,8 +157,7 @@
             
             timeout = 1;
         } else {
-            ods_log_debug("[%s[%i]] nothing to do", worker2str(worker->type),
-                worker->thread_num);
+            ods_log_debug("[worker[%i]] nothing to do", worker->thread_num);
 
             worker->task = schedule_get_first_task(worker->engine->taskq);
 
@@ -210,133 +180,6 @@
     return;
 }
 
-
-/**
- * Drudge.
- *
- */
-static void
-worker_drudge(worker_type* worker)
-{
-    void* context = NULL;
-    task_type* task = NULL;
-    ods_status status = ODS_STATUS_OK;
-    worker_type* chief = NULL;
-    hsm_ctx_t* ctx = NULL;
-
-    ods_log_assert(worker);
-    ods_log_assert(worker->type == WORKER_DRUDGER);
-
-    while (worker->need_to_exit == 0) {
-        
-        /* FIXME: Figure out whether we want to do something like e.g. generate keys.. */
-        int NOTHING_TO_DO = 1;
-        
-        ods_log_debug("[%s[%i]] report for duty", worker2str(worker->type),
-            worker->thread_num);
-
-        while (NOTHING_TO_DO) {
-            ods_log_debug("[%s[%i]] nothing to do", worker2str(worker->type),
-                          worker->thread_num);
-            if (ctx) {
-                hsm_destroy_context(ctx);
-                ctx = NULL;
-            }
-            worker_wait(&worker->engine->signq->q_lock,
-                        &worker->engine->signq->q_threshold);
-        }
-            
-        lock_basic_lock(&worker->engine->signq->q_lock);
-        /* [LOCK] schedule */
-        fifoq_pop(worker->engine->signq, &chief);
-        /* [UNLOCK] schedule */
-        lock_basic_unlock(&worker->engine->signq->q_lock);
-            
-        /* set up the work */
-        if (chief) {
-            task = chief->task;
-        }
-        if (task) {
-            context = task->context;
-        }
-        if (!context) {
-            ods_log_error("[%s[%i]]: unable to drudge: no context reference",
-                worker2str(worker->type), worker->thread_num);
-        }
-        if (!ctx) {
-            ctx = hsm_create_context();
-            if (ctx == NULL) {
-                ods_log_error("[%s[%i]]: unable to drudge: error "
-                    "creating libhsm context", worker2str(worker->type),
-                    worker->thread_num);
-                /* wipe fifoq, notify the chief */
-            }
-        }
-        if (context && ctx) {
-            ods_log_assert(context);
-            ods_log_assert(ctx);
-
-            worker->clock_in = time(NULL);
-            
-            /* FIXME: perform some hsm related work, like key generation. */
-            /* We need to hookup a task here */
-            
-            status = ODS_STATUS_OK; /* rrset_sign(ctx, rrset, context->dname, context->signconf, chief->clock_in, context->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) {
-                worker_wakeup(chief);
-            }
-        }
-        context = NULL;
-        task = NULL;
-        chief = NULL;
-    }
-
-    /* cleanup open HSM sessions */
-    if (ctx) {
-        hsm_destroy_context(ctx);
-        ctx = NULL;
-    }
-    return;
-}
-
-
-/**
- * Start worker.
- *
- */
-void
-worker_start(worker_type* worker)
-{
-    ods_log_assert(worker);
-    switch (worker->type) {
-        case WORKER_DRUDGER:
-            worker_drudge(worker);
-            break;
-        case WORKER_WORKER:
-            worker_work(worker);
-            break;
-        default:
-            ods_log_error("[worker] illegal worker (id=%i)", worker->type);
-            return;
-    }
-    return;
-}
-
-
 /**
  * Put worker to sleep.
  *
@@ -386,8 +229,7 @@
 {
     ods_log_assert(worker);
     if (worker && worker->sleeping && !worker->waiting) {
-        ods_log_debug("[%s[%i]] wake up", worker2str(worker->type),
-           worker->thread_num);
+        ods_log_debug("[worker[%i]] wake up", worker->thread_num);
         lock_basic_lock(&worker->worker_lock);
         /* [LOCK] worker */
         lock_basic_alarm(&worker->worker_alarm);

Modified: trunk/OpenDNSSEC/enforcer-ng/src/daemon/worker.h
==============================================================================
--- trunk/OpenDNSSEC/enforcer-ng/src/daemon/worker.h	Fri Feb  7 08:11:26 2014	(r7630)
+++ trunk/OpenDNSSEC/enforcer-ng/src/daemon/worker.h	Fri Feb  7 10:42:07 2014	(r7631)
@@ -44,13 +44,6 @@
 extern "C" {
 #endif
 
-enum worker_enum {
-    WORKER_NONE = 0,
-    WORKER_WORKER = 1,
-    WORKER_DRUDGER
-};
-typedef enum worker_enum worker_id;
-
 struct engine_struct;
 
 typedef struct worker_struct worker_type;
@@ -60,7 +53,6 @@
     ods_thread_type thread_id;
     struct engine_struct* engine;
     task_type* task;
-    worker_id type;
     time_t clock_in;
     size_t jobs_appointed;
     size_t jobs_completed;
@@ -80,7 +72,7 @@
  * \return worker_type* created worker
  *
  */
-worker_type* worker_create(allocator_type* allocator, int num, worker_id type);
+worker_type* worker_create(allocator_type* allocator, int num);
 
 /**
  * Start working.



More information about the Opendnssec-commits mailing list