From: Jason A. Donenfeld Date: Fri, 9 Apr 2021 00:17:59 +0000 (-0600) Subject: conn: windows: compare head and tail properly X-Git-Tag: 0.0.20210424~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75526d60714ce2e2e967830b42422788fb1b7498;p=thirdparty%2Fwireguard-go.git conn: windows: compare head and tail properly By not comparing these with the modulo, the ring became nearly never full, resulting in completion queue buffers filling up prematurely. Reported-by: Joshua Sjoding Signed-off-by: Jason A. Donenfeld --- diff --git a/conn/bind_windows.go b/conn/bind_windows.go index 6cabee1..a25c7aa 100644 --- a/conn/bind_windows.go +++ b/conn/bind_windows.go @@ -47,7 +47,7 @@ func (rb *ringBuffer) Push() *ringPacket { } ret := (*ringPacket)(unsafe.Pointer(rb.packets + (uintptr(rb.tail%packetsPerRing) * unsafe.Sizeof(ringPacket{})))) rb.tail += 1 - if rb.tail == rb.head { + if rb.tail%packetsPerRing == rb.head%packetsPerRing { rb.isFull = true } return ret