From 75526d60714ce2e2e967830b42422788fb1b7498 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 8 Apr 2021 18:17:59 -0600 Subject: 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 --- conn/bind_windows.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'conn') 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 -- cgit v1.2.3-59-g8ed1b