Implemented initial support for zombie mode by Jan Krüger <jk@jk.gs>
[ircu2.10.12-pk.git] / ircd / ircd.c
index 693ac88e0f68109fcbf1bde830e9411040582392..91ab9b41f6d5de57e42b85ce7153e62713039b5f 100644 (file)
@@ -112,7 +112,7 @@ time_t         CurrentTime;             /**< Updated every time we leave select(
 char          *configfile        = CPATH; /**< Server configuration file */
 int            debuglevel        = -1;    /**< Server debug level  */
 char          *debugmode         = "";    /**< Server debug level */
-char          *dpath             = DPATH; /**< Working directory for daemon */
+static char   *dpath             = DPATH; /**< Working directory for daemon */
 static char   *dbg_client;                /**< Client specifier for chkconf */
 
 static struct Timer connect_timer; /**< timer structure for try_connections() */
@@ -339,7 +339,19 @@ static void check_pings(struct Event* ev) {
    
     if (!cptr)
       continue;
-     
+    
+    /* We don't need to check zombies here */
+    if (IsNotConn(cptr)) {
+      assert(IsUser(cptr));
+      /* for now: reap after fixed time (15 minutes) */
+      if ((CurrentTime - cli_user(cptr)->last) >= 900) {
+        SetFlag(cptr, FLAG_DEADSOCKET);
+        /* this will be used as exit message */
+        ircd_strncpy(cli_info(cptr), "Ping timeout", REALLEN);
+      } else
+        continue;
+    }
+    
     assert(&me != cptr);  /* I should never be in the local client array! */
    
 
@@ -420,6 +432,14 @@ static void check_pings(struct Event* ev) {
         sendto_opmask_butone(0, SNO_OLDSNO,
                              "No response from %s, closing link",
                              cli_name(cptr));
+      /*
+       * Keep client structure around when a user pings out, so that they can
+       * reconnect to it later
+       */
+      if (IsUser(cptr) && IsAccount(cptr)) {
+        zombie_client(&me, &me, cptr);
+        continue;
+      }
       exit_client_msg(cptr, cptr, &me, "Ping timeout");
       continue;
     }
@@ -623,7 +643,6 @@ static int set_userid_if_needed(void) {
 int main(int argc, char **argv) {
   CurrentTime = time(NULL);
   printf("Starting IRCu 2.10.12.10 by pk910.\n");
-  printf("you are not allowed to use this version without my permission\n");
   thisServer.argc = argc;
   thisServer.argv = argv;
   thisServer.uid  = getuid();