ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/src/restart.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 2189 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.h")


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 "restart.h"
27     #include "common.h"
28     #include "ircd.h"
29     #include "send.h"
30     #include "client.h" /* for UMODE_ALL */
31    
32     void
33     restart(const char *mesg)
34     {
35     static int was_here = 0; /* redundant due to restarting flag below */
36    
37     if (was_here)
38     abort();
39     was_here = 1;
40    
41     server_die(mesg, YES);
42     }
43    
44     void
45     server_die(const char *mesg, int rboot)
46     {
47     char buffer[IRCD_BUFSIZE];
48     dlink_node *ptr = NULL;
49     struct Client *target_p = NULL;
50    
51     if (EmptyString(mesg))
52     snprintf(buffer, sizeof(buffer), "Server %s",
53     rboot ? "Restarting" : "Terminating");
54     else
55     snprintf(buffer, sizeof(buffer), "Server %s: %s",
56     rboot ? "Restarting" : "Terminating", mesg);
57    
58     DLINK_FOREACH(ptr, local_client_list.head)
59     {
60     target_p = ptr->data;
61    
62     sendto_one(target_p, ":%s NOTICE %s :%s",
63     me.name, target_p->name, buffer);
64     }
65    
66     DLINK_FOREACH(ptr, serv_list.head)
67     {
68     target_p = ptr->data;
69    
70     sendto_one(target_p, ":%s ERROR :%s", me.name, buffer);
71     }
72    
73     ilog(L_NOTICE, buffer);
74    
75     send_queued_all();
76     close_fds(NULL);
77    
78     unlink(pidFileName);
79    
80     if (rboot)
81     {
82     execv(SPATH, myargv);
83     exit(1);
84     }
85     else
86     exit(0);
87     }
88 adx 62
89     void
90     ircd_outofmemory(void)
91     {
92     restart("Out of memory");
93     }

Properties

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