From: Jeffrey Altman Date: Sun, 17 Dec 2006 01:23:30 +0000 (+0000) Subject: DEVEL15-rx-fix-lock-init-20061216 X-Git-Tag: openafs-devel-1_5_13~26 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=2b1d85b592d731a52248dd934cf52bf736a6c09f;p=packages%2Fo%2Fopenafs.git DEVEL15-rx-fix-lock-init-20061216 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) --- diff --git a/src/libafsrpc/afsrpc.def b/src/libafsrpc/afsrpc.def index 4d965b9d8..32edbcd15 100644 --- a/src/libafsrpc/afsrpc.def +++ b/src/libafsrpc/afsrpc.def @@ -219,3 +219,4 @@ EXPORTS rx_InitHost @224 rx_NewServiceHost @225 osi_AssertFailU @226 + DllMain @227 diff --git a/src/rx/rx.c b/src/rx/rx.c index 6891a2c92..609255408 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -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 + diff --git a/src/rx/rx_user.c b/src/rx/rx_user.c index c88c32f39..9d15032d5 100644 --- a/src/rx/rx_user.c +++ b/src/rx/rx_user.c @@ -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--)