24 #include <drizzled/signal_handler.h>
25 #include <drizzled/drizzled.h>
26 #include <drizzled/session.h>
27 #include <drizzled/session/cache.h>
28 #include <drizzled/internal/my_sys.h>
29 #include <drizzled/probes.h>
30 #include <drizzled/plugin.h>
31 #include <drizzled/plugin/scheduler.h>
32 #include <drizzled/current_session.h>
33 #include <drizzled/util/backtrace.h>
34 #include <drizzled/statistics_variables.h>
35 #include <drizzled/system_variables.h>
37 #define DRIZZLE_UNIX_SOCKET_PATH "/tmp/mysql.socket"
39 using namespace drizzled;
40 namespace fs= boost::filesystem;
42 static uint32_t killed_threads;
43 static bool segfaulted=
false;
54 void drizzled_sigint_handler(
int sig){
58 if (fs::exists(DRIZZLE_UNIX_SOCKET_PATH))
60 fs::remove(DRIZZLE_UNIX_SOCKET_PATH);
62 sa.sa_handler=SIG_DFL;
63 sigaction(SIGINT, &sa, NULL);
64 pthread_kill(pthread_self(),SIGINT);
70 void drizzled_print_signal_warning(
int sig)
72 if (global_system_variables.log_warnings)
73 errmsg_printf(error::WARN, _(
"Got signal %d from thread %"PRIu32),
74 sig, global_thread_id);
75 #ifndef HAVE_BSD_SIGNALS
80 sa.sa_handler= drizzled_print_signal_warning;
83 sigaction(sig, &sa, NULL);
90 void drizzled_end_thread_signal(
int )
92 Session *session= current_session;
95 Session::shared_ptr session_ptr(session::Cache::find(session->
getSessionId()));
102 session_ptr->scheduler->killSessionNow(session_ptr);
103 DRIZZLE_CONNECTION_DONE(session_ptr->getSessionId());
107 static void write_core(
int sig)
109 signal(sig, SIG_DFL);
116 extern void __gcov_flush(
void);
119 pthread_kill(pthread_self(), sig);
120 #if defined(P_MYID) && !defined(SCO)
122 sigsend(P_PID,P_MYID,sig);
126 void drizzled_handle_segfault(
int sig)
139 fprintf(stderr, _(
"Fatal signal %d while backtracing\n"), sig);
145 curr_time= time(NULL);
146 if(curr_time == (time_t)-1)
148 fprintf(stderr, _(
"Fatal: time() call failed\n"));
152 localtime_r(&curr_time, &tm);
154 fprintf(stderr,_(
"%02d%02d%02d %2d:%02d:%02d - drizzled got signal %d;\n"
155 "This could be because you hit a bug. It is also possible that "
156 "this binary\n or one of the libraries it was linked against is "
157 "corrupt, improperly built,\n or misconfigured. This error can "
158 "also be caused by malfunctioning hardware.\n"),
159 tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday,
160 tm.tm_hour, tm.tm_min, tm.tm_sec,
162 fprintf(stderr, _(
"We will try our best to scrape up some info that "
163 "will hopefully help diagnose\n"
164 "the problem, but since we have already crashed, "
165 "something is definitely wrong\nand this may fail.\n\n"));
166 fprintf(stderr,
"read_buffer_size=%ld\n", (
long) global_system_variables.read_buff_size);
167 fprintf(stderr,
"max_used_connections=%"PRIu64
"\n", current_global_counters.max_used_connections);
168 fprintf(stderr,
"connection_count=%u\n", uint32_t(connection_count));
169 fprintf(stderr, _(
"It is possible that drizzled could use up to \n"
170 "(read_buffer_size + sort_buffer_size)*thread_count\n"
172 "Hope that's ok; if not, decrease some variables in the "