X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fmingw%2Fdevice.c;h=441c52477ee6dd13a5f3480382c8c04bd84aea96;hp=56203d44939b789efb4c3b5f1f4b2a0d9faac4ff;hb=67498fb1b55960bcc2ccead2e6341de4167413af;hpb=d5e4226a37ff101cc9328ab6b1f791257cb23c57 diff --git a/src/mingw/device.c b/src/mingw/device.c index 56203d44..441c5247 100644 --- a/src/mingw/device.c +++ b/src/mingw/device.c @@ -49,6 +49,7 @@ static DWORD WINAPI tapreader(void *bla) { DWORD len; OVERLAPPED overlapped; vpn_packet_t packet; + int errors; logger(LOG_DEBUG, "Tap reader running"); @@ -71,13 +72,22 @@ static DWORD WINAPI tapreader(void *bla) { } else { logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); - return -1; + errors++; + if(errors >= 10) { + EnterCriticalSection(&mutex); + running = false; + LeaveCriticalSection(&mutex); + } + usleep(1000000); + continue; } } - EnterCriticalSection(&mutex); + errors = 0; packet.len = len; packet.priority = 0; + + EnterCriticalSection(&mutex); route(myself, &packet); LeaveCriticalSection(&mutex); }