api: skip notifying driver when there are no receive packets yet

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-11-18 17:35:42 +01:00 committed by Jason A. Donenfeld
parent 6af568d1e0
commit ecf70261da

View File

@ -293,8 +293,10 @@ WintunSendPacket(_In_ TUN_SESSION *Session, _In_ const BYTE *Packet)
TUN_RING_WRAP(Session->Receive.TailRelease + AlignedPacketSize, Session->Capacity);
Session->Receive.PacketsToRelease--;
}
WriteULongRelease(&Session->Descriptor.Receive.Ring->Tail, Session->Receive.TailRelease);
if (ReadAcquire(&Session->Descriptor.Receive.Ring->Alertable))
SetEvent(Session->Descriptor.Receive.TailMoved);
if (Session->Descriptor.Receive.Ring->Tail != Session->Receive.TailRelease) {
WriteULongRelease(&Session->Descriptor.Receive.Ring->Tail, Session->Receive.TailRelease);
if (ReadAcquire(&Session->Descriptor.Receive.Ring->Alertable))
SetEvent(Session->Descriptor.Receive.TailMoved);
}
LeaveCriticalSection(&Session->Receive.Lock);
}