]> git.ipfire.org Git - thirdparty/strongswan.git/commit
windows: Avoid potential races with canceling threads master
authorTobias Brunner <tobias@strongswan.org>
Tue, 28 Jul 2026 09:51:16 +0000 (11:51 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 31 Jul 2026 14:07:52 +0000 (16:07 +0200)
commit5011838b32ac88ba9593af4b727932c34b28e127
tree6da2c99e6e6f0e3ed550e37288f22493f9283f00
parent3934089415f4baca7a49267a4b51317d305fb1fc
windows: Avoid potential races with canceling threads

The previous code did not synchronize some of the flags, so it was
possible that `cancel()` did not work properly (e.g. no APC queued).

This change uses atomics to set/read the flags, it also avoids using
the global thread lock for synchronization as getting the condvar before
queuing the APC avoids having to sync with `docancel()`.  However, to
make sure we don't use a stale and potentially already freed condvar
when the thread is canceled a new lock is added and held until the
condvar has been signaled (using atomics for that member doesn't work as
the ordering rules enforced by atomics can not avoid that the thread in
`cancel()` potentially reads a stale value, or the race between reading
and signaling it).
src/libstrongswan/threading/windows/thread.c