Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2006-12-31 04:16:32 UTC

Modified files:
     ChangeLog include/struct.h ircd/ircd.c ircd/m_pong.c ircd/s_bsd.c

Log message:

Separate AsLL timeouts from server ping timeouts.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.825 ircu2.10/ChangeLog:1.826
--- ircu2.10/ChangeLog:1.825    Thu Dec  7 18:07:51 2006
+++ ircu2.10/ChangeLog  Sat Dec 30 20:16:21 2006
@@ -1,3 +1,19 @@
+2006-12-30  Michael Poole <[EMAIL PROTECTED]>
+
+       * include/struct.h (struct Server): Add asll_last field.
+
+       * ircd/ircd.c (check_pings): Add check for asll_last.  When a
+       server doesn't ping, use an old-style ping rather than AsLL ping.
+
+       * ircd/m_pong.c (ms_pong): Use ClearPingSent() rather than
+       ClrFlag().  Set asll_last to current time.
+       (mr_pong): Use ClearPingSent() rather than ClrFlag().
+       (m_pong): Likewise.
+
+       * ircd/s_bsd.c (completed_connection): Likewise.
+       (read_packet): Likewise.  Update cli_lasttime for servers in
+       addition to clients.
+
 2006-12-07  Michael Poole <[EMAIL PROTECTED]>
 
        * ircd/flagset.h: New file.
Index: ircu2.10/include/struct.h
diff -u ircu2.10/include/struct.h:1.11 ircu2.10/include/struct.h:1.12
--- ircu2.10/include/struct.h:1.11      Mon Jul 24 20:27:18 2006
+++ ircu2.10/include/struct.h   Sat Dec 30 20:16:21 2006
@@ -20,7 +20,7 @@
  */
 /** @file
  * @brief Structure definitions for users and servers.
- * @version $Id: struct.h,v 1.11 2006/07/25 03:27:18 entrope Exp $
+ * @version $Id: struct.h,v 1.12 2006/12/31 04:16:21 entrope Exp $
  */
 #ifndef INCLUDED_struct_h
 #define INCLUDED_struct_h
@@ -59,6 +59,7 @@
   int            asll_rtt;      /**< AsLL round-trip time */
   int            asll_to;       /**< AsLL upstream lag */
   int            asll_from;     /**< AsLL downstream lag */
+  time_t         asll_last;     /**< Last time we sent or received an AsLL 
ping */
 
   char *last_error_msg;         /**< Allocated memory with last message 
receive with an ERROR */
   char by[NICKLEN + 1];         /**< Numnick of client who requested the link 
*/
Index: ircu2.10/ircd/ircd.c
diff -u ircu2.10/ircd/ircd.c:1.102 ircu2.10/ircd/ircd.c:1.103
--- ircu2.10/ircd/ircd.c:1.102  Wed Jul 26 18:25:51 2006
+++ ircu2.10/ircd/ircd.c        Sat Dec 30 20:16:21 2006
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief Entry point and other initialization functions for the daemon.
- * @version $Id: ircd.c,v 1.102 2006/07/27 01:25:51 entrope Exp $
+ * @version $Id: ircd.c,v 1.103 2006/12/31 04:16:21 entrope Exp $
  */
 #include "config.h"
 
@@ -355,6 +355,24 @@
           IsPingSent(cptr) ? "[Ping Sent]" : "[]", 
           max_ping, (int)(CurrentTime - cli_lasttime(cptr))));
 
