@@ -1258,11 +1258,12 @@ void kill_mysql(void)
12581258 if (!kill_in_progress)
12591259 {
12601260 pthread_t tmp;
1261+ int error;
12611262 abort_loop=1 ;
1262- if (mysql_thread_create (0 , /* Not instrumented */
1263- &tmp, &connection_attrib, kill_server_thread ,
1264- (void *) 0 ))
1265- sql_print_error (" Can't create thread to kill server" );
1263+ if ((error= mysql_thread_create (0 , /* Not instrumented */
1264+ &tmp, &connection_attrib,
1265+ kill_server_thread, (void *) 0 ) ))
1266+ sql_print_error (" Can't create thread to kill server (errno= %d). " , error );
12661267 }
12671268#endif
12681269 DBUG_VOID_RETURN;
@@ -2728,10 +2729,12 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
27282729#endif
27292730#ifdef USE_ONE_SIGNAL_HAND
27302731 pthread_t tmp;
2731- if (mysql_thread_create (0 , /* Not instrumented */
2732- &tmp, &connection_attrib, kill_server_thread,
2733- (void *) &sig))
2734- sql_print_error (" Can't create thread to kill server" );
2732+ if ((error= mysql_thread_create (0 , /* Not instrumented */
2733+ &tmp, &connection_attrib,
2734+ kill_server_thread,
2735+ (void *) &sig)))
2736+ sql_print_error (" Can't create thread to kill server (errno= %d)" ,
2737+ error);
27352738#else
27362739 kill_server ((void *) sig); // MIT THREAD has a alarm thread
27372740#endif
@@ -4116,9 +4119,12 @@ static void create_shutdown_thread()
41164119#ifdef __WIN__
41174120 hEventShutdown=CreateEvent (0 , FALSE , FALSE , shutdown_event_name);
41184121 pthread_t hThread;
4119- if (mysql_thread_create (key_thread_handle_shutdown,
4120- &hThread, &connection_attrib, handle_shutdown, 0 ))
4121- sql_print_warning (" Can't create thread to handle shutdown requests" );
4122+ int error;
4123+ if ((error= mysql_thread_create (key_thread_handle_shutdown,
4124+ &hThread, &connection_attrib,
4125+ handle_shutdown, 0 )))
4126+ sql_print_warning (" Can't create thread to handle shutdown requests"
4127+ " (errno= %d)" , error);
41224128
41234129 // On "Stop Service" we have to do regular shutdown
41244130 Service.SetShutdownEvent (hEventShutdown);
@@ -4132,6 +4138,7 @@ static void create_shutdown_thread()
41324138static void handle_connections_methods ()
41334139{
41344140 pthread_t hThread;
4141+ int error;
41354142 DBUG_ENTER (" handle_connections_methods" );
41364143 if (hPipe == INVALID_HANDLE_VALUE &&
41374144 (!have_tcpip || opt_disable_networking) &&
@@ -4147,34 +4154,37 @@ static void handle_connections_methods()
41474154 if (hPipe != INVALID_HANDLE_VALUE)
41484155 {
41494156 handler_count++;
4150- if (mysql_thread_create (key_thread_handle_con_namedpipes,
4151- &hThread, &connection_attrib,
4152- handle_connections_namedpipes, 0 ))
4157+ if ((error= mysql_thread_create (key_thread_handle_con_namedpipes,
4158+ &hThread, &connection_attrib,
4159+ handle_connections_namedpipes, 0 ) ))
41534160 {
4154- sql_print_warning (" Can't create thread to handle named pipes" );
4161+ sql_print_warning (" Can't create thread to handle named pipes"
4162+ " (errno= %d)" , error);
41554163 handler_count--;
41564164 }
41574165 }
41584166 if (have_tcpip && !opt_disable_networking)
41594167 {
41604168 handler_count++;
4161- if (mysql_thread_create (key_thread_handle_con_sockets,
4162- &hThread, &connection_attrib,
4163- handle_connections_sockets_thread, 0 ))
4169+ if ((error= mysql_thread_create (key_thread_handle_con_sockets,
4170+ &hThread, &connection_attrib,
4171+ handle_connections_sockets_thread, 0 ) ))
41644172 {
4165- sql_print_warning (" Can't create thread to handle TCP/IP" );
4173+ sql_print_warning (" Can't create thread to handle TCP/IP" ,
4174+ " (errno= %d)" , error);
41664175 handler_count--;
41674176 }
41684177 }
41694178#ifdef HAVE_SMEM
41704179 if (opt_enable_shared_memory)
41714180 {
41724181 handler_count++;
4173- if (mysql_thread_create (key_thread_handle_con_sharedmem,
4174- &hThread, &connection_attrib,
4175- handle_connections_shared_memory, 0 ))
4182+ if ((error= mysql_thread_create (key_thread_handle_con_sharedmem,
4183+ &hThread, &connection_attrib,
4184+ handle_connections_shared_memory, 0 ) ))
41764185 {
4177- sql_print_warning (" Can't create thread to handle shared memory" );
4186+ sql_print_warning (" Can't create thread to handle shared memory" ,
4187+ " (errno= %d)" , error);
41784188 handler_count--;
41794189 }
41804190 }
@@ -4909,11 +4919,14 @@ static void bootstrap(MYSQL_FILE *file)
49094919
49104920 bootstrap_file=file;
49114921#ifndef EMBEDDED_LIBRARY // TODO: Enable this
4912- if (mysql_thread_create (key_thread_bootstrap,
4913- &thd->real_id , &connection_attrib, handle_bootstrap,
4914- (void *) thd))
4922+ int error;
4923+ if ((error= mysql_thread_create (key_thread_bootstrap,
4924+ &thd->real_id , &connection_attrib,
4925+ handle_bootstrap,
4926+ (void *) thd)))
49154927 {
4916- sql_print_warning (" Can't create thread to handle bootstrap" );
4928+ sql_print_warning (" Can't create thread to handle bootstrap (errno= %d)" ,
4929+ error);
49174930 bootstrap_error=-1 ;
49184931 DBUG_VOID_RETURN;
49194932 }
@@ -5012,6 +5025,7 @@ void create_thread_to_handle_connection(THD *thd)
50125025 DBUG_PRINT (" error" ,
50135026 (" Can't create thread to handle request (error %d)" ,
50145027 error));
5028+
50155029 thread_count--;
50165030 thd->killed = THD::KILL_CONNECTION; // Safety
50175031 mysql_mutex_unlock (&LOCK_thread_count);
0 commit comments