]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-rx-fix-lock-init-20061216
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 17 Dec 2006 01:23:30 +0000 (01:23 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 17 Dec 2006 01:23:30 +0000 (01:23 +0000)
When rxBind was added it made an assumption that rx_GetIFInfo could be
called before rx_InitXYZ.  This is true on non-Windows platforms, but
on Windows rxGetIFInfo relies on an initialized mutex.  This patch adds
a DllMain for Windows in order to initialize the mutex object upon DLL
load.

(cherry picked from commit 5b56a0b8ebbdfffa46b90d45b06253c3c6fade15)

src/libafsrpc/afsrpc.def
src/rx/rx.c
src/rx/rx_user.c

index 4d965b9d86a11dc942990d2065bce175d2d8b714..32edbcd15c5a7c50127af7c6568a612b043b562c 100644 (file)
@@ -219,3 +219,4 @@ EXPORTS
        rx_InitHost                             @224
        rx_NewServiceHost                       @225
         osi_AssertFailU                                @226
+       DllMain                                 @227
index 6891a2c92ad7a161eab7cb7664f8db9370fea0b6..609255408722f40a6ff5adf4b424ed88a4ffcf6d 100644 (file)
@@ -7753,3 +7753,31 @@ rx_RxStatUserOk(struct rx_call *call)
        return 0;
     return rxi_rxstat_userok(call);
 }
+
+#ifdef AFS_NT40_ENV
+/*
+ * DllMain() -- Entry-point function called by the DllMainCRTStartup()
+ *     function in the MSVC runtime DLL (msvcrt.dll).
+ *
+ *     Note: the system serializes calls to this function.
+ */
+BOOL WINAPI
+DllMain(HINSTANCE dllInstHandle,       /* instance handle for this DLL module */
+       DWORD reason,                   /* reason function is being called */
+       LPVOID reserved)                /* reserved for future use */
+{
+    switch (reason) {
+    case DLL_PROCESS_ATTACH:
+       /* library is being attached to a process */
+       INIT_PTHREAD_LOCKS;
+       return TRUE;
+
+    case DLL_PROCESS_DETACH:
+       return TRUE;
+
+    default:
+       return FALSE;
+    }
+}
+#endif
+
index c88c32f39a6e77c965084b4cdad75ed41b92fcb4..9d15032d5154c808c6ba9374a0945f9e76b7cd97 100644 (file)
@@ -299,10 +299,14 @@ rx_getAllAddr(afs_int32 * buffer, int maxSize)
     /* The IP address list can change so we must query for it */
     rx_GetIFInfo();
 
+#ifndef AFS_NT40_ENV
     /* we don't want to use the loopback adapter which is first */
-    /* this is a bad bad hack */
+    /* this is a bad bad hack.
+     * and doesn't hold true on Windows.
+     */
     if ( rxi_numNetAddrs > 1 )
         offset = 1;
+#endif /* AFS_NT40_ENV */
 
     for (count = 0; offset < rxi_numNetAddrs && maxSize > 0;
         count++, offset++, maxSize--)