Commit 6757dc64 authored by Mark Andrews's avatar Mark Andrews Committed by Evan Hunt

[master] fix nsupdate test on windows

4888.	[test]		Initialize sockets correctly in sample-update so
			that nsupdate system test will will run on Windows.
			[RT #47097]
parent ecf6dcc5
4888. [test] Initialize sockets correctly in sample-update so
that nsupdate system test will will run on Windows.
[RT #47097]
4887. [test] Enable the rpzrecurse test to run on Windows.
[RT #47093]
......
......@@ -641,10 +641,10 @@ initialise(void) {
exit(1);
}
/*
* The following APIs do not exist as functions in a library, but we must
* ask winsock for them. They are "extensions" -- but why they cannot be
* actual functions is beyond me. So, ask winsock for the pointers to the
* functions we need.
* The following APIs do not exist as functions in a library, but
* we must ask winsock for them. They are "extensions" -- but why
* they cannot be actual functions is beyond me. So, ask winsock
* for the pointers to the functions we need.
*/
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
INSIST(sock != INVALID_SOCKET);
......
......@@ -83,6 +83,31 @@ usage(void) {
exit(1);
}
#ifdef _WIN32
static void
InitSockets(void) {
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(2, 0);
err = WSAStartup(wVersionRequested, &wsaData);
if (err != 0) {
fprintf(stderr, "WSAStartup() failed: %d\n", err);
exit(1);
}
}
static void
DestroySockets(void) {
WSACleanup();
}
#else
#define InitSockets() ((void)0)
#define DestroySockets() ((void)0)
#endif
static isc_boolean_t
addserver(const char *server, isc_sockaddrlist_t *list,
isc_sockaddr_t *sockaddr)
......@@ -100,10 +125,12 @@ addserver(const char *server, isc_sockaddrlist_t *list,
#ifdef AI_NUMERICSERV
hints.ai_flags |= AI_NUMERICSERV;
#endif
InitSockets();
gaierror = getaddrinfo(server, port, &hints, &res);
if (gaierror != 0) {
fprintf(stderr, "getaddrinfo(%s) failed: %s\n",
server, gai_strerror(gaierror));
DestroySockets();
return (ISC_FALSE);
}
INSIST(res->ai_addrlen <= sizeof(sockaddr->type));
......@@ -112,6 +139,7 @@ addserver(const char *server, isc_sockaddrlist_t *list,
ISC_LINK_INIT(sockaddr, link);
ISC_LIST_APPEND(*list, sockaddr, link);
freeaddrinfo(res);
DestroySockets();
return (ISC_TRUE);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment