]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: make waitIO more idempontent
authorqmuntal <quimmuntal@gmail.com>
Thu, 5 Feb 2026 12:16:12 +0000 (13:16 +0100)
committerQuim Muntal <quimmuntal@gmail.com>
Fri, 6 Feb 2026 20:27:40 +0000 (12:27 -0800)
This is a step towards deferring adding the handle to IOCP until the
first IO operation.

waitIO should use the overlapped event if it is provided, regardless of
whether FD is pollable or not. This simplifies reasoning about the code
and makes it more robust to race conditions.

While here, remove the panic in waitIO that was triggered when called
with a blocking handle. That shouldn't happen, but if it does,
fd.pd.wait will return an error that will already be promoted to
a panic.

For #76391

Change-Id: I8e84592568a3ef66e71161eb2c5f515dde638117
Reviewed-on: https://go-review.googlesource.com/c/go/+/742280
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/internal/poll/fd_windows.go

index 699239c57be632472b449d81469eea00a344562a..83407945457c82c78e07bdb6649e626447ff15d3 100644 (file)
@@ -201,10 +201,7 @@ var operationPool = sync.Pool{
 // waitIO waits for the IO operation to complete,
 // handling cancellation if necessary.
 func (fd *FD) waitIO(o *operation) error {
-       if fd.isBlocking {
-               panic("can't wait on blocking operations")
-       }
-       if !fd.pollable() {
+       if o.o.HEvent != 0 {
                // The overlapped handle is not added to the runtime poller,
                // the only way to wait for the IO to complete is block until
                // the overlapped event is signaled.