Merge lp:~denisboyun/drizzle/main_cc_change_part2 into lp:drizzle

Proposed by denis
Status: Merged
Merged at revision: 2576
Proposed branch: lp:~denisboyun/drizzle/main_cc_change_part2
Merge into: lp:drizzle
Diff against target: 68 lines (+31/-1)
1 file modified
drizzled/main.cc (+31/-1)
To merge this branch: bzr merge lp:~denisboyun/drizzle/main_cc_change_part2
Reviewer Review Type Date Requested Status
Drizzle Trunk Pending
Review via email: mp+107535@code.launchpad.net

Description of the change

add the function which close mysql socket when the drizzled is take the SIGINT(ctrl-c)signal

To post a comment you must log in.
Revision history for this message
Brian Aker (brianaker) wrote :

How about incorporating it into "plugin/signal_handler/signal_handler.cc ?

Revision history for this message
denis (denisboyun) wrote :

I don't mind, just give me some information "How to do this",because I'd never done this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/main.cc'
2--- drizzled/main.cc 2012-04-20 18:29:45 +0000
3+++ drizzled/main.cc 2012-05-26 21:46:24 +0000
4@@ -72,14 +72,20 @@
5 #include <drizzled/sql_lex.h>
6 #include <drizzled/system_variables.h>
7
8+#define DRIZZLE_UNIX_SOCKET_PATH "/tmp/mysql.socket"
9+
10 using namespace drizzled;
11 using namespace std;
12+namespace fs= boost::filesystem;
13
14 static pthread_t select_thread;
15 static uint32_t thr_kill_signal;
16
17 extern bool opt_daemon;
18
19+void signal_handler(int sig);
20+
21+
22
23 /**
24 All global error messages are sent here where the first one is stored
25@@ -212,9 +218,33 @@
26 }
27 sigprocmask(SIG_SETMASK,&set,NULL);
28 pthread_sigmask(SIG_SETMASK,&set,NULL);
29+
30+ (void)sigemptyset(&set);
31+ sigaddset(&set,SIGTSTP);
32+ sigaddset(&set,SIGINT);
33+ sigprocmask(SIG_UNBLOCK,&set,NULL);
34+ pthread_sigmask(SIG_UNBLOCK,&set,NULL);
35+ sa.sa_handler = signal_handler;
36+ sigaction(SIGINT,&sa,NULL);
37 return;
38 }
39
40+void signal_handler(int sig){
41+ struct sigaction sa;
42+ switch(sig){
43+ case SIGINT:{
44+ if (fs::exists(DRIZZLE_UNIX_SOCKET_PATH))
45+ {
46+ fs::remove(DRIZZLE_UNIX_SOCKET_PATH);
47+ }
48+ sa.sa_handler=SIG_DFL;
49+ sigaction(SIGINT, &sa, NULL);
50+ pthread_kill(pthread_self(),SIGINT);
51+ break;
52+ }
53+ }
54+}
55+
56 static void GoogleProtoErrorThrower(google::protobuf::LogLevel level,
57 const char* ,
58 int, const string& ) throw(const char *)
59@@ -284,9 +314,9 @@
60 init signals & alarm
61 After this we can't quit by a simple unireg_abort
62 */
63+
64 init_signals();
65
66-
67 select_thread= pthread_self();
68 select_thread_in_use=1;
69

Subscribers

People subscribed via source and target branches

to all changes: