412
412
static void usage(void);
413
413
static void clean_up_mutexes(void);
414
static void create_new_thread(Session *session);
415
414
extern "C" void end_thread_signal(int );
416
415
void close_connections(void);
417
416
extern "C" void print_signal_warning(int sig);
772
770
statistic_increment(killed_threads, &LOCK_status);
773
Scheduler &thread_scheduler= get_thread_scheduler();
774
(void)thread_scheduler.end_thread(session, 0);
771
session->scheduler->killSessionNow(session);
776
return; /* purecov: deadcode */
862
859
localtime_r(&curr_time, &tm);
863
Scheduler &thread_scheduler= get_thread_scheduler();
865
861
fprintf(stderr,"%02d%02d%02d %2d:%02d:%02d - drizzled got signal %d;\n"
866
862
"This could be because you hit a bug. It is also possible that "
878
874
(uint32_t) dflt_key_cache->key_cache_mem_size);
879
875
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
880
876
fprintf(stderr, "max_used_connections=%u\n", max_used_connections);
881
fprintf(stderr, "max_threads=%u\n", thread_scheduler.get_max_threads());
882
fprintf(stderr, "thread_count=%u\n", thread_scheduler.count());
883
877
fprintf(stderr, "connection_count=%u\n", uint32_t(connection_count));
884
878
fprintf(stderr, _("It is possible that drizzled could use up to \n"
885
879
"key_buffer_size + (read_buffer_size + "
886
"sort_buffer_size)*max_threads = %"PRIu64" K\n"
880
"sort_buffer_size)*thread_count\n"
887
881
"bytes of memory\n"
888
882
"Hope that's ok; if not, decrease some variables in the "
890
(uint64_t)(((uint32_t) dflt_key_cache->key_cache_mem_size +
891
(global_system_variables.read_buff_size +
892
global_system_variables.sortbuff_size) *
893
thread_scheduler.get_max_threads()) / 1024));
895
885
#ifdef HAVE_STACKTRACE
896
886
Session *session= current_session;
1629
Create new thread to handle incoming connection.
1631
This function will create new thread to handle the incoming
1632
connection. If there are idle cached threads one will be used.
1633
'session' will be pushed into 'threads'.
1635
In single-threaded mode (\#define ONE_THREAD) connection will be
1636
handled inside this function.
1638
@param[in,out] session Thread handle of future thread.
1641
static void create_new_thread(Session *session)
1643
Scheduler &thread_scheduler= get_thread_scheduler();
1647
if (connection_count > max_used_connections)
1648
max_used_connections= connection_count;
1651
The initialization of thread_id is done in create_embedded_session() for
1652
the embedded library.
1653
TODO: refactor this to avoid code duplication there
1655
session->thread_id= session->variables.pseudo_thread_id= thread_id++;
1658
If we error on creation we drop the connection and delete the session.
1660
pthread_mutex_lock(&LOCK_thread_count);
1661
session_list.push_back(session);
1662
pthread_mutex_unlock(&LOCK_thread_count);
1663
if (thread_scheduler.add_connection(session))
1665
char error_message_buff[DRIZZLE_ERRMSG_SIZE];
1667
session->killed= Session::KILL_CONNECTION; // Safety
1669
statistic_increment(aborted_connects, &LOCK_status);
1671
/* Can't use my_error() since store_globals has not been called. */
1672
snprintf(error_message_buff, sizeof(error_message_buff), ER(ER_CANT_CREATE_THREAD), 1); /* TODO replace will better error message */
1673
session->protocol->sendError(ER_CANT_CREATE_THREAD, error_message_buff);
1674
unlink_session(session);
1679
1620
/****************************************************************************
1680
1621
Handle start options
1681
1622
******************************************************************************/