Fix sending P10 bursts with many bans.
authorMichael Poole <mdpoole@troilus.org>
Fri, 6 Oct 2006 23:18:58 +0000 (23:18 +0000)
committerMichael Poole <mdpoole@troilus.org>
Fri, 6 Oct 2006 23:18:58 +0000 (23:18 +0000)
src/proto-p10.c (irc_burst): Only send modes and user list once.
git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-57

ChangeLog
src/proto-p10.c

index 102e7941537c10d15583d7cf82e6a14c6c818e69..8131210cd80f1307c68444314e033362e06ace1f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3
 #
 
+2006-10-06 23:18:58 GMT        Michael Poole <mdpoole@troilus.org>     patch-57
+
+    Summary:
+      Fix sending P10 bursts with many bans.
+    Revision:
+      srvx--devo--1.3--patch-57
+
+    src/proto-p10.c (irc_burst): Only send modes and user list once.
+
+    modified files:
+     ChangeLog src/proto-p10.c
+
+
 2006-10-06 23:16:58 GMT        Michael Poole <mdpoole@troilus.org>     patch-56
 
     Summary:
index eab4ac6a0a219ba279f6196977599b2b8525bc6d..4d64e830b9a4a60062a93826c18fc9aaf817b504 100644 (file)
@@ -689,13 +689,14 @@ irc_burst(struct chanNode *chan)
     struct modeNode *mn;
     struct banNode *bn;
     long last_mode=-1;
+    unsigned int first_ban;
     unsigned int n;
 
     base_len = sprintf(burst_line, "%s " P10_BURST " %s " FMT_TIME_T " ",
                        self->numeric, chan->name, chan->timestamp);
     len = irc_make_chanmode(chan, burst_line+base_len);
     pos = base_len + len;
-    if (len)
+    if (len > 0 && chan->members.used > 0)
         burst_line[pos++] = ' ';
 
     /* dump the users */
@@ -720,32 +721,36 @@ irc_burst(struct chanNode *chan)
         if ((n+1)<chan->members.used)
             burst_line[pos++] = ',';
     }
+
+    /* dump the bans */
     if (chan->banlist.used) {
-        /* dump the bans */
-        if (pos+2+strlen(chan->banlist.list[0]->ban) > 505) {
-            burst_line[pos-1] = 0;
-            putsock("%s", burst_line);
-            pos = base_len;
-        } else {
+        first_ban = 1;
+
+        if (chan->members.used > 0)
             burst_line[pos++] = ' ';
-        }
 
-        burst_line[pos++] = ':';
-        burst_line[pos++] = '%';
-        base_len = pos;
-        for (n=0; n<chan->banlist.used; n++) {
+        for (n=0; n<chan->banlist.used; ) {
+            if (first_ban && (pos < 500)) {
+                burst_line[pos++] = ':';
+                burst_line[pos++] = '%';
+            }
             bn = chan->banlist.list[n];
             len = strlen(bn->ban);
-            if (pos+len+1 > 510) {
-                burst_line[pos-1] = 0; /* -1 to back up over the space or comma */
+            if (pos + 2 + len < 505) {
+                memcpy(burst_line + pos, bn->ban, len);
+                pos += len;
+                burst_line[pos++] = ' ';
+                first_ban = 0;
+                n++;
+            } else {
+                burst_line[pos-1] = 0;
                 putsock("%s", burst_line);
                 pos = base_len;
+                first_ban = 1;
             }
-            memcpy(burst_line+pos, bn->ban, len);
-            pos += len;
-            burst_line[pos++] = ' ';
         }
     }
+
     /* print the last line */
     burst_line[pos] = 0;
     putsock("%s", burst_line);