+    /* If it's a server and we have not sent an AsLL lately, do so. */
+    if (IsServer(cptr)) {
+      if (CurrentTime - cli_serv(cptr)->asll_last >= max_ping) {
+        char *asll_ts;
+
+        SetPingSent(cptr);
+        cli_serv(cptr)->asll_last = CurrentTime;
+        expire = cli_serv(cptr)->asll_last + max_ping;
+        asll_ts = militime_float(NULL);
+        sendcmdto_prio_one(&me, CMD_PING, cptr, "!%s %s %s", asll_ts,
+                           cli_name(cptr), asll_ts);
+      }
+
+      expire = cli_serv(cptr)->asll_last + max_ping;
+      if (expire < next_check)
+        next_check = expire;
+    }
+
     /* Ok, the thing that will happen most frequently, is that someone will
      * have sent something recently.  Cover this first for speed.
      * -- 
@@ -417,11 +435,7 @@
       if (IsUser(cptr))
         sendrawto_one(cptr, MSG_PING " :%s", cli_name(&me));
       else
-      {
-        char *asll_ts = militime_float(NULL);
-        sendcmdto_prio_one(&me, CMD_PING, cptr, "!%s %s %s", asll_ts,
-                           cli_name(cptr), asll_ts);
-      }
+        sendcmdto_prio_one(&me, CMD_PING, cptr, ":%s", cli_name(&me));
     }
     
     expire = cli_lasttime(cptr) + max_ping * 2;
Index: ircu2.10/ircd/m_pong.c
diff -u ircu2.10/ircd/m_pong.c:1.20 ircu2.10/ircd/m_pong.c:1.21
--- ircu2.10/ircd/m_pong.c:1.20 Wed Jul 26 18:25:51 2006
+++ ircu2.10/ircd/m_pong.c      Sat Dec 30 20:16:21 2006
@@ -20,7 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: m_pong.c,v 1.20 2006/07/27 01:25:51 entrope Exp $
+ * $Id: m_pong.c,v 1.21 2006/12/31 04:16:21 entrope Exp $
  */
 
 #include "config.h"
@@ -74,8 +74,8 @@
   }
   origin      = parv[1];
   destination = parv[2];
-  ClrFlag(cptr, FLAG_PINGSENT);
-  ClrFlag(sptr, FLAG_PINGSENT);
+  ClearPingSent(cptr);
+  ClearPingSent(sptr);
   cli_lasttime(cptr) = CurrentTime;
 
   if (parc > 5)
@@ -84,6 +84,7 @@
     cli_serv(cptr)->asll_rtt = atoi(militime_float(parv[3]));
     cli_serv(cptr)->asll_to = atoi(parv[4]);
     cli_serv(cptr)->asll_from = atoi(militime_float(parv[5]));
+    cli_serv(cptr)->asll_last = CurrentTime;
     return 0;
   }
   
@@ -121,7 +122,7 @@
   assert(cptr == sptr);
   assert(!IsRegistered(sptr));
 
-  ClrFlag(cptr, FLAG_PINGSENT);
+  ClearPingSent(cptr);
   return (parc > 1) ? auth_set_pong(cli_auth(sptr), strtoul(parv[parc - 1], 
NULL, 10)) : 0;
 }
 
@@ -140,7 +141,7 @@
   assert(0 != cptr);
   assert(cptr == sptr);
 
-  ClrFlag(cptr, FLAG_PINGSENT);
+  ClearPingSent(cptr);
   cli_lasttime(cptr) = CurrentTime;
   return 0;
 }
Index: ircu2.10/ircd/s_bsd.c
diff -u ircu2.10/ircd/s_bsd.c:1.88 ircu2.10/ircd/s_bsd.c:1.89
--- ircu2.10/ircd/s_bsd.c:1.88  Thu Dec  7 17:39:22 2006
+++ ircu2.10/ircd/s_bsd.c       Sat Dec 30 20:16:22 2006
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief Functions that now (or in the past) relied on BSD APIs.
- * @version $Id: s_bsd.c,v 1.88 2006/12/08 01:39:22 entrope Exp $
+ * @version $Id: s_bsd.c,v 1.89 2006/12/31 04:16:22 entrope Exp $
  */
 #include "config.h"
 
@@ -374,7 +374,7 @@
    * Make us timeout after twice the timeout for DNS look ups
    */
   cli_lasttime(cptr) = CurrentTime;
-  SetFlag(cptr, FLAG_PINGSENT);
+  ClearPingSent(cptr);
 
   sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s6 :%s",
                 cli_name(&me), cli_serv(&me)->timestamp, newts,
@@ -604,12 +604,11 @@
     case IO_SUCCESS:
       if (length)
       {
-        if (!IsServer(cptr))
-          cli_lasttime(cptr) = CurrentTime;
+        cli_lasttime(cptr) = CurrentTime;
+        ClearPingSent(cptr);
+        ClrFlag(cptr, FLAG_NONL);
         if (cli_lasttime(cptr) > cli_since(cptr))
           cli_since(cptr) = cli_lasttime(cptr);
-        ClrFlag(cptr, FLAG_PINGSENT);
-        ClrFlag(cptr, FLAG_NONL);
       }
       break;
     case IO_BLOCKED:
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to