Skip to content

Commit d7b4114

Browse files
committed
internal/poll: remove rsan field from Windows' poll.operation
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 <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Mark Freeman <[email protected]>
1 parent 361b1ab commit d7b4114

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/internal/poll/fd_windows.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ type operation struct {
8080
buf syscall.WSABuf
8181
msg windows.WSAMsg
8282
rsa *syscall.RawSockaddrAny
83-
rsan int32
8483
bufs []syscall.WSABuf
8584
}
8685

@@ -668,9 +667,9 @@ func (fd *FD) ReadFrom(buf []byte) (int, syscall.Sockaddr, error) {
668667
if o.rsa == nil {
669668
o.rsa = new(syscall.RawSockaddrAny)
670669
}
671-
o.rsan = int32(unsafe.Sizeof(*o.rsa))
670+
rsan := int32(unsafe.Sizeof(*o.rsa))
672671
var flags uint32
673-
err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &o.rsan, &o.o, nil)
672+
err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &rsan, &o.o, nil)
674673
return qty, err
675674
})
676675
err = fd.eofError(n, err)
@@ -699,9 +698,9 @@ func (fd *FD) ReadFromInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error)
699698
if o.rsa == nil {
700699
o.rsa = new(syscall.RawSockaddrAny)
701700
}
702-
o.rsan = int32(unsafe.Sizeof(*o.rsa))
701+
rsan := int32(unsafe.Sizeof(*o.rsa))
703702
var flags uint32
704-
err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &o.rsan, &o.o, nil)
703+
err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &rsan, &o.o, nil)
705704
return qty, err
706705
})
707706
err = fd.eofError(n, err)
@@ -730,9 +729,9 @@ func (fd *FD) ReadFromInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error)
730729
if o.rsa == nil {
731730
o.rsa = new(syscall.RawSockaddrAny)
732731
}
733-
o.rsan = int32(unsafe.Sizeof(*o.rsa))
732+
rsan := int32(unsafe.Sizeof(*o.rsa))
734733
var flags uint32
735-
err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &o.rsan, &o.o, nil)
734+
err = syscall.WSARecvFrom(fd.Sysfd, &o.buf, 1, &qty, &flags, o.rsa, &rsan, &o.o, nil)
736735
return qty, err
737736
})
738737
err = fd.eofError(n, err)
@@ -1040,10 +1039,11 @@ func (fd *FD) ConnectEx(ra syscall.Sockaddr) error {
10401039

10411040
func (fd *FD) acceptOne(s syscall.Handle, rawsa []syscall.RawSockaddrAny, o *operation) (string, error) {
10421041
// Submit accept request.
1043-
o.rsan = int32(unsafe.Sizeof(rawsa[0]))
1042+
rsan := uint32(unsafe.Sizeof(rawsa[0]))
10441043
_, err := fd.execIO(o, func(o *operation) (qty uint32, err error) {
1045-
err = AcceptFunc(fd.Sysfd, s, (*byte)(unsafe.Pointer(&rawsa[0])), 0, uint32(o.rsan), uint32(o.rsan), &qty, &o.o)
1044+
err = AcceptFunc(fd.Sysfd, s, (*byte)(unsafe.Pointer(&rawsa[0])), 0, rsan, rsan, &qty, &o.o)
10461045
return qty, err
1046+
10471047
})
10481048
if err != nil {
10491049
CloseFunc(s)
@@ -1078,7 +1078,7 @@ func (fd *FD) Accept(sysSocket func() (syscall.Handle, error)) (syscall.Handle,
10781078

10791079
errcall, err := fd.acceptOne(s, rawsa[:], o)
10801080
if err == nil {
1081-
return s, rawsa[:], uint32(o.rsan), "", nil
1081+
return s, rawsa[:], uint32(unsafe.Sizeof(rawsa[0])), "", nil
10821082
}
10831083

10841084
// Sometimes we see WSAECONNRESET and ERROR_NETNAME_DELETED is

0 commit comments

Comments
 (0)