ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/restart.c
Revision: 1631
Committed: Thu Nov 1 22:04:01 2012 UTC (12 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 2320 byte(s)
Log Message:
- 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

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 "fdlist.h"
29     #include "ircd.h"
30     #include "irc_string.h"
31     #include "send.h"
32 michael 1309 #include "log.h"
33 adx 30 #include "client.h" /* for UMODE_ALL */
34     #include "memory.h"
35 michael 1630 #include "conf_db.h"
36 adx 30
37     void
38     restart(const char *mesg)
39     {
40     static int was_here = 0; /* redundant due to restarting flag below */
41    
42 michael 1011 if (was_here++)
43 adx 30 abort();
44    
45 michael 1011 server_die(mesg, 1);
46 adx 30 }
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 michael 588 static int was_here = 0;
55 adx 30
56 michael 588 if (rboot && was_here++)
57     abort();
58    
59 adx 30 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 michael 1341 ilog(LOG_TYPE_IRCD, "%s", buffer);
82 adx 30
83 michael 1631 save_all_databases(NULL);
84    
85 adx 30 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