~skinny.moey/drizzle/innodb-replication

« back to all changes in this revision

Viewing changes to plugin/signal_handler/signal_handler.cc

  • Committer: Brian Aker
  • Date: 2010-11-08 22:35:57 UTC
  • mfrom: (1802.1.114 trunk)
  • Revision ID: brian@tangent.org-20101108223557-w3xzwp9hjjtjhtc1
MergeĀ inĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "drizzled/drizzled.h"
29
29
 
30
30
#include <boost/thread/thread.hpp>
 
31
#include <boost/filesystem.hpp>
31
32
 
32
33
#include <sys/stat.h>
33
34
#include <fcntl.h>
41
42
extern int cleanup_done;
42
43
extern bool volatile abort_loop;
43
44
extern bool volatile shutdown_in_progress;
44
 
extern char pidfile_name[FN_REFLEN];
 
45
extern boost::filesystem::path pid_file;
45
46
/* Prototypes -> all of these should be factored out into a propper shutdown */
46
47
extern void close_connections(void);
47
48
extern std::bitset<12> test_flags;
62
63
    or stop, we just want to kill the server.
63
64
*/
64
65
 
65
 
static void kill_server(void *sig_ptr)
 
66
static void kill_server(int sig)
66
67
{
67
 
  int sig=(int) (long) sig_ptr;                 // This is passed a int
68
68
  // if there is a signal during the kill in progress, ignore the other
69
69
  if (kill_in_progress)                         // Safety
70
70
    return;
88
88
  int file;
89
89
  char buff[1024];
90
90
 
91
 
  assert(pidfile_name[0]);
92
 
  if ((file = open(pidfile_name, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) > 0)
 
91
  if ((file = open(pid_file.file_string().c_str(), O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) > 0)
93
92
  {
94
93
    int length;
95
94
 
103
102
    (void)close(file); /* We can ignore the error, since we are going to error anyway at this point */
104
103
  }
105
104
  memset(buff, 0, sizeof(buff));
106
 
  snprintf(buff, sizeof(buff)-1, "Can't start server: can't create PID file (%s)", pidfile_name);
 
105
  snprintf(buff, sizeof(buff)-1, "Can't start server: can't create PID file (%s)", pid_file.file_string().c_str());
107
106
  sql_perror(buff);
108
107
  exit(1);
109
108
}
197
196
      if (!abort_loop)
198
197
      {
199
198
        abort_loop=1;                           // mark abort for threads
200
 
        kill_server((void*) sig);       // MIT THREAD has a alarm thread
 
199
        kill_server(sig);               // MIT THREAD has a alarm thread
201
200
      }
202
201
      break;
203
202
    case SIGHUP: