Commit Graph
26 Commits
Author SHA1 Message Date
Tobias Brunner 83eacc448c processor: Move priority threads assignment to set_threads()
This avoids the evaluation of %N even if the thread pool is never used.
We need to avoid as many custom printf specifiers as possible when
fuzzing our code to avoid excessive log messages.
2017-05-23 18:29:12 +02:00
Martin Willi 874e212f71 processor: Flush pending jobs during cancel(), not destroy
During shutdown, cancel queued jobs earlier to avoid having cleanup functions
accessing infrastructure not available anymore, for example watcher.
2014-05-07 14:13:34 +02:00
Tobias Brunner 8dc6e71632 lib: All settings use configured namespace 2014-02-12 14:34:32 +01:00
Martin Willi dcd5129c25 processor: force synchronous execute_job() if set_threads(0) has been called
During daemon shutdown, some idle threads might be lingering around even if
set_threads(0) already has been called. To avoid any races, we enforce
synchronous execution of the job.
2013-07-19 15:30:22 +02:00
Martin Willi 1897dd730f processor: remove the now unused get_threads() method again 2013-07-18 16:00:31 +02:00
Martin Willi 6653e6c13e processor: add an execute_job() method to directly execute an important job
If all worker threads are busy and waiting for an event, we must ensure that
a job delivering that event gets executed. This new method has this property
for CRITICAL jobs, using a worker if we have one, but executing the job directly
if not.
2013-07-18 16:00:31 +02:00
Martin Willi 50720d7ce9 processor: add a getter for the threads passed to set_threads() 2013-07-18 16:00:29 +02:00
Tobias Brunner b1b0cce396 processor: Simplified the main loop 2013-06-28 17:02:06 +02:00
Tobias Brunner 6ca25ccc04 processor: Don't hold the lock while destroying jobs
If a lock is held when queue_job() is called and the same lock is
required during the destruction of a job, holding the internal lock
in the processor while calling destroy() could result in a deadlock.
2013-06-28 17:02:05 +02:00
Tobias Brunner f05b427265 Moved debug.[ch] to utils folder 2012-10-24 16:00:51 +02:00
Tobias Brunner 12642a6831 Moved data structures to new collections subfolder 2012-10-24 16:00:49 +02:00
Tobias Brunner e0efd7c121 Make rescheduling a job more predictable
This avoids race conditions between calls to cancel() and jobs that like
to be rescheduled.  If jobs were able to reschedule themselves it would
theoretically be possible that two worker threads have the same job
assigned (the one currently executing the job and the one executing the
same but rescheduled job if it already is time to execute it), this means
that cancel() could be called twice for that job.

Creating a new job based on the current one and reschedule that is also
OK, but rescheduling itself is more efficient for jobs that need to be
executed often.
2012-06-25 17:49:12 +02:00
Tobias Brunner 26d77eb3e6 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.
2012-06-25 17:38:59 +02:00
Tobias Brunner 7fec83af28 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.
2012-06-25 17:10:28 +02:00
Tobias Brunner b24287c269 Log worker thread ID with two digits. 2011-12-16 16:44:38 +01:00
Tobias Brunner edad908792 Fixed compiler warnings regarding enum comparison.
Warnings like

  comparison of unsigned expression < 0 is always false

are reported with -Wextra when enum types that are compiled to an
unsigned type (which is up to the compiler) are checked for negativity.
2011-11-25 09:40:30 +01:00
Tobias Brunner dcc1ad6a23 Prevent deadlock while shutting down thread pool.
During destruction the main thread locks the mutex in processor_t and
waits on a condvar for threads to have terminated.  Because the mutex
has also to be locked to decrement the thread count the condvar cannot
be signaled before doing that as otherwise the main thread might already
be waiting to join the threads while locking the mutex and thus causing
a deadlock.
2011-06-08 11:44:42 +02:00
Tobias Brunner 92abe2bd68 Update working thread count without allocation. 2011-05-16 18:28:03 +02:00
Tobias Brunner 21692169b9 Make sure working thread count is correctly updated 2011-05-16 15:24:16 +02:00
Martin Willi 877fdcf0b8 Count number of threads active in each class, and reserve threads only if none active 2011-05-16 15:24:14 +02:00
Martin Willi 68f56418cd Reserve threads for job priority classes based on strongswan.conf options 2011-05-16 15:24:13 +02:00
Martin Willi c73d4f53f5 Processor job scheduling respects job priority classes 2011-05-16 15:24:13 +02:00
Martin Willi 3316742969 Migrated processor to INIT/METHOD macros 2011-05-05 11:14:50 +02:00
Martin Willi 11f89bc948 Do not invoke processor restart() if not required
Doing so might result in a deadlock during shutdown if a delayed
restart is locked on the bus during the debug statement.
2011-03-15 11:48:19 +01:00
Martin Willi d93060759e Remove obsolete pool_size argument in processor_create() 2010-11-16 09:39:06 +01:00
Tobias Brunner e18556e9e9 Moved scheduler and thread pool to libstrongswan. 2010-09-02 19:04:18 +02:00