Author: Andres Miller <a1kmm@mware.virtualave.net>
[ircu2.10.12-pk.git] / ircd / ircd.c
index d6085344441600988cc0412cbb60c8adbbecd8c5..8912a82f705ae93f57cf97db6dec51bb0d212d86 100644 (file)
@@ -26,6 +26,7 @@
 #include "class.h"
 #include "client.h"
 #include "crule.h"
+#include "destruct_event.h"
 #include "hash.h"
 #include "ircd_alloc.h"
 #include "ircd_events.h"
@@ -103,6 +104,7 @@ static char   *dpath             = DPATH;
 
 static struct Timer connect_timer; /* timer structure for try_connections() */
 static struct Timer ping_timer; /* timer structure for check_pings() */
+static struct Timer destruct_event_timer; /* timer structure for exec_expired_destruct_events() */
 
 static struct Daemon thisServer  = { 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0 };
 
@@ -227,7 +229,7 @@ static void try_connections(struct Event* ev) {
   struct ConnectionClass* cltmp;
   struct ConfItem*  con_conf    = 0;
   struct Jupe*      ajupe;
-  unsigned int      con_class   = 0;
+  const char*       con_class   = NULL;
 
   assert(ET_EXPIRE == ev_type(ev));
   assert(0 != ev_timer(ev));
@@ -263,7 +265,7 @@ static void try_connections(struct Event* ev) {
     cptr = FindServer(aconf->name);
 
     if (!cptr && (Links(cltmp) < MaxLinks(cltmp)) &&
-        (!connecting || (ConClass(cltmp) > con_class))) {
+        (!connecting /*|| (ConClass(cltmp) > con_class)*/)) {
       /*
        * Check connect rules to see if we're allowed to try
        */
@@ -353,17 +355,6 @@ static void check_pings(struct Event* ev) {
       continue;
     }
 
-    /* Quit the client after max_ping*2 - they should have answered by now */
-    if (CurrentTime-cli_lasttime(cptr) >= (max_ping*2) ) {
-      /* If it was a server, then tell ops about it. */
-      if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr))
-       sendto_opmask_butone(0, SNO_OLDSNO,
-                            "No response from %s, closing link",
-                            cli_name(cptr));
-      exit_client_msg(cptr, cptr, &me, "Ping timeout");
-      continue;
-    }
-    
     /* Unregistered clients pingout after max_ping seconds, they don't
      * get given a second chance - if they were then people could not quite
      * finish registration and hold resources without being subject to k/g
@@ -378,7 +369,7 @@ static void check_pings(struct Event* ev) {
                   ":Your client may not be compatible with this server.");
        send_reply(cptr, SND_EXPLICIT | ERR_BADPING,
                   ":Compatible clients are available at "
-                  "ftp://ftp.undernet.org/pub/irc/clients");
+                  URL_CLIENTS);
       }    
       exit_client_msg(cptr,cptr,&me, "Ping Timeout");
       continue;
@@ -399,6 +390,17 @@ static void check_pings(struct Event* ev) {
        sendcmdto_one(&me, CMD_PING, cptr, ":%s", cli_name(&me));
     }
     
+    /* Quit the client after max_ping*2 - they should have answered by now */
+    if (CurrentTime-cli_lasttime(cptr) >= (max_ping*2) ) {
+      /* If it was a server, then tell ops about it. */
+      if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr))
+       sendto_opmask_butone(0, SNO_OLDSNO,
+                            "No response from %s, closing link",
+                            cli_name(cptr));
+      exit_client_msg(cptr, cptr, &me, "Ping timeout");
+      continue;
+    }
+    
     expire = cli_lasttime(cptr) + max_ping * 2;
     if (expire < next_check)
       next_check=expire;
@@ -492,9 +494,9 @@ static char check_file_access(const char *path, char which, int mode) {
 
   fprintf(stderr, 
          "Check on %cPATH (%s) failed: %s\n"
-         "Please create file and/or rerun `make config' and "
-         "recompile to correct this.\n",
-         which, path, strerror(errno));
+         "Please create this file and/or rerun `configure' "
+         "using --with-%cpath and recompile to correct this.\n",
+         which, path, strerror(errno), which);
 
   return 0;
 }
@@ -573,11 +575,6 @@ int main(int argc, char **argv) {
   if (!check_file_access(SPATH, 'S', X_OK) ||
       !check_file_access(configfile, 'C', R_OK))
     return 4;
-      
-#ifdef DEBUGMODE
-  if (!check_file_access(LPATH, 'L', W_OK))
-    return 5;
-#endif
 
   debug_init(thisServer.bootopt & BOOT_TTY);
   daemon_init(thisServer.bootopt & BOOT_TTY);
@@ -620,8 +617,9 @@ int main(int argc, char **argv) {
   uping_init();
 
   IPcheck_init();
-  timer_add(&connect_timer, try_connections, 0, TT_RELATIVE, 1);
-  timer_add(&ping_timer, check_pings, 0, TT_RELATIVE, 1);
+  timer_add(timer_init(&connect_timer), try_connections, 0, TT_RELATIVE, 1);
+  timer_add(timer_init(&ping_timer), check_pings, 0, TT_RELATIVE, 1);
+  timer_add(timer_init(&destruct_event_timer), exec_expired_destruct_events, 0, TT_PERIODIC, 60);
 
   CurrentTime = time(NULL);