mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
2199. [bug] win32: don't call WSAStartup() while loading dlls.
[RT #16911]
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: socket.c,v 1.49 2007/03/06 01:50:48 marka Exp $ */
|
||||
/* $Id: socket.c,v 1.50 2007/06/18 03:36:50 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
|
||||
@@ -77,6 +77,7 @@
|
||||
#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>
|
||||
@@ -911,10 +912,11 @@ socket_close(isc_socket_t *sock) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
@@ -923,11 +925,26 @@ BOOL InitSockets() {
|
||||
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
|
||||
@@ -2782,6 +2799,8 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
|
||||
if (manager == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
InitSockets();
|
||||
|
||||
manager->magic = SOCKET_MANAGER_MAGIC;
|
||||
manager->mctx = NULL;
|
||||
ISC_LIST_INIT(manager->socklist);
|
||||
|
Reference in New Issue
Block a user