mariadb/mysys
Vladislav Vaintroub 8f500c522b Bug#38522: 5 seconds delay when closing application using embedded server
The problem here is that embedded server starts handle_thread manager 
thread  on mysql_library_init() does not stop it on mysql_library_end().
At shutdown, my_thread_global_end() waits for thread count to become 0,
but since we did not stop the thread it will give up after 5 seconds.
             
Solution is to move shutdown for handle_manager thread from kill_server()
(mysqld specific) to clean_up() that is used by both embedded and mysqld.
            
This patch also contains some refactorings - to avoid duplicate code,
start_handle_manager() and stop_handle_manager() functions are introduced.
Unused variables are eliminated. handle_manager does not rely on global
variable abort_loop anymore to stop (abort_loop is not set for embedded).
            
Note: Specifically on Windows and when using DBUG version of libmysqld, 
the complete solution requires removing obsolete code my_thread_init() 
from my_thread_var(). This has a side effect that a DBUG statement 
after my_thread_end() can cause thread counter to be incremented, and 
embedded will hang for some seconds. Or worse, my_thread_init() will 
crash if critical sections have been deleted by the global cleanup 
routine that runs in a different thread. 

This patch also fixes and revert prior changes for Bug#38293 
"Libmysqld crash in mysql_library_init if language file missing".

Root cause of the crash observed in Bug#38293  was bug in my_thread_init() 
described above




client/mysql.cc:
  sql_protocol_typelib is not exported from libmysqld
  (does not make sense either)
  thus excluded from embedded client
dbug/dbug.c:
  revert changes for Bug#38293
include/my_dbug.h:
  revert changes for Bug#38293
libmysql/libmysql.c:
  Removed DBUG_POP call, because when called after my_end(), will access
  THR_key_mysys that is already deleted. The result of pthread_get_specific
  is not predictable in this case and hence DBUG_POP can crash.
libmysqld/examples/CMakeLists.txt:
  Revert changes for Bug#38293.
libmysqld/lib_sql.cc:
  code to start handle manager is factored out into 
  start_handle_manager() function
libmysqld/libmysqld.def:
  Revert changes for Bug #38293
  Remove excessive exports from libmysqld, export what API documents.
mysys/my_thr_init.c:
  Remove windows-DLL-specific workaround for something (old code, no documentation for
  what specifically). The problem is that even after my_thread_end() is finished, 
  DBUG statement can initiate my_thread_init(). This does not happen anywhere else and 
  should not happen on  Windows either.
sql/mysql_priv.h:
  - new functions start_handle_manager() and stop_handle_manager()
  - move manager_thread_in_use  variable to sql_manager.cc and made
  it static
  - remove manager_status, as it is unused
sql/mysqld.cc:
  Code to start/stop handle_manager thread is factored out into start_handle_manager()
