Merge end-of-December changes from HEAD to u2_10_12_branch.
authorMichael Poole <mdpoole@troilus.org>
Mon, 15 Jan 2007 03:08:23 +0000 (03:08 +0000)
committerMichael Poole <mdpoole@troilus.org>
Mon, 15 Jan 2007 03:08:23 +0000 (03:08 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1746 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/struct.h
ircd/ircd.c
ircd/ircd_string.c
ircd/m_mode.c
ircd/m_pong.c
ircd/os_generic.c
ircd/s_bsd.c

index b70946a2ce2cf9a5e15ed4ee314f353f3ee34038..2096ac261e23b326aea479174356f75176e74f42 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2006-12-31  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/m_mode.c (ms_mode): Bounce modes from deopped members.
+
+2006-12-30  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/ircd_string.c (ircd_strncpy): Make sure the output buffer
+       is terminated.  We don't rely on the arguable strncpy semantics.
+
+2006-12-30  Michael Poole <mdpoole@troilus.org>
+
+       * 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-01-13  Michael Poole <mdpoole@troilus.org>
 
        * ircd/m_burst.c (ms_burst): Properly handle member mode :ov.
index b7041669c0669fe655d6fa8e311cb371d6d09a9e..cd2712c931c8b8897b0b247c70c897ca90a7ccf3 100644 (file)
@@ -57,6 +57,7 @@ struct Server {
   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 8503d0ca7d33cd168ce61c189838a09cc5f4ede4..006263b8f55eab5547162a1d2c47ebc553be07d8 100644 (file)
@@ -356,6 +356,24 @@ static void check_pings(struct Event* ev) {
           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.
      * -- 
@@ -418,11 +436,7 @@ static void check_pings(struct Event* ev) {
       if (IsUser(cptr))
         sendrawto_one(cptr, MSG_PING " :%s", cli_name(&me));
       else
-      {
-        char *asll_ts = militime_float(NULL);
-        sendcmdto_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 52caed58499033be7ec450e3716fa186446a5e21..a9d945138aed394032ca597bb9d291b1d79e625f 100644 (file)
@@ -156,6 +156,8 @@ char* ircd_strncpy(char* s1, const char* s2, size_t n)
 
   while (s < endp && (*s++ = *s2++))
     ;
+  if (s == endp)
+    *s = '\0';
   return s1;
 }
 
index ca366ccd65bf243b430c84e6174f1016fac6af48..cb27ee5fb4dd37c9a53c291165a5b47f6681a67b 100644 (file)
@@ -197,7 +197,7 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
                MODE_PARSE_FORCE),  /* And force it to be accepted */
                NULL);
   } else {
-    if (!(member = find_member_link(chptr, sptr))) {
+    if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) {
       modebuf_init(&mbuf, sptr, cptr, chptr,
                   (MODEBUF_DEST_SERVER |  /* Send mode to server */
                    MODEBUF_DEST_HACK2  |  /* Send a HACK(2) message */
index 9cae0c0d1e29a67112a497ad02f03bbbe9949fbc..df29b9f6714ace850041b1f669e08094c62e2226 100644 (file)
@@ -119,8 +119,8 @@ int ms_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   }
   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)
@@ -129,6 +129,7 @@ int ms_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     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;
   }
   
@@ -162,7 +163,7 @@ int mr_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   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;
 }
 
@@ -178,7 +179,7 @@ int m_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   assert(0 != cptr);
   assert(cptr == sptr);
 
-  ClrFlag(cptr, FLAG_PINGSENT);
+  ClearPingSent(cptr);
   cli_lasttime(cptr) = CurrentTime;
   return 0;
 }
index 72fba12f21ba657320e01d6ff4d841526bc2731d..1c6489b3a6cce1c20f8d1704c814a0dd427bae07 100644 (file)
@@ -450,9 +450,13 @@ IOResult os_recv_nonb(int fd, char* buf, unsigned int length,
   if (0 < (res = recv(fd, buf, length, 0))) {
     *count_out = (unsigned) res;
     return IO_SUCCESS;
+  } else if (res == 0) {
+    *count_out = 0;
+    errno = 0; /* or ECONNRESET? */
+    return IO_FAILURE;
   } else {
     *count_out = 0;
-    return (res < 0) && is_blocked(errno) ? IO_BLOCKED : IO_FAILURE;
+    return is_blocked(errno) ? IO_BLOCKED : IO_FAILURE;
   }
 }
 
index 71706e518536ee58478860c4cac23cf851cffd57..3989ca0efa1acc021c27a7ed507d0a5ac5058290 100644 (file)
@@ -352,7 +352,7 @@ static int completed_connection(struct Client* cptr)
    * 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,
@@ -581,12 +581,11 @@ static int read_packet(struct Client *cptr, int socket_ready)
     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: