From 1705962cf976a001bb9929146e5690a957ed630e Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Sun, 9 Sep 2018 14:21:25 +1000 Subject: [PATCH] internal/poll: handle zero-byte write in FD.WriteTo Zero-byte write was fixed by CL 132781, that was submitted 3 days ago. But I just submitted CL 129137, and the CL broken zero-byte write functionality without me noticing. CL 129137 was based on old commit (older than 3 days ago), and try-bots did not discover the breakage. Fix zero-byte write again. Fixes windows build. Change-Id: Ib403b25fd25cb881963f25706eecca92b924aaa1 Reviewed-on: https://go-review.googlesource.com/134275 Run-TryBot: Alex Brainman TryBot-Result: Gobot Gobot Reviewed-by: Alex Brainman --- src/internal/poll/fd_windows.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index b5aaafda02..19d9a12dad 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -811,6 +811,17 @@ func (fd *FD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error) { } defer fd.writeUnlock() + if len(buf) == 0 { + // handle zero-byte payload + o := &fd.wop + o.InitBuf(buf) + o.sa = sa + n, err := wsrv.ExecIO(o, func(o *operation) error { + return syscall.WSASendto(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil) + }) + return n, err + } + ntotal := 0 for len(buf) > 0 { b := buf -- 2.50.0