]> Cypherpunks repositories - gostls13.git/commit
internal/poll: fix race in Close
authorqmuntal <quimmuntal@gmail.com>
Tue, 8 Apr 2025 13:31:02 +0000 (15:31 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Wed, 9 Apr 2025 20:07:09 +0000 (13:07 -0700)
commitcac276f81a5ff11ae3c9027c45d14469f2b7fb70
tree1b27ddb31cadb8466150fd4c0a77971aa6120d09
parent7007dfcd0c32c1be83c921b0859dd48464c7c5aa
internal/poll: fix race in Close

There is a potential race between a concurrent call to FD.initIO, which
calls FD.pd.init, and a call to FD.Close, which calls FD.pd.evict.

This is solved by calling FD.initIO in FD.Close, as that will block
until the concurrent FD.initIO has completed. Note that FD.initIO is
no-op if first called from here.

The race window is so small that it is not possible to write a test
that triggers it.

Change-Id: Ie2f2818e746b9d626fe3b9eb6b8ff967c81ef863
Reviewed-on: https://go-review.googlesource.com/c/go/+/663815
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
src/internal/poll/fd_windows.go