mingw: ensure sockets are initialized before calling gethostname
If the Windows sockets subsystem has not been initialized yet then an attempt to get the hostname returns an error and prints a warning to the console. This solves this issue for msysGit as seen with 'git fetch'. Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pat Thoyts committed
Oct 15, 2011 at 15:05 UTC
13d24b018f348401cceca45da5c0dd6d17411268
2 files changed
+10
compat/mingw.c
+7
@@ -1321,6 +1321,13 @@ static void ensure_socket_initialization(void)
1321
initialized = 1;
1322
}
1323
1324
+#undef gethostname
1325
+int mingw_gethostname(char *name, int namelen)
1326
+{
1327
+ ensure_socket_initialization();
1328
+ return gethostname(name, namelen);
1329
+}
1330
+
1331
#undef gethostbyname
1332
struct hostent *mingw_gethostbyname(const char *host)
1333
{
compat/mingw.h
+3
@@ -190,6 +190,9 @@ char *mingw_getcwd(char *pointer, int len);
190
char *mingw_getenv(const char *name);
191
#define getenv mingw_getenv
192
193
+int mingw_gethostname(char *host, int namelen);
194
+#define gethostname mingw_gethostname
195
+
196
struct hostent *mingw_gethostbyname(const char *host);
197
#define gethostbyname mingw_gethostbyname
198