X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fmingw%2Fdevice.c;h=0e748f85e9d965d5d5528b2129c5c610cff0d705;hb=06a4a8c153407b690a3ce3f0e7fdaa8568ccb1a3;hp=9744196a3cd93c65d2138b34deada4d540af6861;hpb=41583d5dcfc1277b1a203478de4cce2cd0cda1b1;p=tinc diff --git a/src/mingw/device.c b/src/mingw/device.c index 9744196a..0e748f85 100644 --- a/src/mingw/device.c +++ b/src/mingw/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Windows tap driver in a MinGW environment Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2013 Guus Sliepen + 2002-2014 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,6 +47,7 @@ static DWORD WINAPI tapreader(void *bla) { DWORD len; OVERLAPPED overlapped; vpn_packet_t packet; + int errors; logger(DEBUG_ALWAYS, LOG_DEBUG, "Tap reader running"); @@ -69,13 +70,22 @@ static DWORD WINAPI tapreader(void *bla) { } else { logger(DEBUG_ALWAYS, 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); event_flush_output(); LeaveCriticalSection(&mutex);