Hi Magne,
On 2/28/11 10:30 AM, Magne Mahre wrote:
> #At file:///export/home/tmp/x/mysql-5.5-11765237/ based on
> revid:tor.didriksen@stripped
>
> 3357 Magne Mahre 2011-02-28
> Bug#11765237 - 58179: CANNOT START MYSQLD WITH APP VERIFIER
> Bug#11763065 - 55730: KILL_SERVER() CALLS SETEVENT ON A NULL
> HANDLE, SMEM_EVENT_CONNECT_REQUEST
>
> Application Verifier is a Microsoft tool used for
> detecting certain classes of programming errors.
> In particular, MS Windows OS resource usage is
> monitored for wrong usage (handles, thread local
> storage, critical sections, ...)
>
> In MySQL 5.5.x, an error was introduced where an
> object on thread local storage was used before the
> TLS and the object was created.
>
> The fix has been to move the mysys initialization
> to an earlier stage in the boot process when built for
> Windows. For non-win builds, the init already happens
> early.
>
> Some un-tangling of calls to my_init(), my_basic_init()
> and my_thread_global_init() was done. There is no
> longer a need to do init in steps, so the full my_init()
> is called instead of my_init_basic().
>
> In addition, Bug#11763065 was fixed. The event handle
> 'smem_event_connect_request' is only created if
> 'opt_enable_shared_memory' is set. When killing the
> server, an event was flagged on the handle
> unconditionally. Added a test, so it will only be
> flagged if created.
Looks good, thanks for working on this. Some minor comments below.
[...]
>
> === modified file 'mysys/my_thr_init.c'
> --- a/mysys/my_thr_init.c 2011-01-12 20:36:39 +0000
> +++ b/mysys/my_thr_init.c 2011-02-28 13:30:26 +0000
> @@ -1,4 +1,4 @@
> -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
> +/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. All rights reserved.
>
> This program is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> @@ -69,74 +69,16 @@ static uint get_thread_lib(void);
> /** True if @c my_thread_basic_global_init() has been called. */
> static my_bool my_thread_basic_global_init_done= 0;
Since my_thread_basic_global_init() no longer exists, please update the
comment and rename my_thread_basic_global_init_done to
my_thread_global_init_done.
>
> @@ -181,7 +138,49 @@ void my_thread_basic_global_reinit(void)
>
> my_bool my_thread_global_init(void)
> {
> - if (my_thread_basic_global_init())
> + int pth_ret;
> +
> + if (my_thread_basic_global_init_done)
> + return 0;
> + my_thread_basic_global_init_done= 1;
> +
> +#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
> + /*
> + Set mutex type to "fast" a.k.a "adaptive"
> +
> + In this case the thread may steal the mutex from some other thread
> + that is waiting for the same mutex. This will save us some
> + context switches but may cause a thread to 'starve forever' while
> + waiting for the mutex (not likely if the code within the mutex is
> + short).
> + */
> + pthread_mutexattr_init(&my_fast_mutexattr);
> + pthread_mutexattr_settype(&my_fast_mutexattr,
> + PTHREAD_MUTEX_ADAPTIVE_NP);
> +#endif
> +
> +#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
> + /*
> + Set mutex type to "errorcheck"
> + */
> + pthread_mutexattr_init(&my_errorcheck_mutexattr);
> + pthread_mutexattr_settype(&my_errorcheck_mutexattr,
> + PTHREAD_MUTEX_ERRORCHECK);
> +#endif
> +
> + if ((pth_ret= pthread_key_create(&THR_KEY_mysys, NULL)) != 0)
> + {
> + fprintf(stderr, "Can't initialize threads: error %d\n", pth_ret);
> + return 1;
> + }
> +
> + mysql_mutex_init(key_THR_LOCK_malloc,&THR_LOCK_malloc, MY_MUTEX_INIT_FAST);
> + mysql_mutex_init(key_THR_LOCK_open,&THR_LOCK_open, MY_MUTEX_INIT_FAST);
> + mysql_mutex_init(key_THR_LOCK_charset,&THR_LOCK_charset, MY_MUTEX_INIT_FAST);
> + mysql_mutex_init(key_THR_LOCK_threads,&THR_LOCK_threads, MY_MUTEX_INIT_FAST);
> +
> +
Remove the extra new line.
> + if (my_thread_init())
This makes the my_thread_init at the end of this function needless.
Regards,
Davi