Skip to content

Commit 75526d6

Browse files
committed
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 <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent fbf9750 commit 75526d6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

conn/bind_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (rb *ringBuffer) Push() *ringPacket {
4747
}
4848
ret := (*ringPacket)(unsafe.Pointer(rb.packets + (uintptr(rb.tail%packetsPerRing) * unsafe.Sizeof(ringPacket{}))))
4949
rb.tail += 1
50-
if rb.tail == rb.head {
50+
if rb.tail%packetsPerRing == rb.head%packetsPerRing {
5151
rb.isFull = true
5252
}
5353
return ret

0 commit comments

Comments
 (0)