Skip to content

Commit f11599b

Browse files
qmuntalgopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Auto-Submit: Michael Knyszek <[email protected]> Reviewed-by: Damien Neil <[email protected]>
1 parent f7432e0 commit f11599b

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/internal/poll/fd_windows.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,14 @@ type operation struct {
7777
mode int32
7878

7979
// fields used only by net package
80-
buf syscall.WSABuf
81-
msg windows.WSAMsg
82-
sa syscall.Sockaddr
83-
rsa *syscall.RawSockaddrAny
84-
rsan int32
85-
handle syscall.Handle
86-
flags uint32
87-
qty uint32
88-
bufs []syscall.WSABuf
80+
buf syscall.WSABuf
81+
msg windows.WSAMsg
82+
sa syscall.Sockaddr
83+
rsa *syscall.RawSockaddrAny
84+
rsan int32
85+
flags uint32
86+
qty uint32
87+
bufs []syscall.WSABuf
8988
}
9089

9190
func (o *operation) setEvent() {
@@ -1028,10 +1027,9 @@ func (fd *FD) ConnectEx(ra syscall.Sockaddr) error {
10281027

10291028
func (fd *FD) acceptOne(s syscall.Handle, rawsa []syscall.RawSockaddrAny, o *operation) (string, error) {
10301029
// Submit accept request.
1031-
o.handle = s
10321030
o.rsan = int32(unsafe.Sizeof(rawsa[0]))
10331031
_, err := fd.execIO(o, func(o *operation) error {
1034-
return AcceptFunc(fd.Sysfd, o.handle, (*byte)(unsafe.Pointer(&rawsa[0])), 0, uint32(o.rsan), uint32(o.rsan), &o.qty, &o.o)
1032+
return AcceptFunc(fd.Sysfd, s, (*byte)(unsafe.Pointer(&rawsa[0])), 0, uint32(o.rsan), uint32(o.rsan), &o.qty, &o.o)
10351033
})
10361034
if err != nil {
10371035
CloseFunc(s)

src/internal/poll/sendfile_windows.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ func SendFile(fd *FD, src uintptr, size int64) (written int64, err error, handle
6363
const maxChunkSizePerCall = int64(0x7fffffff - 1)
6464

6565
o := &fd.wop
66-
o.handle = hsrc
6766
for size > 0 {
6867
chunkSize := maxChunkSizePerCall
6968
if chunkSize > size {
@@ -76,7 +75,7 @@ func SendFile(fd *FD, src uintptr, size int64) (written int64, err error, handle
7675

7776
n, err := fd.execIO(o, func(o *operation) error {
7877
o.qty = uint32(chunkSize)
79-
return syscall.TransmitFile(fd.Sysfd, o.handle, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND)
78+
return syscall.TransmitFile(fd.Sysfd, hsrc, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND)
8079
})
8180
if err != nil {
8281
return written, err, written > 0

0 commit comments

Comments
 (0)