Use a mutex to allow the TAP reader to process packets faster on Windows.

The TAP-Win32 device is not a socket, and select() under Windows only works
with sockets.  Tinc used a separate thread to read from the TAP-Win32 device,
and passed this via a local socket to the main thread which could then select()
from it. We now use a global mutex, which is only unlocked when the main thread
is waiting for select(), to allow the TAP reader thread to process packets
directly.
This commit is contained in:
Guus Sliepen 2009-09-15 22:59:01 +02:00
parent 802a50ffcd
commit b47c17bcde
4 changed files with 25 additions and 117 deletions

View file

@ -115,6 +115,7 @@ static struct option const long_options[] = {
#ifdef HAVE_MINGW
static struct WSAData wsa_state;
CRITICAL_SECTION mutex;
#endif
static void usage(bool status)
@ -568,6 +569,8 @@ int main(int argc, char **argv)
int main2(int argc, char **argv)
{
InitializeCriticalSection(&mutex);
EnterCriticalSection(&mutex);
#endif
if(!detach())