summaryrefslogtreecommitdiffstats
path: root/win/tclWinFile.c
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2018-05-25 15:48:50 (GMT)
committersebres <sebres@users.sourceforge.net>2018-05-25 15:48:50 (GMT)
commitf4651a56605698bf681e88594e7a97d8acd50fac (patch)
tree1f96d518844f9efa6a9cf43ac091f3888efced36 /win/tclWinFile.c
parenta0290b85c51fde9541564338e5b7908153f0cc96 (diff)
downloadtcl-f4651a56605698bf681e88594e7a97d8acd50fac.zip
tcl-f4651a56605698bf681e88594e7a97d8acd50fac.tar.gz
tcl-f4651a56605698bf681e88594e7a97d8acd50fac.tar.bz2
avoid dual init of stubs (possible race condition, 8.5th only)
Diffstat (limited to 'win/tclWinFile.c')
-rwxr-xr-xwin/tclWinFile.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 3819960..2395ae1 100755
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -1436,29 +1436,30 @@ TclpGetUserHome(
HINSTANCE handle;
TCL_DECLARE_MUTEX(initializeMutex)
Tcl_MutexLock(&initializeMutex);
-
- handle = LoadLibraryA("netapi32.dll");
- if (handle) {
- netApiBufferFreeProc = (NETAPIBUFFERFREEPROC *)
+ if (!apistubs) {
+ handle = LoadLibraryA("netapi32.dll");
+ if (handle) {
+ netApiBufferFreeProc = (NETAPIBUFFERFREEPROC *)
GetProcAddress(handle, "NetApiBufferFree");
- netGetDCNameProc = (NETGETDCNAMEPROC *)
+ netGetDCNameProc = (NETGETDCNAMEPROC *)
GetProcAddress(handle, "NetGetDCName");
- netUserGetInfoProc = (NETUSERGETINFOPROC *)
+ netUserGetInfoProc = (NETUSERGETINFOPROC *)
GetProcAddress(handle, "NetUserGetInfo");
- Tcl_CreateExitHandler(TclpUnloadFile, handle);
- }
- handle = LoadLibraryA("userenv.dll");
- if (handle) {
- getProfilesDirectoryProc = (GETPROFILESDIRECTORYPROC *)
+ Tcl_CreateExitHandler(TclpUnloadFile, handle);
+ }
+ handle = LoadLibraryA("userenv.dll");
+ if (handle) {
+ getProfilesDirectoryProc = (GETPROFILESDIRECTORYPROC *)
GetProcAddress(handle, "GetProfilesDirectoryW");
- Tcl_CreateExitHandler(TclpUnloadFile, handle);
- }
-
- apistubs = -1;
- if ( (netUserGetInfoProc != NULL) && (netGetDCNameProc != NULL)
- && (netApiBufferFreeProc != NULL) && (getProfilesDirectoryProc != NULL)
- ) {
- apistubs = 1;
+ Tcl_CreateExitHandler(TclpUnloadFile, handle);
+ }
+
+ apistubs = -1;
+ if ( (netUserGetInfoProc != NULL) && (netGetDCNameProc != NULL)
+ && (netApiBufferFreeProc != NULL) && (getProfilesDirectoryProc != NULL)
+ ) {
+ apistubs = 1;
+ }
}
Tcl_MutexUnlock(&initializeMutex);
}