Moving some m_die code into ircd_shutdown(reason) function and use it on SIGTERM too
This commit is contained in:
parent
041d54ff4b
commit
fd5af3d072
4 changed files with 32 additions and 33 deletions
|
@ -107,4 +107,6 @@ extern int ssl_ok;
|
|||
extern int zlib_ok;
|
||||
extern int maxconnections;
|
||||
|
||||
void ircd_shutdown(const char *reason);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -74,33 +74,7 @@ mo_die(struct Client *client_p __unused, struct Client *source_p, int parc, cons
|
|||
return 0;
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(ptr, lclient_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
sendto_one_notice(target_p, ":Server Terminating. %s", get_client_name(source_p, HIDE_IP));
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(ptr, serv_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
sendto_one(target_p, "SQUIT %s :Terminated by %s",
|
||||
use_id(target_p),
|
||||
get_client_name(source_p, HIDE_IP));
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX we called flush_connections() here. Read server_reboot()
|
||||
* for an explanation as to what we should do.
|
||||
* -- adrian
|
||||
*/
|
||||
ilog(L_MAIN, "Server terminated by %s", get_oper_name(source_p));
|
||||
|
||||
/* this is a normal exit, tell the os it's ok */
|
||||
unlink(pidFileName);
|
||||
exit(0);
|
||||
/* NOT REACHED */
|
||||
ircd_shutdown(get_client_name(source_p, HIDE_IP));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
28
src/ircd.c
28
src/ircd.c
|
@ -141,6 +141,34 @@ rb_bh *linebuf_heap;
|
|||
|
||||
rb_bh *dnode_heap;
|
||||
|
||||
void
|
||||
ircd_shutdown(const char *reason)
|
||||
{
|
||||
struct Client *target_p;
|
||||
rb_dlink_node *ptr;
|
||||
|
||||
RB_DLINK_FOREACH(ptr, lclient_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
sendto_one(target_p, ":%s NOTICE %s :Server Terminating. %s",
|
||||
me.name, target_p->name, reason);
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(ptr, serv_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
sendto_one(target_p, ":%s ERROR :Terminated by %s",
|
||||
me.name, reason);
|
||||
}
|
||||
|
||||
ilog(L_MAIN, "Server Terminating. %s", reason);
|
||||
|
||||
unlink(pidFileName);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* print_startup - print startup information
|
||||
*/
|
||||
|
|
|
@ -57,12 +57,7 @@ sigchld_handler(int sig)
|
|||
static void
|
||||
sigterm_handler(int sig)
|
||||
{
|
||||
/* XXX we had a flush_connections() here - we should close all the
|
||||
* connections and flush data. read server_reboot() for my explanation.
|
||||
* -- adrian
|
||||
*/
|
||||
ilog(L_MAIN, "Server killed By SIGTERM");
|
||||
exit(-1);
|
||||
ircd_shutdown("Received SIGTERM");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue