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) while (!HaveQuit)
{ {
BYTE *Packet = WintunAllocateSendPacket(Session, 28); BYTE *Packet = WintunAllocateSendPacket(Session, 28);
if (!Packet) if (Packet)
return LogLastError(L"Packet write failed"); {
MakeICMP(Packet); MakeICMP(Packet);
WintunSendPacket(Session, Packet); WintunSendPacket(Session, Packet);
}
else if (GetLastError() != ERROR_BUFFER_OVERFLOW)
return LogLastError(L"Packet write failed");
switch (WaitForSingleObject(QuitEvent, 1000 /* 1 second */)) switch (WaitForSingleObject(QuitEvent, 1000 /* 1 second */))
{ {