aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/processing/jobs/job.h
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2012-06-19 13:29:09 +0200
committerTobias Brunner <tobias@strongswan.org>2012-06-25 17:38:59 +0200
commit26d77eb3e61b2ff929dff96bbb53a5d22d76ce4f (patch)
tree5d5b7bd7bb2cd6a721c65b82f8ce2a8b3f4fdf22 /src/libstrongswan/processing/jobs/job.h
parent7fec83af28f233a02b7ae08c6fd4de65799cb6b4 (diff)
downloadstrongswan-26d77eb3e61b2ff929dff96bbb53a5d22d76ce4f.tar.bz2
strongswan-26d77eb3e61b2ff929dff96bbb53a5d22d76ce4f.tar.xz
Centralized thread cancellation in processor_t
This ensures that no threads are active when plugins and the rest of the daemon are unloaded. callback_job_t was simplified a lot in the process as its main functionality is now contained in processor_t. The parent-child relationships were abandoned as these were only needed to simplify job cancellation.
Diffstat (limited to 'src/libstrongswan/processing/jobs/job.h')
-rw-r--r--src/libstrongswan/processing/jobs/job.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/libstrongswan/processing/jobs/job.h b/src/libstrongswan/processing/jobs/job.h
index c3e640065..43bb5430e 100644
--- a/src/libstrongswan/processing/jobs/job.h
+++ b/src/libstrongswan/processing/jobs/job.h
@@ -103,6 +103,26 @@ struct job_t {
job_requeue_t (*execute) (job_t *this);
/**
+ * Cancel a job.
+ *
+ * Implementing this method is optional. It allows potentially blocking
+ * jobs to be canceled during shutdown.
+ *
+ * If no special action is to be taken simply return FALSE then the thread
+ * executing the job will be canceled. If TRUE is returned the job is
+ * expected to return from execute() itself (i.e. the thread won't be
+ * canceled explicitly and can still be joined later).
+ * Jobs that return FALSE have to make sure they provide the appropriate
+ * cancellation points.
+ *
+ * @note Regular jobs that do not block MUST NOT implement this method.
+ * @note This method could be called even before execute() has been called.
+ *
+ * @return FALSE to cancel the thread, TRUE if canceled otherwise
+ */
+ bool (*cancel)(job_t *this);
+
+ /**
* Get the priority of a job.
*
* @return job priority
@@ -117,7 +137,7 @@ struct job_t {
*
* Use the status of a job to decide what to do during destruction.
*/
- void (*destroy) (job_t *this);
+ void (*destroy)(job_t *this);
};
#endif /** JOB_H_ @}*/