internal/poll: remove handle field from Windows' poll.operation

The handle field can be accessed directly wherever needed, there is
no need to store it in the operation struct.

This skims down the size of os.File by 16 bytes.

Change-Id: I87c94cb773437891127b6c36dc7f8883622ffed3
Reviewed-on: https://go-review.googlesource.com/c/go/+/685435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
qmuntal 2025-07-02 11:12:28 +02:00 committed by Gopher Robot
parent f7432e0230
commit f11599b0b9
2 changed files with 10 additions and 13 deletions

View file

@ -77,15 +77,14 @@ type operation struct {
mode int32
// fields used only by net package
buf syscall.WSABuf
msg windows.WSAMsg
sa syscall.Sockaddr
rsa *syscall.RawSockaddrAny
rsan int32
handle syscall.Handle
flags uint32
qty uint32
bufs []syscall.WSABuf
buf syscall.WSABuf
msg windows.WSAMsg
sa syscall.Sockaddr
rsa *syscall.RawSockaddrAny
rsan int32
flags uint32
qty uint32
bufs []syscall.WSABuf
}
func (o *operation) setEvent() {
@ -1028,10 +1027,9 @@ func (fd *FD) ConnectEx(ra syscall.Sockaddr) error {
func (fd *FD) acceptOne(s syscall.Handle, rawsa []syscall.RawSockaddrAny, o *operation) (string, error) {
// Submit accept request.
o.handle = s
o.rsan = int32(unsafe.Sizeof(rawsa[0]))
_, err := fd.execIO(o, func(o *operation) error {
return AcceptFunc(fd.Sysfd, o.handle, (*byte)(unsafe.Pointer(&rawsa[0])), 0, uint32(o.rsan), uint32(o.rsan), &o.qty, &o.o)
return AcceptFunc(fd.Sysfd, s, (*byte)(unsafe.Pointer(&rawsa[0])), 0, uint32(o.rsan), uint32(o.rsan), &o.qty, &o.o)
})
if err != nil {
CloseFunc(s)

View file

@ -63,7 +63,6 @@ func SendFile(fd *FD, src uintptr, size int64) (written int64, err error, handle
const maxChunkSizePerCall = int64(0x7fffffff - 1)
o := &fd.wop
o.handle = hsrc
for size > 0 {
chunkSize := maxChunkSizePerCall
if chunkSize > size {
@ -76,7 +75,7 @@ func SendFile(fd *FD, src uintptr, size int64) (written int64, err error, handle
n, err := fd.execIO(o, func(o *operation) error {
o.qty = uint32(chunkSize)
return syscall.TransmitFile(fd.Sysfd, o.handle, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND)
return syscall.TransmitFile(fd.Sysfd, hsrc, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND)
})
if err != nil {
return written, err, written > 0