ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/restart.c
Revision: 588
Committed: Mon May 8 13:22:59 2006 UTC (19 years, 3 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/src/restart.c
File size: 2298 byte(s)
Log Message:
- m_restart(): don't send restart notices twice to locally connected clients

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     #include "tools.h"
27     #include "restart.h"
28     #include "common.h"
29     #include "fdlist.h"
30     #include "ircd.h"
31     #include "irc_string.h"
32     #include "send.h"
33     #include "s_log.h"
34     #include "client.h" /* for UMODE_ALL */
35     #include "memory.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     was_here = 1;
45    
46     server_die(mesg, YES);
47     }
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     ilog(L_NOTICE, buffer);
83    
84     send_queued_all();
85     close_fds(NULL);
86    
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