]> git.ipfire.org Git - thirdparty/wireguard-go.git/commit
tun: windows: protect reads from closing
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 27 Apr 2021 02:22:45 +0000 (22:22 -0400)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 27 Apr 2021 02:22:45 +0000 (22:22 -0400)
commit097af6e1351ba80a18b8f63e9c07b9bd13b632bb
tree71053b525918fdf2fcde1793bb9e5986260050a9
parent8246d251ea9b9cbef07082bd69280a8f988cec0c
tun: windows: protect reads from closing

The code previously used the old errors channel for checking, rather
than the simpler boolean, which caused issues on shutdown, since the
errors channel was meaningless. However, looking at this exposed a more
basic problem: Close() and all the other functions that check the closed
boolean can race. So protect with a basic RW lock, to ensure that
Close() waits for all pending operations to complete.

Reported-by: Joshua Sjoding <joshua.sjoding@scjalliance.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
tun/tun_windows.go