summaryrefslogtreecommitdiff
path: root/lib/lwres/context.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lwres/context.c')
-rw-r--r--lib/lwres/context.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/lwres/context.c b/lib/lwres/context.c
index b606b9d21a1f0..213b43748de60 100644
--- a/lib/lwres/context.c
+++ b/lib/lwres/context.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: context.c,v 1.41.2.1.2.4 2004/09/17 05:50:31 marka Exp $ */
+/* $Id: context.c,v 1.41.2.1.2.8 2007/08/28 07:19:18 tbox Exp $ */
#include <config.h>
@@ -128,6 +128,9 @@ lwres_context_destroy(lwres_context_t **contextp) {
*contextp = NULL;
if (ctx->sock != -1) {
+#ifdef WIN32
+ DestroySockets();
+#endif
(void)close(ctx->sock);
ctx->sock = -1;
}
@@ -231,19 +234,34 @@ context_connect(lwres_context_t *ctx) {
} else
return (LWRES_R_IOERROR);
+#ifdef WIN32
+ InitSockets();
+#endif
s = socket(domain, SOCK_DGRAM, IPPROTO_UDP);
- if (s < 0)
+ if (s < 0) {
+#ifdef WIN32
+ DestroySockets();
+#endif
return (LWRES_R_IOERROR);
+ }
ret = connect(s, sa, salen);
if (ret != 0) {
+#ifdef WIN32
+ DestroySockets();
+#endif
(void)close(s);
return (LWRES_R_IOERROR);
}
MAKE_NONBLOCKING(s, ret);
- if (ret < 0)
+ if (ret < 0) {
+#ifdef WIN32
+ DestroySockets();
+#endif
+ (void)close(s);
return (LWRES_R_IOERROR);
+ }
ctx->sock = s;