/[svn]/ircd-hybrid/trunk/src/restart.c
ViewVC logotype

Contents of /ircd-hybrid/trunk/src/restart.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1631 - (show annotations)
Thu Nov 1 22:04:01 2012 UTC (7 years, 9 months ago) by michael
File MIME type: text/x-chdr
File size: 2320 byte(s)
- restart.c: since save_all_databases may generate server traffic and log
  activity, it makes more sense to save the databases _before_ flushing the
  sendqueue/closing file descriptors

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 save_all_databases(NULL);
84
85 send_queued_all();
86 close_fds(NULL);
87
88 unlink(pidFileName);
89
90 if (rboot)
91 {
92 execv(SPATH, myargv);
93 exit(1);
94 }
95 else
96 exit(0);
97 }

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28