00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdinc.h"
00026 #include "tools.h"
00027 #include "restart.h"
00028 #include "common.h"
00029 #include "fdlist.h"
00030 #include "ircd.h"
00031 #include "irc_string.h"
00032 #include "send.h"
00033 #include "s_log.h"
00034 #include "client.h"
00035 #include "memory.h"
00036
00037 void
00038 restart(const char *mesg)
00039 {
00040 static int was_here = 0;
00041
00042 if (was_here)
00043 abort();
00044 was_here = 1;
00045
00046 server_die(mesg, YES);
00047 }
00048
00049 void
00050 server_die(const char *mesg, int rboot)
00051 {
00052 char buffer[IRCD_BUFSIZE];
00053 dlink_node *ptr = NULL;
00054 struct Client *target_p = NULL;
00055 static int was_here = 0;
00056
00057 if (rboot && was_here++)
00058 abort();
00059
00060 if (EmptyString(mesg))
00061 snprintf(buffer, sizeof(buffer), "Server %s",
00062 rboot ? "Restarting" : "Terminating");
00063 else
00064 snprintf(buffer, sizeof(buffer), "Server %s: %s",
00065 rboot ? "Restarting" : "Terminating", mesg);
00066
00067 DLINK_FOREACH(ptr, local_client_list.head)
00068 {
00069 target_p = ptr->data;
00070
00071 sendto_one(target_p, ":%s NOTICE %s :%s",
00072 me.name, target_p->name, buffer);
00073 }
00074
00075 DLINK_FOREACH(ptr, serv_list.head)
00076 {
00077 target_p = ptr->data;
00078
00079 sendto_one(target_p, ":%s ERROR :%s", me.name, buffer);
00080 }
00081
00082 ilog(L_NOTICE, buffer);
00083
00084 send_queued_all();
00085 close_fds(NULL);
00086
00087 unlink(pidFileName);
00088
00089 if (rboot)
00090 {
00091 execv(SPATH, myargv);
00092 exit(1);
00093 }
00094 else
00095 exit(0);
00096 }