X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=compat%2Fmingw.c;h=f9d82ff103cd096ac328d221c8b1b5e7a4e7d330;hb=b7cc9f82594a2d5fe12867c515d86d91ecedad8f;hp=15fe33eaa0f220e94131006bca89effd14d6d058;hpb=1fdffa616119aeb607e211a77688c9bc3883ca87;p=git.git diff --git a/compat/mingw.c b/compat/mingw.c index 15fe33eaa..f9d82ff10 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -903,16 +903,25 @@ char **make_augmented_environ(const char *const *vars) return env; } -/* this is the first function to call into WS_32; initialize it */ -#undef gethostbyname -struct hostent *mingw_gethostbyname(const char *host) +static void ensure_socket_initialization(void) { WSADATA wsa; + static int initialized = 0; + + if (initialized) + return; if (WSAStartup(MAKEWORD(2,2), &wsa)) die("unable to initialize winsock subsystem, error %d", WSAGetLastError()); atexit((void(*)(void)) WSACleanup); + initialized = 1; +} + +#undef gethostbyname +struct hostent *mingw_gethostbyname(const char *host) +{ + ensure_socket_initialization(); return gethostbyname(host); }