| 1 |
adx |
30 |
/* |
| 2 |
michael |
2916 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
adx |
30 |
* |
| 4 |
michael |
2916 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 5 |
adx |
30 |
* |
| 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 |
| 8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
|
|
* (at your option) any later version. |
| 10 |
|
|
* |
| 11 |
|
|
* This program is distributed in the hope that it will be useful, |
| 12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
|
|
* GNU General Public License for more details. |
| 15 |
|
|
* |
| 16 |
|
|
* You should have received a copy of the GNU General Public License |
| 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 |
|
|
|
| 22 |
michael |
2916 |
/*! \file restart.c |
| 23 |
|
|
* \brief Functions to allow the ircd to restart. |
| 24 |
|
|
* \version $Id$ |
| 25 |
|
|
*/ |
| 26 |
|
|
|
| 27 |
adx |
30 |
#include "stdinc.h" |
| 28 |
michael |
1011 |
#include "list.h" |
| 29 |
adx |
30 |
#include "restart.h" |
| 30 |
|
|
#include "fdlist.h" |
| 31 |
|
|
#include "ircd.h" |
| 32 |
|
|
#include "irc_string.h" |
| 33 |
|
|
#include "send.h" |
| 34 |
michael |
1309 |
#include "log.h" |
| 35 |
michael |
2916 |
#include "client.h" |
| 36 |
adx |
30 |
#include "memory.h" |
| 37 |
michael |
1630 |
#include "conf_db.h" |
| 38 |
adx |
30 |
|
| 39 |
|
|
void |
| 40 |
michael |
3167 |
server_die(const char *message, int rboot) |
| 41 |
adx |
30 |
{ |
| 42 |
michael |
3166 |
char buffer[IRCD_BUFSIZE] = ""; |
| 43 |
adx |
30 |
dlink_node *ptr = NULL; |
| 44 |
michael |
588 |
static int was_here = 0; |
| 45 |
adx |
30 |
|
| 46 |
michael |
588 |
if (rboot && was_here++) |
| 47 |
|
|
abort(); |
| 48 |
|
|
|
| 49 |
michael |
3167 |
if (EmptyString(message)) |
| 50 |
adx |
30 |
snprintf(buffer, sizeof(buffer), "Server %s", |
| 51 |
|
|
rboot ? "Restarting" : "Terminating"); |
| 52 |
|
|
else |
| 53 |
|
|
snprintf(buffer, sizeof(buffer), "Server %s: %s", |
| 54 |
michael |
3167 |
rboot ? "Restarting" : "Terminating", message); |
| 55 |
adx |
30 |
|
| 56 |
|
|
DLINK_FOREACH(ptr, local_client_list.head) |
| 57 |
michael |
3166 |
sendto_one_notice(ptr->data, &me, ":%s", buffer); |
| 58 |
adx |
30 |
|
| 59 |
michael |
3186 |
sendto_server(NULL, NOCAPS, NOCAPS, ":%s ERROR :%s", me.id, buffer); |
| 60 |
adx |
30 |
|
| 61 |
michael |
1341 |
ilog(LOG_TYPE_IRCD, "%s", buffer); |
| 62 |
adx |
30 |
|
| 63 |
michael |
1631 |
save_all_databases(NULL); |
| 64 |
|
|
|
| 65 |
adx |
30 |
send_queued_all(); |
| 66 |
|
|
close_fds(NULL); |
| 67 |
|
|
|
| 68 |
|
|
unlink(pidFileName); |
| 69 |
|
|
|
| 70 |
|
|
if (rboot) |
| 71 |
|
|
{ |
| 72 |
|
|
execv(SPATH, myargv); |
| 73 |
|
|
exit(1); |
| 74 |
|
|
} |
| 75 |
|
|
else |
| 76 |
|
|
exit(0); |
| 77 |
|
|
} |