2008-12-04 19:41:53 +01:00
..
.cvsignore
array.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
base64.c BUG#28884 - maybe a problem with malloc into base64.c 2008-01-15 16:23:14 +04:00
ChangeLog
charset-def.c Merge maint1.mysql.com:/data/localhome/tsmith/bk/maint/50 2007-06-21 20:55:37 +02:00
charset.c Fix for server bug experienced in Maria (wrong "Truncated incorrect <var_name> 2008-02-18 23:29:39 +01:00
checksum.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
CMakeLists.txt Bug#37003 Tests sporadically crashes with embedded server 2008-06-18 13:17:15 -03:00
default.c Up-merge 5.0.66a-release changes (via 5.0) into 5.1. 2008-07-17 11:45:08 -06:00
default_modify.c Slow query log to file now displays queries with microsecond precission 2007-07-30 11:33:50 +03:00
errors.c Fix for Bug#16902. 2008-06-16 10:05:00 +02:00
hash.c Bug#37958 - test main.plugin crash on Mac OS X when selecting from EXAMPLE engine. 2008-10-01 12:21:15 +02:00
list.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
make-ccc
make-conf.c
Makefile.am Bug#37003 Tests sporadically crashes with embedded server 2008-06-18 13:17:15 -03:00
md5.c Avoid the name conflict between the system-provided "md5.h" and the MySQL one 2007-07-19 14:14:03 +02:00
mf_arr_appstr.c Bug #20748: Configuration files should not be read more than once 2007-11-07 15:23:50 -07:00
mf_brkhant.c
mf_cache.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_dirname.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_fn_ext.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_format.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_getdate.c Slow query log to file now displays queries with microsecond precission 2007-07-30 11:33:50 +03:00
mf_iocache.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
mf_iocache2.c Correct bad merge, and remove version numbers from test case. 2007-08-08 12:21:04 -04:00
mf_keycache.c Bug#37302 (missing DBUG_RETURN macro in function "find_key_block" (5.0 only)) 2008-08-11 15:08:12 -06:00
mf_keycaches.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_loadpath.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_pack.c Merge from 5.0-bugteam local. 2008-08-18 13:11:55 -04:00
mf_path.c Slow query log to file now displays queries with microsecond precission 2007-07-30 11:33:50 +03:00
mf_qsort.c Fix for bug #31207: Test "join_nested" shows different strategy on IA64 2007-10-17 20:08:58 +04:00
mf_qsort2.c
mf_radix.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_same.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_sort.c Merge polly.(none):/home/kaa/src/maint/mysql-5.0-maint 2007-10-18 14:32:43 +04:00
mf_soundex.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_strip.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_tempdir.c Bug#38293 Libmysqld crash in mysql_library_init if language file missing 2008-11-19 13:57:23 +04:00
mf_tempfile.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
mf_unixpath.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mf_util.c
mf_wcomp.c
mf_wfile.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
mulalloc.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_access.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_aes.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_alarm.c
my_alloc.c Bug#38296 (low memory crash with many conditions in a query) 2008-08-11 10:10:00 -06:00
my_append.c Slow query log to file now displays queries with microsecond precission 2007-07-30 11:33:50 +03:00
my_atomic.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_bit.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_bitmap.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_chsize.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_clock.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_compress.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_conio.c Merge magare.gmz:/home/kgeorge/mysql/autopush/B29325-5.0-opt 2007-07-11 12:44:49 +03:00
my_copy.c Slow query log to file now displays queries with microsecond precission 2007-07-30 11:33:50 +03:00
my_crc32.c
my_create.c Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-main 2008-03-13 23:35:52 +02:00
my_delete.c Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-main 2007-12-07 22:27:48 +02:00
my_div.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_dup.c Fixed compiler warnings. 2007-03-22 20:32:07 +02:00
my_error.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_file.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_fopen.c Fixed a lot of compiler warnings and errors detected by Forte C++ on Solaris 2007-08-13 16:11:25 +03:00
my_fstream.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_gethostbyname.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-31 01:32:21 +01:00
my_gethwaddr.c mysys/my_gethwaddr.c 2007-08-09 14:56:57 +02:00
my_getncpus.c Many files: 2006-12-27 02:23:51 +01:00
my_getopt.c Bug#38293 Libmysqld crash in mysql_library_init if language file missing 2008-11-19 13:57:23 +04:00
my_getpagesize.c
my_getsystime.c Reverted wrong patch, fix for Windows 32bit build. 2008-02-26 18:44:04 +02:00
my_getwd.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_handler.c Fixed problem with non-synchronous error lists 2008-03-28 18:45:03 +02:00
my_handler_errors.h Fixed problem with non-synchronous error lists 2008-03-28 18:45:03 +02:00
my_init.c merge fix for 36279 2008-11-10 21:38:45 +01:00
my_largepage.c Backport of my_malloc() changes from 5.1 to make it 64-bit safe on Unix platforms. 2007-08-29 19:20:18 +04:00
my_lib.c Merge polly.(none):/home/kaa/src/maint/mysql-5.0-maint 2007-10-18 14:32:43 +04:00
my_libwrap.c
my_lock.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_lockmem.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_malloc.c Backport of my_malloc() changes from 5.1 to make it 64-bit safe on Unix platforms. 2007-08-29 19:20:18 +04:00
my_memmem.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_messnc.c
my_mkdir.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_mmap.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_net.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_netware.c
my_new.cc
my_once.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_open.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_port.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_pread.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_pthread.c my_pthread.c: 2007-07-30 20:40:49 +02:00
my_quick.c Added casts to avoid compiler warnings and fixed a wrong type. 2007-05-31 17:45:22 +03:00
my_read.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_realloc.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_redel.c Merge mysql.com:/home/svoj/devel/mysql/BUG25521/mysql-5.0-engines 2007-03-29 22:01:51 +05:00
my_rename.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_seek.c Merge mysql.com:/home/svoj/devel/mysql/BUG27141/mysql-5.0-engines 2007-06-05 03:43:11 +05:00
my_sleep.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
my_static.c Bug#35616: memory overrun on 64-bit linux on setting large values for keybuffer-size 2008-08-19 15:56:41 +02:00
my_static.h Bug#35616: memory overrun on 64-bit linux on setting large values for keybuffer-size 2008-08-19 15:56:41 +02:00
my_symlink.c Bug#39102 valgrind build does not compile in realpath, which make DATA/INDEX DIR fail 2008-10-27 19:25:11 +04:00
my_symlink2.c Merge mysql.com:/home/svoj/devel/mysql/BUG32111/mysql-5.0-engines 2007-11-12 15:26:37 +04:00
my_sync.c Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 2007-10-11 18:07:40 +03:00
my_thr_init.c Bug#38522: 5 seconds delay when closing application using embedded server 2008-12-04 19:41:53 +01:00
my_vle.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_wincond.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_windac.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
my_winthread.c Bug#30992 Wrong implementation of pthread_mutex_trylock() 2007-10-03 21:38:32 +02:00
my_write.c Merge polly.(none):/home/kaa/src/maint/mysql-5.0-maint 2007-10-25 08:22:14 +04:00
mysys_priv.h Slow query log to file now displays queries with microsecond precission 2007-07-30 11:33:50 +03:00
ptr_cmp.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
queues.c Fix for server bug experienced in Maria (wrong "Truncated incorrect <var_name> 2008-02-18 23:29:39 +01:00
rijndael.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
safemalloc.c Bug#35616: memory overrun on 64-bit linux on setting large values for keybuffer-size 2008-08-21 06:48:28 +02:00
sha1.c Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
stacktrace.c merge fix from 5.0-bugteam 2008-09-16 15:23:07 +02:00
string.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
test_charset.c Fix doxygen warnings. 2007-08-15 17:43:08 +04:00
test_dir.c Merge mysql.com:/home/kent/bk/main/mysql-5.0 2006-12-23 20:20:40 +01:00
test_fn.c
test_xml.c
testhash.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
thr_alarm.c Avoid compilation problem on AIX. 2008-04-28 13:41:12 -04:00
thr_lock.c Merge Bug#36579 into mysql-5.1-bugteam 2008-08-25 10:57:34 -03:00
thr_mutex.c Bug#38941: fast mutexes in MySQL 5.1 have mutex contention when calling random() 2008-10-15 19:21:00 -03:00
thr_rwlock.c
tree.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
trie.c WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
typelib.c Merged from main 5.1 2007-05-24 19:47:58 +03:00