~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/signal_handler/signal_handler.cc

  • Committer: Lee Bieber
  • Date: 2010-11-14 23:15:42 UTC
  • mfrom: (1929.1.42 warning-stack-frame)
  • Revision ID: kalebral@gmail.com-20101114231542-fnnu6ydd2p17n582
Merge Monty - fix bug 672372: some functions use > 32k stack

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
   Copyright (C) 2011 Brian Aker
3
 
   Copyright (C) 2006 MySQL AB
 
1
/* Copyright (C) 2006 MySQL AB
4
2
 
5
3
   This program is free software; you can redistribute it and/or modify
6
4
   it under the terms of the GNU General Public License as published by
16
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
17
15
 
18
16
#include "config.h"
19
 
 
20
17
#include <drizzled/gettext.h>
21
18
#include <drizzled/error.h>
22
19
#include <drizzled/unireg.h>
23
20
#include <drizzled/plugin/storage_engine.h>
 
21
#include <drizzled/cursor.h> /* for refresh_version */
24
22
#include "drizzled/pthread_globals.h"
25
23
#include "drizzled/internal/my_pthread.h"
26
24
#include "drizzled/internal/my_sys.h"
27
25
#include "drizzled/plugin/daemon.h"
28
26
#include "drizzled/signal_handler.h"
29
27
 
30
 
#include <drizzled/session.h>
31
 
#include <drizzled/session/cache.h>
32
 
 
33
 
#include "drizzled/debug.h"
34
 
 
35
28
#include "drizzled/drizzled.h"
36
29
 
37
 
#include <drizzled/refresh_version.h>
38
 
 
39
30
#include <boost/thread/thread.hpp>
40
31
#include <boost/filesystem.hpp>
41
32
 
54
45
extern boost::filesystem::path pid_file;
55
46
/* Prototypes -> all of these should be factored out into a propper shutdown */
56
47
extern void close_connections(void);
 
48
extern std::bitset<12> test_flags;
57
49
}
58
50
 
59
51
using namespace drizzled;
60
52
 
61
53
 
62
54
 
63
 
 
64
55
/**
65
56
  Force server down. Kill all connections and threads and exit.
66
57
 
82
73
  if (sig != 0) // 0 is not a valid signal number
83
74
    ignore_signal(sig);                    /* purify inspected */
84
75
  if (sig == SIGTERM || sig == 0)
85
 
    errmsg_printf(error::INFO, _(ER(ER_NORMAL_SHUTDOWN)),internal::my_progname);
 
76
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_NORMAL_SHUTDOWN)),internal::my_progname);
86
77
  else
87
 
    errmsg_printf(error::ERROR, _(ER(ER_GOT_SIGNAL)),internal::my_progname,sig);
88
 
 
 
78
    errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_GOT_SIGNAL)),internal::my_progname,sig);
89
79
  close_connections();
90
80
  clean_up(1);
91
81
}
127
117
  boost::this_thread::at_thread_exit(&internal::my_thread_end);
128
118
  signal_thread_in_use= true;
129
119
 
130
 
  if ((drizzled::getDebug().test(drizzled::debug::ALLOW_SIGINT)))
 
120
  if ((test_flags.test(TEST_SIGINT)))
131
121
  {
132
122
    (void) sigemptyset(&set);                   // Setup up SIGINT for debug
133
123
    (void) sigaddset(&set,SIGINT);              // For debugging
134
 
    (void) pthread_sigmask(SIG_UNBLOCK, &set, NULL);
 
124
    (void) pthread_sigmask(SIG_UNBLOCK,&set,NULL);
135
125
  }
136
126
  (void) sigemptyset(&set);                     // Setup up SIGINT for debug
137
127
#ifndef IGNORE_SIGHUP_SIGQUIT
168
158
    (Asked MontyW over the phone about this.) -Brian
169
159
 
170
160
  */
171
 
  session::Cache::singleton().mutex().lock();
172
 
  session::Cache::singleton().mutex().unlock();
 
161
  LOCK_thread_count.lock();
 
162
  LOCK_thread_count.unlock();
173
163
  COND_thread_count.notify_all();
174
164
 
175
165
  if (pthread_sigmask(SIG_BLOCK, &set, NULL))
234
224
    drizzled::plugin::Daemon("Signal Handler")
235
225
  {
236
226
    // @todo fix spurious wakeup issue
237
 
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
 
227
    boost::mutex::scoped_lock scopedLock(LOCK_thread_count);
238
228
    thread= boost::thread(signal_hand);
239
229
    signal_thread= thread.native_handle();
240
230
    COND_thread_count.wait(scopedLock);
286
276
}
287
277
 
288
278
 
 
279
static drizzle_sys_var* system_variables[]= {
 
280
  NULL
 
281
};
 
282
 
289
283
DRIZZLE_DECLARE_PLUGIN
290
284
{
291
285
  DRIZZLE_VERSION_ID,
295
289
  "Default Signal Handler",
296
290
  PLUGIN_LICENSE_GPL,
297
291
  init, /* Plugin Init */
298
 
  NULL,   /* depends */
 
292
  system_variables,   /* system variables */
299
293
  NULL    /* config options */
300
294
}
301
295
DRIZZLE_DECLARE_PLUGIN_END;