example: account for buffer being drained too slowly

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-11-04 14:46:06 +01:00
parent 5d1efa847f
commit e2ffd0b3b3

View File

@ -247,10 +247,13 @@ SendPackets(_Inout_ DWORD_PTR SessionPtr)
while (!HaveQuit)
{
BYTE *Packet = WintunAllocateSendPacket(Session, 28);
if (!Packet)
if (Packet)
{
MakeICMP(Packet);
WintunSendPacket(Session, Packet);
}
else if (GetLastError() != ERROR_BUFFER_OVERFLOW)
return LogLastError(L"Packet write failed");
MakeICMP(Packet);
WintunSendPacket(Session, Packet);
switch (WaitForSingleObject(QuitEvent, 1000 /* 1 second */))
{