]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd_io.cpp
Moved to B3 official
[user/henk/code/inspircd.git] / src / inspircd_io.cpp
index 4d61d41050b8a830d79f0bf0698152acb714e7d5..79e91217574b0f843fb97154443e3417273b429e 100644 (file)
@@ -32,6 +32,8 @@ using namespace std;
 extern FILE *log_file;
 extern int boundPortCount;
 extern int openSockfd[MAXSOCKS];
+extern time_t TIME;
+extern bool unlimitcore;
 
 void WriteOpers(char* text, ...);
 
@@ -40,13 +42,6 @@ void Exit (int status)
        if (log_file)
                fclose(log_file);
        send_error("Server shutdown.");
-
-       // close down all listening sockets
-       for (int count = 0; count < boundPortCount; count++)
-       {
-               shutdown(openSockfd[count], 2);
-       }
-
        exit (status);
 }
 
@@ -55,11 +50,6 @@ void Killed(int status)
        if (log_file)
                fclose(log_file);
        send_error("Server terminated.");
-        // close down all listening sockets
-       for (int count = 0; count < boundPortCount; count++)
-       {
-               shutdown(openSockfd[count], 2);
-       }
        exit(status);
 }
 
@@ -73,12 +63,12 @@ void Rehash(int status)
 
 void Start (void)
 {
-       printf("\033[1;37mInspire Internet Relay Chat Server, compiled " __DATE__ " at " __TIME__ "\n");
+       printf("\033[1mInspire Internet Relay Chat Server, compiled " __DATE__ " at " __TIME__ "\n");
        printf("(C) ChatSpike Development team.\033[0;37m\n\n");
-       printf("\033[1;37mDevelopers:\033[0;37m     Brain, FrostyCoolSlug\n");
-       printf("\033[1;37mDocumentation:\033[0;37m  FrostyCoolSlug, w00t\n");
-       printf("\033[1;37mTesters:\033[0;37m        typobox43, piggles, Lord_Zathras, CC\n");
-       printf("\033[1;37mName concept:\033[0;37m   Lord_Zathras\n\n");
+       printf("Developers:\033[1m     Brain, FrostyCoolSlug\n");
+       printf("Documentation:\033[1m  FrostyCoolSlug, w00t\n");
+       printf("Testers:\033[1m        typobox43, piggles, Lord_Zathras, CC\n");
+       printf("Name concept:\033[1m   Lord_Zathras\n\n");
 }
 
 void WritePID(std::string filename)
@@ -119,12 +109,28 @@ int DaemonSeed (void)
                exit (0);
        setsid ();
        umask (007);
-       /* close stdout, stdin, stderr */
-       close(0);
-       close(1);
-       close(2);
-
+       printf("InspIRCd PID: %d\n",getpid());
+       /* close stdin, stdout, stderr */
+       freopen("/dev/null","w",stdout);
+       freopen("/dev/null","w",stderr);
+       
        setpriority(PRIO_PROCESS,(int)getpid(),15); /* ircd sets to low process priority so it doesnt hog the box */
+
+       if (unlimitcore)
+       {
+               rlimit rl;
+               if (getrlimit(RLIMIT_CORE, &rl) == -1)
+               {
+                       log(DEFAULT,"Failed to getrlimit()!");
+                       return(FALSE);
+               }
+               else
+               {
+                       rl.rlim_cur = rl.rlim_max;
+                       if (setrlimit(RLIMIT_CORE, &rl) == -1)
+                               log(DEFAULT,"setrlimit() failed, cannot increase coredump size.");
+               }
+       }
   
        return (TRUE);
 }
@@ -650,7 +656,7 @@ int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server
 int OpenTCPSocket (void)
 {
        int sockfd;
-       int on = 0;
+       int on = 1;
        struct linger linger = { 0 };
   
        if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
@@ -660,7 +666,7 @@ int OpenTCPSocket (void)
                setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on));
                /* This is BSD compatible, setting l_onoff to 0 is *NOT* http://web.irc.org/mla/ircd-dev/msg02259.html */
                linger.l_onoff = 1;
-               linger.l_linger = 0;
+               linger.l_linger = 1;
                setsockopt(sockfd, SOL_SOCKET, SO_LINGER, (const char*)&linger,sizeof(linger));
                return (sockfd);
        }