From 7fec83af28f233a02b7ae08c6fd4de65799cb6b4 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 19 Jun 2012 10:45:17 +0200 Subject: Give processor_t more control over the lifecycle of a job Jobs are now destroyed by the processor, but they are allowed to reschedule themselves. That is, parts of the reschedule functionality already provided by callback_job_t is moved to the processor. Not yet fully supported is JOB_REQUEUE_DIRECT and canceling jobs. Note: job_t.destroy() is now called not only for queued jobs but also after execution or cancellation of jobs. job_t.status can be used to decide what to do in said method. --- src/libcharon/control/controller.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/libcharon/control/controller.c') diff --git a/src/libcharon/control/controller.c b/src/libcharon/control/controller.c index c23bf044e..be691178d 100644 --- a/src/libcharon/control/controller.c +++ b/src/libcharon/control/controller.c @@ -290,7 +290,8 @@ METHOD(listener_t, child_state_change, bool, METHOD(job_t, recheckin, void, interface_job_t *job) { - if (job->listener.ike_sa) + if (job->public.status == JOB_STATUS_QUEUED && + job->listener.ike_sa) { charon->ike_sa_manager->checkin(charon->ike_sa_manager, job->listener.ike_sa); @@ -304,7 +305,7 @@ METHOD(controller_t, create_ike_sa_enumerator, enumerator_t*, wait); } -METHOD(job_t, initiate_execute, void, +METHOD(job_t, initiate_execute, job_requeue_t, interface_job_t *job) { ike_sa_t *ike_sa; @@ -322,7 +323,7 @@ METHOD(job_t, initiate_execute, void, charon->ike_sa_manager, IKE_ANY, TRUE); DESTROY_IF(listener->ike_sa); listener->status = FAILED; - return; + return JOB_REQUEUE_NONE; } listener->ike_sa = ike_sa; @@ -343,6 +344,7 @@ METHOD(job_t, initiate_execute, void, ike_sa); listener->status = FAILED; } + return JOB_REQUEUE_NONE; } METHOD(controller_t, initiate, status_t, @@ -389,7 +391,7 @@ METHOD(controller_t, initiate, status_t, return job.listener.status; } -METHOD(job_t, terminate_ike_execute, void, +METHOD(job_t, terminate_ike_execute, job_requeue_t, interface_job_t *job) { interface_listener_t *listener = &job->listener; @@ -409,6 +411,7 @@ METHOD(job_t, terminate_ike_execute, void, ike_sa); listener->status = SUCCESS; } + return JOB_REQUEUE_NONE; } METHOD(controller_t, terminate_ike, status_t, @@ -466,7 +469,7 @@ METHOD(controller_t, terminate_ike, status_t, return job.listener.status; } -METHOD(job_t, terminate_child_execute, void, +METHOD(job_t, terminate_child_execute, job_requeue_t, interface_job_t *job) { interface_listener_t *listener = &job->listener; @@ -486,6 +489,7 @@ METHOD(job_t, terminate_child_execute, void, ike_sa); listener->status = FAILED; } + return JOB_REQUEUE_NONE; } METHOD(controller_t, terminate_child, status_t, -- cgit v1.2.3