]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: remove rsan field from Windows' poll.operation
authorqmuntal <quimmuntal@gmail.com>
Wed, 2 Jul 2025 10:51:42 +0000 (12:51 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Mon, 28 Jul 2025 18:52:15 +0000 (11:52 -0700)
There is no need to keep the rsan field in the poll.operation struct.

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

Change-Id: I5e99e0e87178b63a19f0b9883b7b3d25abfd9ec3
Reviewed-on: https://go-review.googlesource.com/c/go/+/685417
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
src/internal/poll/fd_windows.go

index 99aacfe93c606af53224330f39cde8cf00246eb8..e57d1f1bd867ef64fe510fe1455019653b529b18 100644 (file)
@@ -80,7 +80,6 @@ type operation struct {
        buf  syscall.WSABuf
        msg  windows.WSAMsg
        rsa  *syscall.RawSockaddrAny
-       rsan int32
        bufs []syscall.WSABuf
 }
 
@@ -668,9 +667,9 @@ func (fd *FD) ReadFrom(buf []byte) (int, syscall.Sockaddr, error) {
                if o.rsa == nil {
                        o.rsa = new(syscall.RawSockaddrAny)
                }
-               o.rsan = int32(unsafe.Sizeof(*o.rsa))
+               rsan := int32(unsafe.Sizeof(*o.rsa))
                var flags uint32
-               err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &o.rsan, &o.o, nil)
+               err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &rsan, &o.o, nil)
                return qty, err
        })
        err = fd.eofError(n, err)
@@ -699,9 +698,9 @@ func (fd *FD) ReadFromInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error)
                if o.rsa == nil {
                        o.rsa = new(syscall.RawSockaddrAny)
                }
-               o.rsan = int32(unsafe.Sizeof(*o.rsa))
+               rsan := int32(unsafe.Sizeof(*o.rsa))
                var flags uint32
-               err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &o.rsan, &o.o, nil)
+               err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &rsan, &o.o, nil)
                return qty, err
        })
        err = fd.eofError(n, err)
@@ -730,9 +729,9 @@ func (fd *FD) ReadFromInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error)
                if o.rsa == nil {
                        o.rsa = new(syscall.RawSockaddrAny)
                }
-               o.rsan = int32(unsafe.Sizeof(*o.rsa))
+               rsan := int32(unsafe.Sizeof(*o.rsa))
                var flags uint32
-               err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &o.rsan, &o.o, nil)
+               err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &rsan, &o.o, nil)
                return qty, err
        })
        err = fd.eofError(n, err)
@@ -1040,10 +1039,11 @@ 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.rsan = int32(unsafe.Sizeof(rawsa[0]))
+       rsan := uint32(unsafe.Sizeof(rawsa[0]))
        _, err := fd.execIO(o, func(o *operation) (qty uint32, err error) {
-               err = AcceptFunc(fd.Sysfd, s, (*byte)(unsafe.Pointer(&rawsa[0])), 0, uint32(o.rsan), uint32(o.rsan), &qty, &o.o)
+               err = AcceptFunc(fd.Sysfd, s, (*byte)(unsafe.Pointer(&rawsa[0])), 0, rsan, rsan, &qty, &o.o)
                return qty, err
+
        })
        if err != nil {
                CloseFunc(s)
@@ -1078,7 +1078,7 @@ func (fd *FD) Accept(sysSocket func() (syscall.Handle, error)) (syscall.Handle,
 
                errcall, err := fd.acceptOne(s, rawsa[:], o)
                if err == nil {
-                       return s, rawsa[:], uint32(o.rsan), "", nil
+                       return s, rawsa[:], uint32(unsafe.Sizeof(rawsa[0])), "", nil
                }
 
                // Sometimes we see WSAECONNRESET and ERROR_NETNAME_DELETED is