aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/processing
Commit message (Collapse)AuthorAgeFilesLines
* Use standard unsigned integer typesAndreas Steffen2016-03-243-5/+5
|
* watcher: Check for cancellation if poll() fails with EINTRMartin Willi2015-12-041-0/+7
| | | | | | | With LinuxThreads, poll() is unfortunately no cancellation point. It seems that poll gets woken up after cancellation, but we actively must check for cancellation before re-entering poll to properly shut down the watcher thread.
* scheduler: Add method to remove all scheduled jobsTobias Brunner2015-03-092-5/+21
| | | | References #840.
* apple: Redefine some additional clashing Mach typesMartin Willi2014-12-161-0/+2
| | | | | | While they usually are not included in a normal strongSwan build, the XPC header indirectly defines these Mach types. To build charon-xpc, which uses both XPC and strongSwan includes, we have to redefine these types.
* watcher: Proper handle poll() POLLHUP/NVAL signalingMartin Willi2014-11-281-13/+36
| | | | | | | poll() may return POLLHUP or POLLNVAL for given file descriptors. To handle these properly, we signal them to the EXCEPT watcher state, if registered. If not, we call the read/write callbacks, so they can properly fail when trying to read from or write to the file descriptor.
* watcher: Use Windows read/write(2) wrappers instead of compile-conditionsMartin Willi2014-11-211-8/+0
|
* watcher: Use poll(2) instead of selectMartin Willi2014-11-211-24/+38
|
* watcher: Doxygen comment fixedTobias Brunner2014-10-131-1/+1
|
* watcher: Add a method to query the watcher stateMartin Willi2014-09-242-7/+45
| | | | | This allows a user to check if the watcher is actually running, and potentially perform read operations directly instead of relying on watcher.
* watcher: Prevent race condition spawning multiple watcher threadsMartin Willi2014-06-171-1/+3
| | | | | | | | If file descriptors get added and removed in rapid succession, the active watcher thread might not take notice of it and continues running. However, add() spawns a watcher thread whenever a file descriptor is added to an empty set. This could result in multiple watcher threads, which is fixed by a proper check for running watchers.
* watcher: Add Windows supportMartin Willi2014-06-041-16/+80
| | | | | | | | | | Instead of a pipe we use a TCP socketpair (can't select() a _pipe()), and Windsock2 send/recv functions instead of read/write. Currently supported (and required) are file descriptors provided by Winsock only; we might use a separate mechanism for traditional file handles if required (or switch to Windows events and WaitForMultipleObjects) for a future version.
* watcher: Don't wait for running callback once watcher thread cancelledMartin Willi2014-05-071-1/+8
| | | | | | | | During shutdown, waiting for callbacks might never complete, as queued callbacks might not get executed under certain conditions. Not the clean fix, but works good enough for now. Seen on Windows in vici tests.
* watcher: Avoid queueing multiple watcher callbacks at the same timeMartin Willi2014-05-071-1/+8
| | | | | | | | | While we don't add FDs with an active callback to the watched FDSET, we still can get notifications for callbacks active due the asynchronous processing of the same. To avoid queue multiple callbacks, we check for queued callbacks before activating new ones.
* processor: Flush pending jobs during cancel(), not destroyMartin Willi2014-05-071-1/+11
| | | | | During shutdown, cancel queued jobs earlier to avoid having cleanup functions accessing infrastructure not available anymore, for example watcher.
* lib: All settings use configured namespaceTobias Brunner2014-02-121-1/+1
|
* watcher: Don't complain if select() syscall got interruptedMartin Willi2014-01-221-1/+1
|
* watcher: Rebuild fdset when select() failsMartin Willi2013-10-241-1/+12
| | | | | | This should make sure we refresh the fdset if a user closes an FD it just removed. Some selects() seem to complain about the bad FD before signaling the notification pipe.
* watcher: Made notify array initialization compatible with older GCC versionsTobias Brunner2013-07-251-2/+1
|
* processor: force synchronous execute_job() if set_threads(0) has been calledMartin Willi2013-07-191-1/+1
| | | | | | 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.
* Fix various API doc issues and typosTobias Brunner2013-07-181-1/+1
| | | | Partially based on an old patch by Adrian-Ken Rueegsegger.
* processor: remove the now unused get_threads() method againMartin Willi2013-07-182-17/+0
|
* watcher: use processors new execute_job() to notify FDsMartin Willi2013-07-181-9/+1
| | | | | Just queueing is problematic, as all threads might be busy waiting for events that the queued (but never executed) job delivers.
* processor: add an execute_job() method to directly execute an important jobMartin Willi2013-07-182-0/+36
| | | | | | | 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.
* watcher: properly support multiple watch callback types for the same FDMartin Willi2013-07-182-36/+45
|
* watcher: read multiple notifications if availableMartin Willi2013-07-181-2/+15
| | | | | Use non-blocking I/O on the read end of the notify pipe. This also makes sure the read does not block should select() signal data while there is none.
* watcher: add some debugging statementsMartin Willi2013-07-181-0/+12
|
* watcher: if the processor has no threads, execute the job with watcher threadMartin Willi2013-07-181-11/+19
| | | | | This is important during shutdown, where we might need to signal some FDs while all idle threads are gone already.
* processor: add a getter for the threads passed to set_threads()Martin Willi2013-07-182-1/+17
|
* watcher: unregister a watcher FD if its thread gets cancelledMartin Willi2013-07-181-0/+13
|
* watcher: release threads waiting in remove() when watcher thread gets cancelledMartin Willi2013-07-181-0/+24
| | | | | | | During daemon shutdown, users might call remove() after processor.set_threads(0) has been called. This gets problematic, as a watch event might be unable to signal completion when no threads are available anymore. Work around this issue by cancelling waiters once processor.cancel() has been called.
* watcher: add a centralized an generic facility to monitor file descriptorsMartin Willi2013-07-182-0/+493
|
* processor: Simplified the main loopTobias Brunner2013-06-281-109/+127
|
* processor: Don't hold the lock while destroying jobsTobias Brunner2013-06-281-38/+66
| | | | | | 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.
* Moved debug.[ch] to utils folderTobias Brunner2012-10-242-2/+2
|
* Moved data structures to new collections subfolderTobias Brunner2012-10-242-2/+2
|
* Make rescheduling a job more predictableTobias Brunner2012-06-252-37/+85
| | | | | | | | | | | | | 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.
* Centralized thread cancellation in processor_tTobias Brunner2012-06-256-206/+124
| | | | | | | | | | 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.
* Give processor_t more control over the lifecycle of a jobTobias Brunner2012-06-256-105/+176
| | | | | | | | | | | 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.
* Use wrapped semaphore in callback_job_t.Tobias Brunner2012-05-021-12/+9
|
* Log worker thread ID with two digits.Tobias Brunner2011-12-161-2/+2
|
* Fixed compiler warnings regarding enum comparison.Tobias Brunner2011-11-251-1/+1
| | | | | | | | | 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.
* Fixed common misspellings.Tobias Brunner2011-07-202-2/+2
| | | | Mostly found by 'codespell'.
* Prevent deadlock while shutting down thread pool.Tobias Brunner2011-06-081-2/+2
| | | | | | | | | 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.
* Update working thread count without allocation.Tobias Brunner2011-05-161-22/+15
|
* Make sure working thread count is correctly updatedTobias Brunner2011-05-161-4/+23
|
* Use CRITICAL job priority class for long running dispatcher jobsMartin Willi2011-05-161-1/+2
|
* Introduce a highest priority job for critical thread servicesMartin Willi2011-05-162-2/+5
|
* Added a callback_job constructor supporting custom prioritiesMartin Willi2011-05-162-4/+36
|
* Count number of threads active in each class, and reserve threads only if ↵Martin Willi2011-05-162-17/+66
| | | | none active
* Reserve threads for job priority classes based on strongswan.conf optionsMartin Willi2011-05-161-1/+17
|