1
/* Copyright (C) 2006 MySQL AB
2
Copyright (C) 2011 Brian Aker
3
Copyright (C) 2006 MySQL AB
3
5
This program is free software; you can redistribute it and/or modify
4
6
it under the terms of the GNU General Public License as published by
13
15
along with this program; if not, write to the Free Software
14
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
17
19
#include <drizzled/gettext.h>
18
20
#include <drizzled/error.h>
19
21
#include <drizzled/unireg.h>
20
22
#include <drizzled/plugin/storage_engine.h>
21
#include <drizzled/cursor.h> /* for refresh_version */
22
#include "drizzled/pthread_globals.h"
23
#include "drizzled/internal/my_pthread.h"
24
#include "drizzled/internal/my_sys.h"
25
#include "drizzled/plugin/daemon.h"
26
#include "drizzled/signal_handler.h"
28
#include "drizzled/session/cache.h"
30
#include "drizzled/drizzled.h"
23
#include <drizzled/pthread_globals.h>
24
#include <drizzled/internal/my_pthread.h>
25
#include <drizzled/internal/my_sys.h>
26
#include <drizzled/plugin/daemon.h>
27
#include <drizzled/signal_handler.h>
28
#include <drizzled/session.h>
29
#include <drizzled/session/cache.h>
30
#include <drizzled/debug.h>
31
#include <drizzled/drizzled.h>
32
#include <drizzled/open_tables_state.h>
32
34
#include <boost/thread/thread.hpp>
33
35
#include <boost/filesystem.hpp>
47
49
extern boost::filesystem::path pid_file;
48
50
/* Prototypes -> all of these should be factored out into a propper shutdown */
49
51
extern void close_connections(void);
50
extern std::bitset<12> test_flags;
53
54
using namespace drizzled;
76
77
if (sig != 0) // 0 is not a valid signal number
77
78
ignore_signal(sig); /* purify inspected */
78
79
if (sig == SIGTERM || sig == 0)
79
errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_NORMAL_SHUTDOWN)),internal::my_progname);
80
errmsg_printf(error::INFO, _(ER(ER_NORMAL_SHUTDOWN)),internal::my_progname);
81
errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_GOT_SIGNAL)),internal::my_progname,sig);
82
errmsg_printf(error::ERROR, _(ER(ER_GOT_SIGNAL)),internal::my_progname,sig);
82
84
close_connections();
119
121
internal::my_thread_init(); // Init new thread
120
boost::this_thread::at_thread_exit(&internal::my_thread_end);
121
122
signal_thread_in_use= true;
123
if ((test_flags.test(TEST_SIGINT)))
124
if ((drizzled::getDebug().test(drizzled::debug::ALLOW_SIGINT)))
125
126
(void) sigemptyset(&set); // Setup up SIGINT for debug
126
127
(void) sigaddset(&set,SIGINT); // For debugging
127
(void) pthread_sigmask(SIG_UNBLOCK,&set,NULL);
128
(void) pthread_sigmask(SIG_UNBLOCK, &set, NULL);
129
130
(void) sigemptyset(&set); // Setup up SIGINT for debug
130
131
#ifndef IGNORE_SIGHUP_SIGQUIT
161
162
(Asked MontyW over the phone about this.) -Brian
164
session::Cache::singleton().mutex().lock();
165
session::Cache::singleton().mutex().unlock();
165
session::Cache::mutex().lock();
166
session::Cache::mutex().unlock();
166
167
COND_thread_count.notify_all();
168
169
if (pthread_sigmask(SIG_BLOCK, &set, NULL))
227
228
drizzled::plugin::Daemon("Signal Handler")
229
230
// @todo fix spurious wakeup issue
230
boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
231
boost::mutex::scoped_lock scopedLock(session::Cache::mutex());
231
232
thread= boost::thread(signal_hand);
232
233
signal_thread= thread.native_handle();
233
234
COND_thread_count.wait(scopedLock);
292
289
"Default Signal Handler",
293
290
PLUGIN_LICENSE_GPL,
294
291
init, /* Plugin Init */
295
system_variables, /* system variables */
296
293
NULL /* config options */
298
295
DRIZZLE_DECLARE_PLUGIN_END;