From f0e11cd2c55a83662049646d2f6ffba3ac697989 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 27 Aug 2013 21:19:50 +0200 Subject: [PATCH] Call WSAStartup() in main(). The tinc utility defered calling WSAStartup() until it tried to connect to a running tinc daemon. However, socket functions are now also used for other things (like joining another VPN using an invitation). Now we just unconditionally call WSAStartup() early in main(). --- src/tincctl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/tincctl.c b/src/tincctl.c index 956771f7..6e7965c2 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -68,10 +68,6 @@ bool netnamegiven = false; char *scriptinterpreter = NULL; char *scriptextension = ""; -#ifdef HAVE_MINGW -static struct WSAData wsa_state; -#endif - static struct option const long_options[] = { {"config", required_argument, NULL, 'c'}, {"net", required_argument, NULL, 'n'}, @@ -682,14 +678,6 @@ bool connect_tincd(bool verbose) { fclose(f); -#ifdef HAVE_MINGW - if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { - if(verbose) - fprintf(stderr, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError())); - return false; - } -#endif - #ifndef HAVE_MINGW struct sockaddr_un sa; sa.sun_family = AF_UNIX; @@ -2366,6 +2354,15 @@ int main(int argc, char *argv[]) { return 0; } +#ifdef HAVE_MINGW + static struct WSAData wsa_state; + + if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { + fprintf(stderr, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError())); + return false; + } +#endif + srand(time(NULL)); crypto_init(); -- 2.20.1