diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-05-09 13:14:32 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-05-09 13:14:32 +0000 |
commit | 3fdab8ea4af40635c0f950be4c9edbc56f1a9053 (patch) | |
tree | f8ae5e537a3ec2f8df9026d34fe7c95e80d34c6d | |
parent | 02203e5243b18b9044320ecf291c3948cc80b150 (diff) |
Added support for /RESTART (currently has a bug, do not use)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@800 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/InspIRCd.layout | 80 | ||||
-rw-r--r-- | src/channels.cpp | 1 | ||||
-rw-r--r-- | src/commands.cpp | 45 | ||||
-rw-r--r-- | src/inspircd.cpp | 26 | ||||
-rw-r--r-- | src/modules.cpp | 1 | ||||
-rw-r--r-- | src/xline.cpp | 1 |
6 files changed, 99 insertions, 55 deletions
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index 031b101b5..6cfb8dd38 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -1,5 +1,5 @@ [Editors] -Focused=-1 +Focused=43 Order=2,4,6,3,7,25,5,24,39,42,43,-1,1,46,0,49 [Editor_0] @@ -14,16 +14,16 @@ LeftChar=1 Open=1 Top=0 CursorCol=1 -CursorRow=1 -TopLine=1 +CursorRow=99 +TopLine=73 LeftChar=1 [Editor_2] Open=1 Top=0 -CursorCol=18 -CursorRow=354 -TopLine=110 +CursorCol=21 +CursorRow=489 +TopLine=437 LeftChar=1 [Editor_3] @@ -37,9 +37,9 @@ LeftChar=1 [Editor_4] Open=1 Top=0 -CursorCol=21 -CursorRow=441 -TopLine=407 +CursorCol=12 +CursorRow=78 +TopLine=78 LeftChar=1 [Editor_5] @@ -71,7 +71,7 @@ Open=1 Top=0 CursorCol=50 CursorRow=31 -TopLine=7 +TopLine=1 LeftChar=1 [Editor_9] @@ -79,15 +79,15 @@ Open=1 Top=0 CursorCol=17 CursorRow=65 -TopLine=26 +TopLine=1 LeftChar=1 [Editor_10] Open=1 Top=0 -CursorCol=13 -CursorRow=62 -TopLine=49 +CursorCol=3 +CursorRow=29 +TopLine=70 LeftChar=1 [Editor_11] @@ -149,8 +149,8 @@ LeftChar=1 [Editor_18] Open=1 Top=0 -CursorCol=69 -CursorRow=31 +CursorCol=6 +CursorRow=20 TopLine=1 LeftChar=1 @@ -205,8 +205,8 @@ LeftChar=1 Open=1 Top=0 CursorCol=1 -CursorRow=134 -TopLine=116 +CursorRow=77 +TopLine=77 LeftChar=1 [Editor_26] Open=1 @@ -254,8 +254,8 @@ LeftChar=1 Open=1 Top=0 CursorCol=3 -CursorRow=50 -TopLine=52 +CursorRow=57 +TopLine=28 LeftChar=1 [Editor_33] Open=1 @@ -274,9 +274,9 @@ LeftChar=1 [Editor_35] Open=1 Top=0 -CursorCol=1 -CursorRow=29 -TopLine=1 +CursorCol=2 +CursorRow=51 +TopLine=24 LeftChar=1 [Editor_36] Open=1 @@ -329,10 +329,10 @@ TopLine=1232 LeftChar=1 [Editor_43] Open=1 -Top=0 -CursorCol=1 -CursorRow=1405 -TopLine=1364 +Top=1 +CursorCol=10 +CursorRow=285 +TopLine=249 LeftChar=1 [Editor_44] Open=1 @@ -351,23 +351,23 @@ LeftChar=1 [Editor_46] Open=1 Top=0 -CursorCol=13 -CursorRow=154 -TopLine=1 +CursorCol=1 +CursorRow=77 +TopLine=24 LeftChar=1 [Editor_47] Open=1 -Top=1 -CursorCol=138 -CursorRow=103 -TopLine=96 +Top=0 +CursorCol=1 +CursorRow=157 +TopLine=4 LeftChar=1 [Editor_48] Open=1 Top=0 CursorCol=11 CursorRow=82 -TopLine=53 +TopLine=2 LeftChar=1 [Editor_49] Open=1 @@ -381,33 +381,33 @@ Open=1 Top=0 CursorCol=1 CursorRow=211 -TopLine=203 +TopLine=167 LeftChar=1 [Editor_51] Open=1 Top=0 CursorCol=12 CursorRow=57 -TopLine=28 +TopLine=19 LeftChar=1 [Editor_52] Open=1 Top=0 CursorCol=2 CursorRow=39 -TopLine=4 +TopLine=43 LeftChar=1 [Editor_53] Open=1 Top=0 CursorCol=1 CursorRow=58 -TopLine=16 +TopLine=1 LeftChar=1 [Editor_54] Open=1 Top=0 CursorCol=1 CursorRow=29 -TopLine=2 +TopLine=14 LeftChar=1 diff --git a/src/channels.cpp b/src/channels.cpp index 86df2124a..1def64fd8 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -74,7 +74,6 @@ extern time_t nb_start; extern std::vector<int> fd_reap; extern std::vector<std::string> module_names; -extern char bannerBuffer[MAXBUF]; extern int boundPortCount; extern int portCount; extern int UDPportCount; diff --git a/src/commands.cpp b/src/commands.cpp index c7b0bc6a1..13487e695 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -71,10 +71,12 @@ extern int NetBufferSize; extern int MaxWhoResults; extern time_t nb_start; +extern bool nofork; + extern std::vector<int> fd_reap; extern std::vector<std::string> module_names; -extern char bannerBuffer[MAXBUF]; +extern char MyExecutable[1024]; extern int boundPortCount; extern int portCount; extern int UDPportCount; @@ -259,13 +261,44 @@ void handle_die(char **parameters, int pcnt, userrec *user) void handle_restart(char **parameters, int pcnt, userrec *user) { - log(DEBUG,"restart: %s",user->nick); + char restart[1024]; + char *argv[32]; + log(DEFAULT,"Restart: %s",user->nick); if (!strcmp(parameters[0],restartpass)) { - WriteOpers("*** RESTART command from %s!%s@%s, Pretending to restart till this is finished :D",user->nick,user->ident,user->host); - sleep(DieDelay); - Exit(ERROR); - /* Will finish this later when i can be arsed :) */ + WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host); + + argv[0] = MyExecutable; + argv[1] = "-wait"; + if (nofork) + { + argv[2] = "-nofork"; + } + else + { + argv[2] = NULL; + } + argv[3] = NULL; + + // close ALL file descriptors + send_error("Server restarting."); + sleep(1); + for (int i = 0; i < 65536; i++) + { + int on = 0; + struct linger linger = { 0 }; + setsockopt(i, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)); + linger.l_onoff = 1; + linger.l_linger = 0; + setsockopt(i, SOL_SOCKET, SO_LINGER, (const char*)&linger,sizeof(linger)); + Blocking(i); + close(i); + } + sleep(5); + + execv(MyExecutable,argv); + + exit(0); } else { diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 6a6359b6e..48460b369 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -174,7 +174,7 @@ address_cache IP; ClassVector Classes; struct linger linger = { 0 }; -char bannerBuffer[MAXBUF]; +char MyExecutable[1024]; int boundPortCount = 0; int portCount = 0, UDPportCount = 0, ports[MAXSOCKS]; int defaultRoute = 0; @@ -2000,7 +2000,7 @@ void Error(int status) } -int main(int argc, char *argv[]) +int main(int argc, char **argv) { Start(); srand(time(NULL)); @@ -2013,10 +2013,18 @@ int main(int argc, char *argv[]) Exit(ERROR); } if (argc > 1) { - if (!strcmp(argv[1],"-nofork")) { - nofork = true; + for (int i = 1; i < argc; i++) + { + if (!strcmp(argv[i],"-nofork")) { + nofork = true; + } + if (!strcmp(argv[i],"-wait")) { + sleep(6); + } } } + strcpy(MyExecutable,argv[0]); + if (InspIRCd() == ERROR) { log(DEBUG,"main: daemon function bailed"); @@ -3174,8 +3182,14 @@ int InspIRCd(void) log(DEBUG,"InspIRCd: startup: binding '%s:%s' is default server route",Addr,configToken); } me[count3] = new serverrec(ServerName,100L,false); - me[count3]->CreateListener(Addr,atoi(configToken)); - count3++; + if (!me[count3]->CreateListener(Addr,atoi(configToken))) + { + log(DEFAULT,"Error! Failed to bind port %d",atoi(configToken)); + } + else + { + count3++; + } } else { diff --git a/src/modules.cpp b/src/modules.cpp index 73f3ba69a..311cee22d 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -75,7 +75,6 @@ extern time_t nb_start; extern std::vector<int> fd_reap; extern std::vector<std::string> module_names; -extern char bannerBuffer[MAXBUF]; extern int boundPortCount; extern int portCount; extern int UDPportCount; diff --git a/src/xline.cpp b/src/xline.cpp index 9e756abe5..734c27976 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -74,7 +74,6 @@ extern time_t nb_start; extern std::vector<int> fd_reap; extern std::vector<std::string> module_names; -extern char bannerBuffer[MAXBUF]; extern int boundPortCount; extern int portCount; extern int UDPportCount; |