aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/threading
Commit message (Collapse)AuthorAgeFilesLines
* thread: Don't hold mutex when calling cleanup handlers while terminatingTobias Brunner2016-04-131-12/+14
| | | | | | | | | | This could interfere with cleanup handlers that try to acquire mutexes while other threads holding these try to e.g. cancel the threads. As cleanup handlers are only queued by the threads themselves we don't need any synchronization to access the list. Fixes #1401.
* thread: Allow thread ID to be value returned by gettid()Thomas Egerer2016-03-043-14/+32
| | | | Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
* thread: Add a function to pop and call all registered cleanup handlersMartin Willi2015-04-153-0/+47
|
* thread: Don't acquire lock for thread_cleanup_push/popMartin Willi2015-04-151-5/+0
| | | | | This is called only by the thread for its own thread_t, and does not need synchronization.
* thread: Remove unneeded thread startup synchronizationMartin Willi2015-04-131-13/+4
| | | | | | | | | | | sem_init() is deprecated on OS X, and it actually fails with ENOSYS. Using our wrapped semaphore object is not an option, as it relies on the thread cleanup that we can't rely on at this stage. It is unclear why startup synchronization is required, as we can allocate the thread ID just before creating the pthread. There is a chance that we allocate a thread ID for a thread that fails to create, but the risk and consequences are negligible.
* apple: Introduce a central compatibility header with all __APPLE__ quirksMartin Willi2014-11-212-86/+3
|
* thread: Test for pending cancellation requests before poll()ing on OS XMartin Willi2014-11-211-0/+20
| | | | | As we are now using poll(2) instead of select(2), we need the work-around from 76dc329e for poll() as well.
* threading: Support rwlock try_write_lock() on WindowsMartin Willi2014-10-301-2/+0
| | | | | | | | | | | We explicitly avoided TryAcquireSRWLockExclusive() because of crashes. This issue was caused by a MinGW-w64 bug (mingw-w64 fix 46f77afc). Using a newer toolchain works fine. While try_write_lock() obviously can fail, not supporting it is not really an option, as some algorithms depend on occasionally successful calls. Certificate caching in the certificate manager and the cred_set cache rely on successful try_write_lock()ing.
* thread: Test for pending cancellation requests before select()ing on OS XMartin Willi2014-10-141-0/+28
| | | | | | This fixes some vici test cases on OS X, where the test thread tries to cancel the watcher thread during cleanup, but fails as select() does not honor the pre-issued cancellation request.
* mutex: Use atomics to set current thread in recursive mutexTobias Brunner2014-09-091-9/+12
| | | | | | | | Because this->thread is also read by threads that don't hold the mutex the previous implementation was problematic (especially since pthread_t is an opaque type of unknown length). Fixes #654.
* windows: Remove useless assignment in put_thread()Tobias Brunner2014-07-021-1/+1
|
* windows: Fix parameter name in Doxygen commentTobias Brunner2014-06-301-1/+1
|
* thread-value: Defer cleanup handling to thread termination on WindowsMartin Willi2014-06-173-40/+51
| | | | | | | | | | | Instead of cleaning up all thread-values during destruction, cleanup handler is invoked when a thread detaches. Thread detaching is cough using the Windows DllMain() entry point, and allows us to basically revert 204098a7. Using this mechanism, we make sure that the cleanup handler is invoked by the the correct thread. Further, this mechanism works for externally-spawned threads which run outside of our thread_cb() routine, and works more efficiently with short-running threads.
* windows: Use WINAPI call convention for Windows API callbacksMartin Willi2014-06-061-2/+4
| | | | | For x86_64 it does not actually matter, but for i686 builds the call convention is different with WINAPI.
* windows: Include for Vista instead of defining CondVar/SRWLock functions ourselfMartin Willi2014-06-045-33/+12
|
* thread-value: Immediately cleanup all Windows TLS values on destroyMartin Willi2014-06-043-14/+46
|
* windows: Prevent queueing of multiple thread cancel APCsMartin Willi2014-06-041-4/+13
| | | | | This avoids any races during cleanup invocation if multiple cancel() requests come in.
* windows: Provide a complete native Windows threading backendMartin Willi2014-06-047-0/+1492
|
* thread: Add a Windows pthread variant to print thread identifiersMartin Willi2014-06-031-0/+3
|
* thread: Properly clean up meta data of main threadTobias Brunner2014-03-071-0/+2
|
* thread: Note that tread_cancellation_point temporarily activates cancelabilityMartin Willi2013-11-061-5/+4
|
* Fixed some typosTobias Brunner2013-10-291-1/+1
|
* rwlock: Disable thread cancelability while waiting in (fallback) rwlockMartin Willi2013-10-241-0/+7
| | | | | | An rwlock wait is not a thread cancellation point. As a canceled thread would not have released the mutex, the rwlock would have been left in unusable state.
* rwlock: Don't use buggy pthread_rwlock on OS XMartin Willi2013-10-241-0/+7
| | | | Recursive read locks don't seem to work properly, at least on 10.9.
* semaphore: Support cancellation in wait functions of semaphore fallbackMartin Willi2013-10-231-4/+6
| | | | | Semaphore wait functions should be a thread cancellation point, but did not properly release the mutex in the fallback implementation.
* rwlock: Re-acquire rwlock even if condvar wait times outMartin Willi2013-10-231-1/+1
| | | | | A caller expects that the associated rwlock is held, whether the condvar gets signaled or the wait times out.
* thread: implicitly create thread_t if an external thread calls thread_current()Martin Willi2013-07-181-1/+14
|
* semaphore: similar to thread_create(), semaphore_create() is used by MachMartin Willi2013-05-061-0/+5
| | | | | | The compiler spits no warning, but the wrong symbol is used when calling semaphore_create() from strongSwan. Override the name with a #define to force the use of our semaphore_create().
* Use SIGUSR2 for SIG_CANCEL on AndroidTobias Brunner2013-02-261-0/+4
| | | | | | | | | | SIGRTMIN is defined as 32 while sigset_t is defined as unsigned long (i.e. holds 32 signals). Hence, the signal could never be blocked. Sending the signal still canceled threads, but sometimes in situations where they shouldn't have been canceled (e.g. while holding a lock). Fixes #298.
* Use a ./configure check to detect pthread spinlock availabilityMartin Willi2012-12-181-15/+7
| | | | | _POSIX_SPIN_LOCKS does not seem to be defined correctly on all systems (Debian libc 2.3.6). Fixes #262.
* Moved debug.[ch] to utils folderTobias Brunner2012-10-244-4/+4
|
* Moved data structures to new collections subfolderTobias Brunner2012-10-241-1/+1
|
* Use a helper function to add milliseconds to timeval structsTobias Brunner2012-10-182-13/+2
|
* Properly handle thread cancelation in rwlock_condvar_tTobias Brunner2012-09-211-15/+20
|
* Added a condvar implementation that works with rwlock_tTobias Brunner2012-09-212-0/+216
|
* Don't use POSIX semaphores if a MONOTONIC clock is availableMartin Willi2012-08-201-0/+8
| | | | | | POSIX semaphores use CLOCK_REALTIME, but our semaphore_t abstraction expects CLOCK_MONOTONIC based times. Use the mutex/condvar based fallback if time_monotonic() actuall returns monotonic times.
* Add a mutex/condvar based semaphore implementation if sem_timedwait is ↵Martin Willi2012-08-201-2/+67
| | | | | | unavailable Fixes #214.
* Merge branch 'android-app'Tobias Brunner2012-08-131-2/+2
|\ | | | | | | | | | | | | | | This branch introduces a userland IPsec implementation (libipsec) and an Android App which targets the VpnService API that is provided by Android 4+. The implementation is based on the bachelor thesis 'Userland IPsec for Android 4' by Giuliano Grassi and Ralf Sager.
| * Ensure thread IDs always start with 1 even if the library is reusedTobias Brunner2012-08-131-2/+2
| | | | | | | | | | | | Within the Android App the library stays loaded in memory and is just initialized/deinitialized with each connection, the static thread counter would continuously increase without this patch.
* | If _POSIX_SPIN_LOCKS is defined as -1, it is not availableMartin Willi2012-08-101-0/+4
|/
* Implemented recursive mutex without thread-specific counterTobias Brunner2012-08-031-23/+17
|
* Use a single thread-specific value for our custom rwlock_t implementationTobias Brunner2012-08-031-50/+67
| | | | | | The pthread implementation on Android currently only supports 64 different thread-specific values per process, which we hit easily when every rwlock_t requires one.
* Properly cleanup thread-local values for the threads destroying ↵Tobias Brunner2012-07-121-2/+19
| | | | thread_value_t objects
* Added wrapper for POSIX spin locksTobias Brunner2012-07-042-0/+190
|
* Added recursive read_lock support to our own implementation of rwlock_t.Tobias Brunner2012-05-021-4/+35
|
* Added a wrapper class around POSIX semaphores.Tobias Brunner2012-05-022-0/+191
|
* Fix gettid() on Android, which is defined in unistd.h there.Tobias Brunner2012-01-121-3/+4
|
* Use native gettid() if available (which is the case on Android).Tobias Brunner2012-01-101-3/+11
|
* Log native thread ID when a thread is created.Tobias Brunner2011-12-161-1/+16
| | | | | If possible gettid() is used, otherwise pthread_self() is logged (which is not completely portable, but seems to work on most supported platforms).
* Create a dummy pthread key for value "0", as some buggy PKCS#11 libraries ↵Martin Willi2011-12-071-0/+10
| | | | mangle it