1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* restart.c: Functions to allow the ircd to restart. |
2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
4 |
> |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file restart.c |
23 |
> |
* \brief Functions to allow the ircd to restart. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
32 |
|
#include "irc_string.h" |
33 |
|
#include "send.h" |
34 |
|
#include "log.h" |
35 |
< |
#include "client.h" /* for UMODE_ALL */ |
35 |
> |
#include "client.h" |
36 |
|
#include "memory.h" |
37 |
+ |
#include "conf_db.h" |
38 |
|
|
39 |
|
void |
40 |
< |
restart(const char *mesg) |
40 |
> |
server_die(const char *message, int rboot) |
41 |
|
{ |
42 |
< |
static int was_here = 0; /* redundant due to restarting flag below */ |
40 |
< |
|
41 |
< |
if (was_here++) |
42 |
< |
abort(); |
43 |
< |
|
44 |
< |
server_die(mesg, 1); |
45 |
< |
} |
46 |
< |
|
47 |
< |
void |
48 |
< |
server_die(const char *mesg, int rboot) |
49 |
< |
{ |
50 |
< |
char buffer[IRCD_BUFSIZE]; |
42 |
> |
char buffer[IRCD_BUFSIZE] = ""; |
43 |
|
dlink_node *ptr = NULL; |
52 |
– |
struct Client *target_p = NULL; |
44 |
|
static int was_here = 0; |
45 |
|
|
46 |
|
if (rboot && was_here++) |
47 |
|
abort(); |
48 |
|
|
49 |
< |
if (EmptyString(mesg)) |
49 |
> |
if (EmptyString(message)) |
50 |
|
snprintf(buffer, sizeof(buffer), "Server %s", |
51 |
|
rboot ? "Restarting" : "Terminating"); |
52 |
|
else |
53 |
|
snprintf(buffer, sizeof(buffer), "Server %s: %s", |
54 |
< |
rboot ? "Restarting" : "Terminating", mesg); |
54 |
> |
rboot ? "Restarting" : "Terminating", message); |
55 |
|
|
56 |
|
DLINK_FOREACH(ptr, local_client_list.head) |
57 |
< |
{ |
67 |
< |
target_p = ptr->data; |
57 |
> |
sendto_one_notice(ptr->data, &me, ":%s", buffer); |
58 |
|
|
59 |
< |
sendto_one(target_p, ":%s NOTICE %s :%s", |
70 |
< |
me.name, target_p->name, buffer); |
71 |
< |
} |
72 |
< |
|
73 |
< |
DLINK_FOREACH(ptr, serv_list.head) |
74 |
< |
{ |
75 |
< |
target_p = ptr->data; |
76 |
< |
|
77 |
< |
sendto_one(target_p, ":%s ERROR :%s", me.name, buffer); |
78 |
< |
} |
59 |
> |
sendto_server(NULL, NOCAPS, NOCAPS, ":%s ERROR :%s", me.id, buffer); |
60 |
|
|
61 |
|
ilog(LOG_TYPE_IRCD, "%s", buffer); |
62 |
|
|
63 |
+ |
save_all_databases(NULL); |
64 |
+ |
|
65 |
|
send_queued_all(); |
66 |
|
close_fds(NULL); |
67 |
|
|