From: Wouter Wijngaards Date: Wed, 18 Jun 2008 08:16:04 +0000 (+0000) Subject: testbound works on XP. X-Git-Tag: release-1.0.1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7be0e5b8146a0567f5c6a2706112a30b1816b1b9;p=thirdparty%2Funbound.git testbound works on XP. ioctlsocket nicer error message. git-svn-id: file:///svn/unbound/trunk@1126 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index bbab8f2eb..6701995e8 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,9 @@ +18 June 2008: Wouter + - open testbound replay files in binary mode, because fseek/ftell + do not work in ascii-mode on windows. The b does nothing on unix. + unittest and testbound tests work on windows (xp too). + - ioctlsocket prints nicer error message. + 17 June 2008: Wouter - outgoing num fds 32 by default on windows ; it supports less fds for waiting on than unixes. diff --git a/libunbound/libunbound.c b/libunbound/libunbound.c index f027e6e3c..8cb146304 100644 --- a/libunbound/libunbound.c +++ b/libunbound/libunbound.c @@ -64,8 +64,20 @@ ub_ctx_create() { struct ub_ctx* ctx; unsigned int seed; +#ifdef USE_WINSOCK + int r; + WSADATA wsa_data; +#endif + log_init(NULL, 0, NULL); /* logs to stderr */ log_ident_set("libunbound"); +#ifdef USE_WINSOCK + if((r = WSAStartup(MAKEWORD(2,2), &wsa_data)) != 0) { + log_err("could not init winsock. WSAStartup: %s", + wsa_strerror(r)); + return NULL; + } +#endif verbosity = 0; /* errors only */ checklock_start(); ctx = (struct ub_ctx*)calloc(1, sizeof(*ctx)); @@ -231,6 +243,9 @@ ub_ctx_delete(struct ub_ctx* ctx) alloc_clear(&ctx->superalloc); traverse_postorder(&ctx->queries, delq, NULL); free(ctx); +#ifdef USE_WINSOCK + WSACleanup(); +#endif } int diff --git a/testcode/replay.c b/testcode/replay.c index 4d5da932c..1de5b132e 100644 --- a/testcode/replay.c +++ b/testcode/replay.c @@ -235,7 +235,6 @@ replay_moment_read(char* remain, FILE* in, const char* name, int* lineno, remain++; if(strlen(remain) > 0) /* remove \n */ remain[strlen(remain)-1] = 0; - printf("remain '%s'\n", remain); if(!extstrtoaddr(remain, &mom->addr, &mom->addrlen)) { log_err("line %d: could not parse ADDRESS: %s", *lineno, remain); diff --git a/testcode/testbound.c b/testcode/testbound.c index fcb4ab8cd..58330f1d8 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -177,7 +177,7 @@ setup_playback(const char* filename, char* configfile, int lineno = 0; if(filename) { - FILE *in = fopen(filename, "r"); + FILE *in = fopen(filename, "rb"); if(!in) { perror(filename); exit(1); diff --git a/util/net_help.c b/util/net_help.c index 21ffe5d77..76cb6b619 100644 --- a/util/net_help.c +++ b/util/net_help.c @@ -96,7 +96,8 @@ fd_set_nonblock(int s) #elif defined(HAVE_IOCTLSOCKET) unsigned long on = 1; if(ioctlsocket(s, FIONBIO, &on) != 0) { - log_err("can't ioctlsocket FIONBIO on: %d", WSAGetLastError()); + log_err("can't ioctlsocket FIONBIO on: %s", + wsa_strerror(WSAGetLastError())); } #endif return 1; @@ -119,7 +120,8 @@ fd_set_block(int s) #elif defined(HAVE_IOCTLSOCKET) unsigned long off = 0; if(ioctlsocket(s, FIONBIO, &off) != 0) { - log_err("can't ioctlsocket FIONBIO off: %d", WSAGetLastError()); + log_err("can't ioctlsocket FIONBIO off: %s", + wsa_strerror(WSAGetLastError())); } #endif return 1;