~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/signal_handler/signal_handler.cc

  • Committer: Andrew Hutchings
  • Date: 2010-09-26 08:33:47 UTC
  • mto: (1795.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1796.
  • Revision ID: andrew@linuxjedi.co.uk-20100926083347-fzsc9e7w0j4u7bj1
Disable boost:po allow_guessing which was making some wrong assumptions

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "drizzled/plugin/daemon.h"
26
26
#include "drizzled/signal_handler.h"
27
27
 
28
 
#include "drizzled/session/cache.h"
29
 
 
30
28
#include "drizzled/drizzled.h"
31
29
 
32
30
#include <boost/thread/thread.hpp>
33
 
#include <boost/filesystem.hpp>
34
31
 
35
32
#include <sys/stat.h>
36
33
#include <fcntl.h>
44
41
extern int cleanup_done;
45
42
extern bool volatile abort_loop;
46
43
extern bool volatile shutdown_in_progress;
47
 
extern boost::filesystem::path pid_file;
 
44
extern char pidfile_name[FN_REFLEN];
48
45
/* Prototypes -> all of these should be factored out into a propper shutdown */
49
46
extern void close_connections(void);
50
47
extern std::bitset<12> test_flags;
54
51
 
55
52
 
56
53
 
57
 
 
58
54
/**
59
55
  Force server down. Kill all connections and threads and exit.
60
56
 
66
62
    or stop, we just want to kill the server.
67
63
*/
68
64
 
69
 
static void kill_server(int sig)
 
65
static void kill_server(void *sig_ptr)
70
66
{
 
67
  int sig=(int) (long) sig_ptr;                 // This is passed a int
71
68
  // if there is a signal during the kill in progress, ignore the other
72
69
  if (kill_in_progress)                         // Safety
73
70
    return;
91
88
  int file;
92
89
  char buff[1024];
93
90
 
94
 
  if ((file = open(pid_file.file_string().c_str(), O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) > 0)
 
91
  assert(pidfile_name[0]);
 
92
  if ((file = open(pidfile_name, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) > 0)
95
93
  {
96
94
    int length;
97
95
 
104
102
    }
105
103
    (void)close(file); /* We can ignore the error, since we are going to error anyway at this point */
106
104
  }
107
 
  memset(buff, 0, sizeof(buff));
108
 
  snprintf(buff, sizeof(buff)-1, "Can't start server: can't create PID file (%s)", pid_file.file_string().c_str());
 
105
  snprintf(buff, 1024, "Can't start server: can't create PID file (%s)", pidfile_name);
109
106
  sql_perror(buff);
110
107
  exit(1);
111
108
}
161
158
    (Asked MontyW over the phone about this.) -Brian
162
159
 
163
160
  */
164
 
  session::Cache::singleton().mutex().lock();
165
 
  session::Cache::singleton().mutex().unlock();
 
161
  LOCK_thread_count.lock();
 
162
  LOCK_thread_count.unlock();
166
163
  COND_thread_count.notify_all();
167
164
 
168
165
  if (pthread_sigmask(SIG_BLOCK, &set, NULL))
199
196
      if (!abort_loop)
200
197
      {
201
198
        abort_loop=1;                           // mark abort for threads
202
 
        kill_server(sig);               // MIT THREAD has a alarm thread
 
199
        kill_server((void*) sig);       // MIT THREAD has a alarm thread
203
200
      }
204
201
      break;
205
202
    case SIGHUP:
227
224
    drizzled::plugin::Daemon("Signal Handler")
228
225
  {
229
226
    // @todo fix spurious wakeup issue
230
 
    boost::mutex::scoped_lock scopedLock(session::Cache::singleton().mutex());
 
227
    boost::mutex::scoped_lock scopedLock(LOCK_thread_count);
231
228
    thread= boost::thread(signal_hand);
232
229
    signal_thread= thread.native_handle();
233
230
    COND_thread_count.wait(scopedLock);