#At file:///C:/bzr/mysql-5.0-bugteam/
2666 Vladislav Vaintroub 2008-08-19
his patch fixes
Bug#37226 Explicit call of my_thread_init() on Windows for every new thread.
Bug#33031 app linked to libmysql.lib crash if run as service in vista under
localsystem
Bug#38522 5 seconds delay when closing application using embedded server
There are some problems using DllMain hook functions on Windows that
automatically do global and per-thread initialization for a DLL in MySQL context
1)per-thread initialization(DLL_THREAD_ATTACH)
MySQL internally counts number of active threads that and causes a delay in in
my_end() if not all threads are exited. But,there are threads that can be
started either by Windows internally (often in TCP/IP scenarios) or by user
himself - those threads are not necessarily using libmysql.dll functionality,
but nonetheless the contribute to the count of open threads.
2)process-initialization (DLL_PROCESS_ATTACH)
my_init() calls WSAStartup that itself loads DLLs and can lead to a deadlock in
Windows loader.
Fix is to remove dll initialization code from libmysql.dll in general case. I
still leave an environment variable LIBMYSQL_DLLINIT, which if set to any value
will cause the old behavior (DLL init hooks will be called). This env.variable
exists only to prevent breakage of existing Windows-only applications that
don't do mysql_thread_init() and work ok today. Use of LIBMYSQL_DLLINIT is
discouraged and it will be removed in 6.0
modified:
libmysql/dll.c
=== modified file 'libmysql/dll.c'
--- a/libmysql/dll.c 2004-08-18 17:57:55 +0000
+++ b/libmysql/dll.c 2008-08-19 15:46:14 +0000
@@ -91,7 +91,12 @@ BOOL APIENTRY LibMain(HANDLE hInst,DWORD
int __stdcall DllMain(HANDLE hInst,DWORD ul_reason_being_called,LPVOID lpReserved)
{
- return LibMain(hInst,ul_reason_being_called,lpReserved);
+ static BOOL do_libmain;
+ if (ul_reason_being_called == DLL_PROCESS_ATTACH)
+ do_libmain = (getenv("LIBMYSQL_DLLINIT") != NULL);
+ if (do_libmain)
+ return LibMain(hInst,ul_reason_being_called,lpReserved);
+ return TRUE;
}
#elif defined(WINDOWS)
| Thread |
|---|
| • bzr commit into mysql-5.0 branch (vvaintroub:2666) Bug#33031 Bug#37226Bug#38522 | Vladislav Vaintroub | 19 Aug |