ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/restart.c
Revision: 1630
Committed: Thu Nov 1 21:32:25 2012 UTC (11 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 2319 byte(s)
Log Message:
- restart.c: ensure databases get dumped to disk before terminating

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * restart.c: Functions to allow the ircd to restart.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "list.h"
27 #include "restart.h"
28 #include "fdlist.h"
29 #include "ircd.h"
30 #include "irc_string.h"
31 #include "send.h"
32 #include "log.h"
33 #include "client.h" /* for UMODE_ALL */
34 #include "memory.h"
35 #include "conf_db.h"
36
37 void
38 restart(const char *mesg)
39 {
40 static int was_here = 0; /* redundant due to restarting flag below */
41
42 if (was_here++)
43 abort();
44
45 server_die(mesg, 1);
46 }
47
48 void
49 server_die(const char *mesg, int rboot)
50 {
51 char buffer[IRCD_BUFSIZE];
52 dlink_node *ptr = NULL;
53 struct Client *target_p = NULL;
54 static int was_here = 0;
55
56 if (rboot && was_here++)
57 abort();
58
59 if (EmptyString(mesg))
60 snprintf(buffer, sizeof(buffer), "Server %s",
61 rboot ? "Restarting" : "Terminating");
62 else
63 snprintf(buffer, sizeof(buffer), "Server %s: %s",
64 rboot ? "Restarting" : "Terminating", mesg);
65
66 DLINK_FOREACH(ptr, local_client_list.head)
67 {
68 target_p = ptr->data;
69
70 sendto_one(target_p, ":%s NOTICE %s :%s",
71 me.name, target_p->name, buffer);
72 }
73
74 DLINK_FOREACH(ptr, serv_list.head)
75 {
76 target_p = ptr->data;
77
78 sendto_one(target_p, ":%s ERROR :%s", me.name, buffer);
79 }
80
81 ilog(LOG_TYPE_IRCD, "%s", buffer);
82
83 send_queued_all();
84 close_fds(NULL);
85
86 save_all_databases(NULL);
87 unlink(pidFileName);
88
89 if (rboot)
90 {
91 execv(SPATH, myargv);
92 exit(1);
93 }
94 else
95 exit(0);
96 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision