aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2026-02-05 14:57:53 +0100
committerQuim Muntal <quimmuntal@gmail.com>2026-02-11 20:16:35 -0800
commitb40f0b118014f8dbc25e8ef4de82ccf78410903f (patch)
tree337802d9de4236aeab552df2b853fa1f74e7fc0b /src
parent54c46328ccb9d559fa21c09fd8e2dff22a99c72c (diff)
downloadgo-b40f0b118014f8dbc25e8ef4de82ccf78410903f.tar.xz
internal/poll: simplify IOCP association checks
This is a step towards deferring adding the handle to IOCP until the first IO operation. FD.pollable() obscures the fact that it is really checking if the handle is associated with the IOCP. This doesn't need to be a function that checks multiple conditions. It can be a simple boolean field that tracks whether the handle is associated with the IOCP or not. For #76391 Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-amd64-race Change-Id: I3ee6532f8a387fb5cfae8ae3d20ea9569f585e71 Reviewed-on: https://go-review.googlesource.com/c/go/+/742282 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/internal/poll/fd_windows.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go
index c9e74d0699..6875557c6f 100644
--- a/src/internal/poll/fd_windows.go
+++ b/src/internal/poll/fd_windows.go
@@ -269,7 +269,7 @@ func (fd *FD) execIO(mode int, submit func(o *operation) (uint32, error), buf []
}
}()
}
- if !fd.pollable() {
+ if !fd.associated {
// If the handle is opened for overlapped IO but we can't
// use the runtime poller, then we need to use an
// event to wait for the IO to complete.
@@ -370,7 +370,8 @@ type FD struct {
// Whether FILE_FLAG_OVERLAPPED was not set when opening the file.
isBlocking bool
- disassociated bool
+ // Whether the handle is currently associated with the IOCP.
+ associated bool
// readPinner and writePinner are automatically unpinned
// before execIO returns.
@@ -400,12 +401,6 @@ func (fd *FD) addOffset(off int) {
fd.offset += int64(off)
}
-// pollable should be used instead of fd.pd.pollable(),
-// as it is aware of the disassociated state.
-func (fd *FD) pollable() bool {
- return fd.pd.pollable() && !fd.disassociated
-}
-
// fileKind describes the kind of file.
type fileKind byte
@@ -458,6 +453,7 @@ func (fd *FD) Init(net string, pollable bool) error {
if err != nil {
return err
}
+ fd.associated = true
// FILE_SKIP_SET_EVENT_ON_HANDLE is always safe to use. We don't use that feature
// and it adds some overhead to the Windows I/O manager.
@@ -490,7 +486,7 @@ func (fd *FD) DisassociateIOCP() error {
}
defer fd.readWriteUnlock()
- if fd.isBlocking || !fd.pollable() {
+ if !fd.associated {
// Nothing to disassociate.
return nil
}
@@ -500,7 +496,7 @@ func (fd *FD) DisassociateIOCP() error {
return err
}
// tryReadWriteLock means we have exclusive access to fd.
- fd.disassociated = true
+ fd.associated = false
// Don't call fd.pd.close(), it would be too racy.
// There is no harm on leaving fd.pd open until Close is called.
return nil