+2199. [bug] win32: don't call WSAStartup() while loading dlls.
+ [RT #16911]
+
2198. [bug] win32: RegCloseKey() could be called when
RegOpenKeyEx() failed. [RT #16911]
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: DLLMain.c,v 1.3.2.1 2004/03/09 06:11:43 marka Exp $ */
+/* $Id: DLLMain.c,v 1.3.2.2 2007/06/18 03:30:31 marka Exp $ */
#include <windows.h>
#include <signal.h>
-BOOL InitSockets(void);
-
/*
* Called when we enter the DLL
*/
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: DLLMain.c,v 1.3.2.2 2004/03/09 06:12:16 marka Exp $ */
+/* $Id: DLLMain.c,v 1.3.2.3 2007/06/18 03:30:31 marka Exp $ */
#include <windows.h>
#include <stdio.h>
-BOOL InitSockets(void);
-
/*
* Called when we enter the DLL
*/
* initialization or a call to LoadLibrary.
*/
case DLL_PROCESS_ATTACH:
- if (!InitSockets())
- return (FALSE);
break;
/* The attached process creates a new thread. */
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: interfaceiter.c,v 1.4.2.1 2004/03/09 06:12:18 marka Exp $ */
+/* $Id: interfaceiter.c,v 1.4.2.2 2007/06/18 03:30:31 marka Exp $ */
/*
* Note that this code will need to be revisited to support IPv6 Interfaces.
#include <isc/util.h>
#include "errno2result.h"
+void InitSockets(void);
+
/* Common utility functions */
/*
if (iter == NULL)
return (ISC_R_NOMEMORY);
+ InitSockets();
+
iter->mctx = mctx;
iter->buf = NULL;
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: net.c,v 1.3.2.3 2004/03/09 06:12:18 marka Exp $ */
+/* $Id: net.c,v 1.3.2.4 2007/06/18 03:30:31 marka Exp $ */
#include <config.h>
static isc_result_t ipv4_result = ISC_R_NOTFOUND;
static isc_result_t ipv6_result = ISC_R_NOTFOUND;
+void InitSockets(void);
+
static isc_result_t
try_proto(int domain) {
SOCKET s;
static void
initialize_action(void) {
+ InitSockets();
ipv4_result = try_proto(PF_INET);
#ifdef ISC_PLATFORM_HAVEIPV6
#ifdef WANT_IPV6
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket.c,v 1.5.2.32 2007/02/01 23:55:18 marka Exp $ */
+/* $Id: socket.c,v 1.5.2.33 2007/06/18 03:30:31 marka Exp $ */
/* This code has been rewritten to take advantage of Windows Sockets
* I/O Completion Ports and Events. I/O Completion Ports is ONLY
#include <isc/msgs.h>
#include <isc/mutex.h>
#include <isc/net.h>
+#include <isc/once.h>
#include <isc/os.h>
#include <isc/platform.h>
#include <isc/print.h>
}
}
-/*
- * Initialize socket services
- */
-BOOL InitSockets() {
+static isc_once_t initialise_once = ISC_ONCE_INIT;
+static isc_boolean_t initialised = ISC_FALSE;
+
+static void
+initialise(void) {
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(2, 0);
err = WSAStartup(wVersionRequested, &wsaData);
- if ( err != 0 ) {
- /* Tell the user that we could not find a usable Winsock DLL */
- return(FALSE);
- }
- return(TRUE);
+ if (err != 0) {
+ char strbuf[ISC_STRERRORSIZE];
+ isc__strerror(err, strbuf, sizeof(strbuf));
+ FATAL_ERROR(__FILE__, __LINE__, "WSAStartup() %s: %s",
+ isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
+ ISC_MSG_FAILED, "failed"),
+ strbuf);
+ } else
+ initialised = ISC_TRUE;
+}
+
+/*
+ * Initialize socket services
+ */
+void
+InitSockets(void) {
+ RUNTIME_CHECK(isc_once_do(&initialise_once,
+ initialise) == ISC_R_SUCCESS);
+ if (!initialised)
+ exit(1);
}
int
if (manager == NULL)
return (ISC_R_NOMEMORY);
+ InitSockets();
+
manager->magic = SOCKET_MANAGER_MAGIC;
manager->mctx = NULL;
ISC_LIST_INIT(manager->socklist);
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: DLLMain.c,v 1.3.2.1 2004/03/09 06:12:29 marka Exp $ */
+/* $Id: DLLMain.c,v 1.3.2.2 2007/06/18 03:30:31 marka Exp $ */
#include <windows.h>
#include <signal.h>
-BOOL InitSockets(void);
-
/*
* Called when we enter the DLL
*/
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: DLLMain.c,v 1.3.2.1 2004/03/09 06:12:32 marka Exp $ */
+/* $Id: DLLMain.c,v 1.3.2.2 2007/06/18 03:30:31 marka Exp $ */
#include <windows.h>
#include <signal.h>
-BOOL InitSockets(void);
-
/*
* Called when we enter the DLL
*/
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: context.c,v 1.41.2.4 2004/09/17 05:57:20 marka Exp $ */
+/* $Id: context.c,v 1.41.2.5 2007/06/18 03:30:31 marka Exp $ */
#include <config.h>
*contextp = NULL;
if (ctx->sock != -1) {
+#ifdef WIN32
+ DestroySockets();
+#endif
close(ctx->sock);
ctx->sock = -1;
}
} 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
close(s);
return (LWRES_R_IOERROR);
}
MAKE_NONBLOCKING(s, ret);
- if (ret < 0)
+ if (ret < 0) {
+#ifdef WIN32
+ DestroySockets();
+#endif
return (LWRES_R_IOERROR);
+ }
ctx->sock = s;
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: getipnode.c,v 1.30.2.8 2005/04/28 23:59:13 marka Exp $ */
+/* $Id: getipnode.c,v 1.30.2.9 2007/06/18 03:30:31 marka Exp $ */
#include <config.h>
static int bufsiz = 4095;
int s, cpsize, n;
+#ifdef WIN32
+ InitSockets();
+#endif
/*
* Set to zero. Used as loop terminators below.
*/
}
if (buf != NULL)
free(buf);
+#ifdef WIN32
+ DestroySockets();
+#endif
close(s);
return (0);
+
err_ret:
if (buf != NULL)
free(buf);
if (s != -1)
close(s);
+#ifdef WIN32
+ DestroySockets();
+#endif
return (-1);
#endif
}
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: DLLMain.c,v 1.2.2.1 2004/03/09 06:12:42 marka Exp $ */
+/* $Id: DLLMain.c,v 1.2.2.2 2007/06/18 03:30:31 marka Exp $ */
#include <windows.h>
#include <signal.h>
-BOOL InitSockets(void);
-
/*
* Called when we enter the DLL
*/
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: platform.h,v 1.4.2.1 2004/03/09 06:12:44 marka Exp $ */
+/* $Id: platform.h,v 1.4.2.2 2007/06/18 03:30:31 marka Exp $ */
#ifndef LWRES_PLATFORM_H
#define LWRES_PLATFORM_H 1
#undef close
#define close closesocket
+/*
+ * Internal to liblwres.
+ */
+void InitSockets(void);
+
+void DestroySockets(void);
+
#endif /* LWRES_PLATFORM_H */
# End Source File
# Begin Source File
+SOURCE=.\socket.c
+# End Source File
+# Begin Source File
+
SOURCE=.\version.c
# End Source File
# End Group
-@erase "$(INTDIR)\lwres_grbn.obj"
-@erase "$(INTDIR)\lwres_noop.obj"
-@erase "$(INTDIR)\lwresutil.obj"
+ -@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(INTDIR)\socket.obj"
-@erase "$(INTDIR)\version.obj"
-@erase "$(OUTDIR)\liblwres.exp"
-@erase "$(OUTDIR)\liblwres.lib"
"$(INTDIR)\lwres_grbn.obj" \
"$(INTDIR)\lwres_noop.obj" \
"$(INTDIR)\lwresutil.obj" \
+ "$(INTDIR)\socket.obj" \
"$(INTDIR)\version.obj"
"..\..\..\Build\Release\liblwres.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-@erase "$(INTDIR)\lwres_noop.sbr"
-@erase "$(INTDIR)\lwresutil.obj"
-@erase "$(INTDIR)\lwresutil.sbr"
+ -@erase "$(INTDIR)\socket.obj"
+ -@erase "$(INTDIR)\socket.sbr"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
+ -@erase "$(INTDIR)\socket.obj"
+ -@erase "$(INTDIR)\socket.sbr"
-@erase "$(INTDIR)\version.obj"
-@erase "$(INTDIR)\version.sbr"
-@erase "$(OUTDIR)\liblwres.bsc"
"$(INTDIR)\lwres_grbn.obj" \
"$(INTDIR)\lwres_noop.obj" \
"$(INTDIR)\lwresutil.obj" \
+ "$(INTDIR)\socket.obj" \
"$(INTDIR)\version.obj"
"..\..\..\Build\Debug\liblwres.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(CPP) $(CPP_PROJ) $(SOURCE)
+!ENDIF
+
+SOURCE=.\socket.c
+
+!IF "$(CFG)" == "liblwres - Win32 Release"
+
+
+"$(INTDIR)\socket.obj" : $(SOURCE) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "liblwres - Win32 Debug"
+
+
+"$(INTDIR)\socket.obj" "$(INTDIR)\socket.sbr" : $(SOURCE) "$(INTDIR)"
+
+
!ENDIF
SOURCE=.\version.c