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 <joshua.sjoding@scjalliance.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-04-08 18:17:59 -06:00
parent fbf97502cf
commit 75526d6071

View File

@ -47,7 +47,7 @@ func (rb *ringBuffer) Push() *ringPacket {
} }
ret := (*ringPacket)(unsafe.Pointer(rb.packets + (uintptr(rb.tail%packetsPerRing) * unsafe.Sizeof(ringPacket{})))) ret := (*ringPacket)(unsafe.Pointer(rb.packets + (uintptr(rb.tail%packetsPerRing) * unsafe.Sizeof(ringPacket{}))))
rb.tail += 1 rb.tail += 1
if rb.tail == rb.head { if rb.tail%packetsPerRing == rb.head%packetsPerRing {
rb.isFull = true rb.isFull = true
} }
return ret return ret