ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/branches/newio/src/restart.c
Revision: 2418
Committed: Mon Jul 22 22:26:59 2013 UTC (13 years ago) by michael
Content type: text/x-csrc
File size: 2380 byte(s)
Log Message:
- ioengine changes as of 23JUL13

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #include "restart.h"
28     #include "ircd.h"
29 michael 2418 #include "ircd_signal.h"
30 adx 30 #include "irc_string.h"
31 michael 2414 #include "s_bsd.h"
32 adx 30 #include "send.h"
33 michael 1309 #include "log.h"
34 adx 30 #include "client.h" /* for UMODE_ALL */
35     #include "memory.h"
36 michael 1630 #include "conf_db.h"
37 adx 30
38     void
39     restart(const char *mesg)
40     {
41     static int was_here = 0; /* redundant due to restarting flag below */
42    
43 michael 1011 if (was_here++)
44 adx 30 abort();
45    
46 michael 1011 server_die(mesg, 1);
47 adx 30 }
48    
49     void
50     server_die(const char *mesg, int rboot)
51     {
52     char buffer[IRCD_BUFSIZE];
53     dlink_node *ptr = NULL;
54     struct Client *target_p = NULL;
55 michael 588 static int was_here = 0;
56 adx 30
57 michael 588 if (rboot && was_here++)
58     abort();
59    
60 adx 30 if (EmptyString(mesg))
61     snprintf(buffer, sizeof(buffer), "Server %s",
62     rboot ? "Restarting" : "Terminating");
63     else
64     snprintf(buffer, sizeof(buffer), "Server %s: %s",
65     rboot ? "Restarting" : "Terminating", mesg);
66    
67     DLINK_FOREACH(ptr, local_client_list.head)
68     {
69     target_p = ptr->data;
70    
71     sendto_one(target_p, ":%s NOTICE %s :%s",
72     me.name, target_p->name, buffer);
73     }
74    
75     DLINK_FOREACH(ptr, serv_list.head)
76     {
77     target_p = ptr->data;
78    
79     sendto_one(target_p, ":%s ERROR :%s", me.name, buffer);
80     }
81    
82 michael 1341 ilog(LOG_TYPE_IRCD, "%s", buffer);
83 adx 30
84 michael 1631 save_all_databases(NULL);
85    
86 michael 2414 flush_connections(NULL);
87     close_connections(1);
88 adx 30
89     unlink(pidFileName);
90    
91     if (rboot)
92     {
93 michael 2418 reap_children();
94 adx 30 execv(SPATH, myargv);
95     exit(1);
96     }
97     else
98 michael 2415 running = 0;
99 adx 30 }

Properties

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