Scan all Connect blocks for next auto-reconnect time.
authorMichael Poole <mdpoole@troilus.org>
Sun, 5 Feb 2006 00:52:16 +0000 (00:52 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sun, 5 Feb 2006 00:52:16 +0000 (00:52 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1615 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/ircd.c

index 8c935b85c9202d5769cba0aa11dd3a607d0e2d3b..095919eda5f1afb5f1c91701f451cc1c6a0e9fb3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-02-04  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/ircd.c (try_connections): Scan all Connect blocks for the
+       earliest hold time (suggested by Michael).
+
 2006-02-04  Michael Poole <mdpoole@troilus.org>
 
        * ircd/m_join.c (m_join): Remove #if 0 code and update comment.
index 3ef0cdd9a5d36eb5628618952f09e96c65d9e428..3ba3af7dc5b8a0f9559fac536e0d90a95614833b 100644 (file)
@@ -250,15 +250,18 @@ static int check_pid(void)
 static void try_connections(struct Event* ev) {
   struct ConfItem*  aconf;
   struct ConfItem** pconf;
-  time_t            next        = 0;
-  struct ConnectionClass* cltmp;
+  time_t            next;
   struct Jupe*      ajupe;
-  int hold;
+  int               hold;
+  int               done;
 
   assert(ET_EXPIRE == ev_type(ev));
   assert(0 != ev_timer(ev));
 
   Debug((DEBUG_NOTICE, "Connection check at   : %s", myctime(CurrentTime)));
+  next = CurrentTime + feature_int(FEAT_CONNECTFREQUENCY);
+  done = 0;
+
   for (aconf = GlobalConfList; aconf; aconf = aconf->next) {
     /* Only consider server items with non-zero port and non-zero
      * connect times that are not actively juped.
@@ -273,17 +276,16 @@ static void try_connections(struct Event* ev) {
     hold = aconf->hold > CurrentTime;
 
     /* Update next possible connection check time. */
-    if (hold && (next > aconf->hold || next == 0))
+    if (hold && next > aconf->hold)
         next = aconf->hold;
 
-    cltmp = aconf->conn_class;
-
     /* Do not try to connect if its use is still on hold until future,
+     * we have already initiated a connection this try_connections(),
      * too many links in its connection class, it is already linked,
      * or if connect rules forbid a link now.
      */
-    if (hold
-        || (Links(cltmp) > MaxLinks(cltmp))
+    if (hold || done
+        || (ConfLinks(aconf) > ConfMaxLinks(aconf))
         || FindServer(aconf->name)
         || conf_eval_crule(aconf->name, CRULE_MASK))
       continue;
@@ -305,14 +307,10 @@ static void try_connections(struct Event* ev) {
                           aconf->name);
 
     /* And stop looking for further candidates. */
-    break;
+    done = 1;
   }
 
-  if (next == 0)
-    next = CurrentTime + feature_int(FEAT_CONNECTFREQUENCY);
-
   Debug((DEBUG_NOTICE, "Next connection check : %s", myctime(next)));
-
   timer_add(&connect_timer, try_connections, 0, TT_ABSOLUTE, next);
 }