From ecf70261da7b42db080df5047685850ab39b58fe Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 18 Nov 2020 17:35:42 +0100 Subject: api: skip notifying driver when there are no receive packets yet Signed-off-by: Simon Rozman --- api/session.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'api/session.c') diff --git a/api/session.c b/api/session.c index c48d5cb..a900a0a 100644 --- a/api/session.c +++ b/api/session.c @@ -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); } -- cgit v1.2.3-59-g8ed1b