+2005-04-22 Jeffrey Altman <jaltman@mit.edu>
+
+ * win_glue.c: Remove calls to WSAStartup/WSACleanup because
+ they can result in deadlocks when called from DllMain().
+
2005-04-13 Ken Raeburn <raeburn@mit.edu>
* win_glue.c (NEED_SOCKETS): Don't define.
+2005-04-22 Jeffrey Altman <jaltman@mit.edu>
+
+ * init_os_ctx.c: use krb5_init_ctx and krb5_free_ctx
+ to initialize and cleanup the winsock stack. WSAStartup/
+ WSACleanup are only supposed to increment/decrement a
+ reference counter if they have been previously called
+ within the application.
+
2005-04-13 Ken Raeburn <raeburn@mit.edu>
* accessor.c (NEED_SOCKETS): Don't define.
#endif
#if defined(_WIN32)
+#include <winsock.h>
static krb5_error_code
get_from_windows_dir(
{
krb5_os_context os_ctx;
krb5_error_code retval = 0;
+#ifdef _WIN32
+ WORD wVersionRequested;
+ WSADATA wsaData;
+#endif /* _WIN32 */
os_ctx = ctx->os_context;
os_ctx->magic = KV5M_OS_CONTEXT;
os_ctx->os_flags = 0;
os_ctx->default_ccname = 0;
- krb5_cc_set_default_name(ctx, NULL);
-
retval = os_init_paths(ctx);
-
/*
* If there's an error in the profile, return an error. Just
* ignoring the error is a Bad Thing (tm).
*/
-
+
+ if (!retval) {
+ krb5_cc_set_default_name(ctx, NULL);
+
+#ifdef _WIN32
+ /* We initialize winsock to version 1.1 but
+ * we do not care if we succeed or fail.
+ */
+ wVersionRequested = 0x0101;
+ WSAStartup (wVersionRequested, &wsaData);
+#endif /* _WIN32 */
+ }
return retval;
}
profile_release(ctx->profile);
ctx->profile = 0;
}
+
+#ifdef _WIN32
+ WSACleanup();
+#endif /* _WIN32 */
}
-/*
- * WinSock support.
- *
- * Do the WinSock initialization call, keeping all the hair here.
- *
- * This routine is called by SOCKET_INITIALIZE in include/c-windows.h.
- * The code is pretty much copied from winsock.txt from winsock-1.1,
- * available from:
- * ftp://sunsite.unc.edu/pub/micro/pc-stuff/ms-windows/winsock/winsock-1.1
- *
- * Note: WSAStartup and WSACleanup is called here (and only here).
- * This assumes that under Windows, we only use this library via the
- * DLL. Note that calls to WSAStartup and WSACleanup must be in
- * matched pairs. If there is a missing WSACleanup call when a
- * program exits, under Lan Workplace, the name resolver will stop
- * working.
- */
-
#ifdef KRB4
#include <kerberosIV/krb.h>
#endif
#include "k5-int.h"
-#ifndef NEED_WINSOCK
-#if defined(KRB4) || defined(KRB5) || defined(GSSAPI)
-#define NEED_WINSOCK 1
-#endif
-#endif
-
#ifdef KRB4
#include <kerberosIV/krb_err.h>
#include <kerberosIV/kadm_err.h>
static int
control(int mode)
{
-#ifdef NEED_WINSOCK
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
-#endif
-
switch(mode) {
case DLL_STARTUP:
-#ifdef NEED_WINSOCK
- wVersionRequested = 0x0101; /* We need version 1.1 */
- if ((err = WSAStartup (wVersionRequested, &wsaData)))
- return err;
- if (wVersionRequested != wsaData.wVersion) {
- /* DLL couldn't support our version of the spec */
- WSACleanup ();
- return -104; /* FIXME -- better error? */
- }
-#endif
break;
case DLL_SHUTDOWN:
#ifdef KRB5
krb5_stdcc_shutdown();
-#endif
-#ifdef NEED_WINSOCK
- WSACleanup ();
#endif
break;