]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
rx-fix-lock-init-20061216
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 17 Dec 2006 01:21:52 +0000 (01:21 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 17 Dec 2006 01:21:52 +0000 (01:21 +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.

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 e4d7a7edaa47f7e2989bc0fd67ba591cc70e765a..6694514375036e1e0b003de2e8c2552548fd47c2 100644 (file)
@@ -7900,3 +7900,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 424a8e5ce522fb21df764ee3f3270a9c2b685f92..1ddd778b688e27eafacfdff25b1376b447d4c746 100644 (file)
@@ -301,10 +301,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--)