]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
add service install and remove calls to installer.
[user/henk/code/inspircd.git] / src / inspircd.cpp
index d09dff84067f35612d4942559e42a5288b5628ac..e2ed1282ceab55bfc111c3d18498aef0369925ac 100644 (file)
@@ -11,6 +11,8 @@
  * ---------------------------------------------------
  */
 
+/* w00t was here. ;p */
+
 /* $Install: src/inspircd $(BINPATH) */
 #include "inspircd.h"
 #include <signal.h>
@@ -93,7 +95,7 @@ void InspIRCd::Cleanup()
        /* Close all client sockets, or the new process inherits them */
        for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++)
        {
-               (*i)->SetWriteError("Server shutdown");
+               this->Users->QuitUser((*i), "Server shutdown");
                (*i)->CloseSocket();
        }
 
@@ -224,8 +226,6 @@ void InspIRCd::Restart(const std::string &reason)
         */
        this->SendError(reason);
 
-       this->Cleanup();
-
        /* Figure out our filename (if theyve renamed it, we're boned) */
        std::string me;
 
@@ -237,7 +237,11 @@ void InspIRCd::Restart(const std::string &reason)
        me = Config->MyDir + "/inspircd";
 #endif
 
-       if (execv(me.c_str(), Config->argv) == -1)
+       char** argv = Config->argv;
+
+       this->Cleanup();
+
+       if (execv(me.c_str(), argv) == -1)
        {
                /* Will raise a SIGABRT if not trapped */
                throw CoreException(std::string("Failed to execv()! error: ") + strerror(errno));
@@ -349,7 +353,8 @@ bool InspIRCd::DaemonSeed()
 void InspIRCd::WritePID(const std::string &filename)
 {
        std::string fname = (filename.empty() ? "inspircd.pid" : filename);
-       if (*(fname.begin()) != '/')
+       std::replace(fname.begin(), fname.end(), '\\', '/');
+       if ((fname[0] != '/') && (!Config->StartsWithWindowsDriveLetter(filename)))
        {
                std::string::size_type pos;
                std::string confpath = this->ConfigFileName;
@@ -666,22 +671,15 @@ InspIRCd::InspIRCd(int argc, char** argv)
        this->BuildISupport();
        InitializeDisabledCommands(Config->DisabledCommands, this);
 
-       /*if ((Config->ports.size() == 0) && (found_ports > 0))
-       {
-               printf("\nERROR: I couldn't bind any ports! Are you sure you didn't start InspIRCd twice?\n");
-               Logs->Log("STARTUP", DEFAULT,"ERROR: I couldn't bind any ports! Something else is bound to those ports!");
-               Exit(EXIT_STATUS_BIND);
-       }*/
-
        if (Config->ports.size() != (unsigned int)found_ports)
        {
                printf("\nWARNING: Not all your client ports could be bound --\nstarting anyway with %d of %d client ports bound.\n\n", bounditems, found_ports);
                printf("The following port(s) failed to bind:\n");
-               printf("Hint: Try using an IP instead of blank or *\n\n");
+               printf("Hint: Try using a public IP instead of blank or *\n\n");
                int j = 1;
                for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
                {
-                       printf("%d.\tIP: %s\tPort: %lu\n", j, i->first.empty() ? "<all>" : i->first.c_str(), (unsigned long)i->second);
+                       printf("%d.\tAddress: %s\tReason: %s\n", j, i->first.empty() ? "<all>" : i->first.c_str(), i->second.c_str());
                }
        }
 
@@ -703,7 +701,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
                 * e.g. we are restarting, or being launched by cron. Dont kill parent, and dont
                 * close stdin/stdout
                 */
-               if (!do_nofork)
+               if ((!do_nofork) && (!do_testsuite))
                {
                        fclose(stdin);
                        fclose(stderr);
@@ -790,9 +788,14 @@ int InspIRCd::Run()
                 */
                if (TIME != OLDTIME)
                {
-                       if (TIME < OLDTIME)
+                       /* Allow a buffer of two seconds drift on this so that ntpdate etc dont harass admins */
+                       if (TIME < OLDTIME - 2)
+                       {
+                               SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %lu secs.", (unsigned long)OLDTIME-TIME);
+                       }
+                       else if (TIME > OLDTIME + 2)
                        {
-                               SNO->WriteToSnoMask('A', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %lu secs.", (unsigned long)OLDTIME-TIME);
+                               SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is jumping FORWARDS! Clock skipped %lu secs.", (unsigned long)TIME - OLDTIME);
                        }
 
                        if ((TIME % 3600) == 0)
@@ -864,7 +867,7 @@ void InspIRCd::BufferedSocketCull()
  * An ircd in five lines! bwahahaha. ahahahahaha. ahahah *cough*.
  */
 
-int main(int argc, char ** argv)
+ENTRYPOINT
 {
        SI = new InspIRCd(argc, argv);
        mysig = &SI->s_signal;