mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 01:05:15 +01:00
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:
parent
fbf97502cf
commit
75526d6071
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user