diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd_restart.cpp | 28 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 22 | ||||
-rw-r--r-- | src/inspircd.cpp | 12 | ||||
-rw-r--r-- | src/modules/extra/m_ziplink.cpp | 2 |
4 files changed, 29 insertions, 35 deletions
diff --git a/src/cmd_restart.cpp b/src/cmd_restart.cpp index c985c1717..73bfce298 100644 --- a/src/cmd_restart.cpp +++ b/src/cmd_restart.cpp @@ -24,37 +24,11 @@ extern "C" command_t* init_command(InspIRCd* Instance) CmdResult cmd_restart::Handle (const char** parameters, int pcnt, userrec *user) { - char *argv[32]; ServerInstance->Log(DEFAULT,"Restart: %s",user->nick); if (!strcmp(parameters[0],ServerInstance->Config->restartpass)) { ServerInstance->WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host); - - argv[0] = ServerInstance->Config->MyExecutable; - argv[1] = "-wait"; - if (ServerInstance->Config->nofork) - { - argv[2] = "-nofork"; - } - else - { - argv[2] = NULL; - } - argv[3] = NULL; - - // close ALL file descriptors - ServerInstance->SendError("Server restarting."); - sleep(1); - for (int i = 0; i < MAX_DESCRIPTORS; i++) - { - shutdown(i,2); - close(i); - } - sleep(2); - - execv(ServerInstance->Config->MyExecutable,argv); - - exit(0); + ServerInstance->Restart("Server restarting"); } else { diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index dab21744a..9ddfe338f 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -274,20 +274,24 @@ chanrec* InspIRCd::FindChan(const std::string &chan) * sends out an error notice to all connected clients (not to be used * lightly!) */ -void InspIRCd::SendError(const char *s) +void InspIRCd::SendError(const std::string &s) { for (std::vector<userrec*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++) { - userrec* t = (userrec*)(*i); - if (t->registered == REG_ALL) + if ((*i)->registered == REG_ALL) { - t->WriteServ("NOTICE %s :%s",t->nick,s); + (*i)->WriteServ("NOTICE %s :%s",(*i)->nick,s.c_str()); } else { - // fix - unregistered connections receive ERROR, not NOTICE - t->Write("ERROR :%s",s); + /* Unregistered connections receive ERROR, not a NOTICE */ + (*i)->Write("ERROR :" + s); } + /* This might generate a whole load of EAGAIN, but we dont really + * care about this, as if we call SendError something catastrophic + * has occured anyway, and we wont receive the events for these. + */ + (*i)->FlushWriteBuf(); } } @@ -423,11 +427,15 @@ bool InspIRCd::IsNick(const char* n) void InspIRCd::OpenLog(char** argv, int argc) { + Config->MyDir = ServerConfig::GetFullProgDir(argv,argc); + Config->argv = argv; + Config->argc = argc; + if (!*this->LogFileName) { if (Config->logpath == "") { - Config->logpath = ServerConfig::GetFullProgDir(argv,argc) + "/ircd.log"; + Config->logpath = Config->MyDir + "/ircd.log"; } Config->log_file = fopen(Config->logpath.c_str(),"a+"); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 54c3aa0ab..670fb5ef7 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -66,6 +66,18 @@ void InspIRCd::Exit(int status) exit (status); } +void InspIRCd::Restart(const std::string &reason) +{ + this->SendError(reason); + std::string me = Config->MyDir + "/inspircd"; + this->Logger->Close(); + if (execv(me.c_str(), Config->argv) == -1) + { + /* Will raise a SIGABRT if not trapped */ + throw CoreException(std::string("Failed to execv()! error: ") + strerror(errno)); + } +} + void InspIRCd::Start() { printf("\033[1;32mInspire Internet Relay Chat Server, compiled %s at %s\n",__DATE__,__TIME__); diff --git a/src/modules/extra/m_ziplink.cpp b/src/modules/extra/m_ziplink.cpp index 841591225..ab40acb46 100644 --- a/src/modules/extra/m_ziplink.cpp +++ b/src/modules/extra/m_ziplink.cpp @@ -443,7 +443,7 @@ class ModuleZLib : public Module void CloseSession(izip_session* session) { - if (session->status = IZIP_OPEN) + if (session->status == IZIP_OPEN) { session->status = IZIP_CLOSED; session->outbuf = ""; |