threading: Support rwlock try_write_lock() on Windows
authorMartin Willi <martin@revosec.ch>
Wed, 22 Oct 2014 09:24:51 +0000 (11:24 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 30 Oct 2014 09:45:24 +0000 (10:45 +0100)
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.

src/libstrongswan/threading/windows/rwlock.c

index 0de57f7..fc0d6d8 100644 (file)
@@ -85,8 +85,6 @@ METHOD(rwlock_t, write_lock, void,
 METHOD(rwlock_t, try_write_lock, bool,
        private_rwlock_t *this)
 {
-       /* TODO: causes random failures and segfaults. Bug? */
-       return FALSE;
        return TryAcquireSRWLockExclusive(&this->srw);
 }