From: Jeffrey Altman Date: Sun, 17 Dec 2006 01:21:52 +0000 (+0000) Subject: rx-fix-lock-init-20061216 X-Git-Tag: BP-openafs-windows-kdfs-ifs~917 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=5b56a0b8ebbdfffa46b90d45b06253c3c6fade15;p=packages%2Fo%2Fopenafs.git 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. --- 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 e4d7a7eda..669451437 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -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 + diff --git a/src/rx/rx_user.c b/src/rx/rx_user.c index 424a8e5ce..1ddd778b6 100644 --- a/src/rx/rx_user.c +++ b/src/rx/rx_user.c @@ -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--)