]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: remove handle field from Windows' poll.operation
authorqmuntal <quimmuntal@gmail.com>
Wed, 2 Jul 2025 09:12:28 +0000 (11:12 +0200)
committerGopher Robot <gobot@golang.org>
Thu, 24 Jul 2025 17:50:32 +0000 (10:50 -0700)
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>
src/internal/poll/fd_windows.go
src/internal/poll/sendfile_windows.go

index f052a2a0163ac9c1fc8a89fff564727560a4c928..38fecb0e12db0fcec67cba3b2b06e15b04581efc 100644 (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)
index d1cc04069b523c07604677699b21b50af0a70949..67e7b2e76707851e94f4d293c15ba7900dae56ec 100644 (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