浏览代码

* Reverted patch from 1.2 which disabled removing duplicate msgs in server queue. (Fixes most queue/excess flood bugs)

svn: 1970
Bryan Drewery 21 年之前
父节点
当前提交
608a33b059
共有 3 个文件被更改,包括 34 次插入0 次删除
  1. 1 0
      doc/UPDATES
  2. 4 0
      src/mod/server.mod/cmdsserv.c
  3. 29 0
      src/mod/server.mod/server.c

+ 1 - 0
doc/UPDATES

@@ -58,6 +58,7 @@ Lines prefixxed with '-' were disabled before release and are not finishsed, or
 * Fixed a bug with connecting to servers that did not send any data on connect.
 * Fixed a bug with connecting to servers that did not send any data on connect.
 * Fixed bot's not being able to link when the botnick case did not match (userlist vs binary -C).
 * Fixed bot's not being able to link when the botnick case did not match (userlist vs binary -C).
 * Fixed colors still showing for characters ":@()<>" when colors were turned off.
 * Fixed colors still showing for characters ":@()<>" when colors were turned off.
+* Reverted patch from 1.2 which disabled removing duplicate msgs in server queue. (Fixes most queue/excess flood bugs)
 
 
 1.2.2
 1.2.2
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.

+ 4 - 0
src/mod/server.mod/cmdsserv.c

@@ -85,6 +85,7 @@ static void cmd_clearqueue(int idx, char *par)
     msgq_clear(&mq);
     msgq_clear(&mq);
     msgq_clear(&hq);
     msgq_clear(&hq);
     burst = 0;
     burst = 0;
+    double_warned = 0;
     dprintf(idx, "Removed %d message%s from all queues.\n", msgs, 
     dprintf(idx, "Removed %d message%s from all queues.\n", msgs, 
         (msgs != 1) ? "s" : "");
         (msgs != 1) ? "s" : "");
   } else if (!egg_strcasecmp(par, "mode")) {
   } else if (!egg_strcasecmp(par, "mode")) {
@@ -92,11 +93,13 @@ static void cmd_clearqueue(int idx, char *par)
     msgq_clear(&modeq);
     msgq_clear(&modeq);
     if (mq.tot == 0)
     if (mq.tot == 0)
       burst = 0;
       burst = 0;
+    double_warned = 0;
     dprintf(idx, "Removed %d message%s from the mode queue.\n", msgs, 
     dprintf(idx, "Removed %d message%s from the mode queue.\n", msgs, 
         (msgs != 1) ? "s" : "");
         (msgs != 1) ? "s" : "");
   } else if (!egg_strcasecmp(par, "help")) {
   } else if (!egg_strcasecmp(par, "help")) {
     msgs = hq.tot;
     msgs = hq.tot;
     msgq_clear(&hq);
     msgq_clear(&hq);
+    double_warned = 0;
     dprintf(idx, "Removed %d message%s from the help queue.\n", msgs,
     dprintf(idx, "Removed %d message%s from the help queue.\n", msgs,
         (msgs != 1) ? "s" : "");
         (msgs != 1) ? "s" : "");
   } else if (!egg_strcasecmp(par, "server")) {
   } else if (!egg_strcasecmp(par, "server")) {
@@ -104,6 +107,7 @@ static void cmd_clearqueue(int idx, char *par)
     msgq_clear(&mq);
     msgq_clear(&mq);
     if (modeq.tot == 0)
     if (modeq.tot == 0)
       burst = 0;
       burst = 0;
+    double_warned = 0;
     dprintf(idx, "Removed %d message%s from the server queue.\n", msgs,
     dprintf(idx, "Removed %d message%s from the server queue.\n", msgs,
         (msgs != 1) ? "s" : "");
         (msgs != 1) ? "s" : "");
   } else {
   } else {

+ 29 - 0
src/mod/server.mod/server.c

@@ -71,6 +71,11 @@ static bool use_penalties;
 static int use_fastdeq;
 static int use_fastdeq;
 size_t nick_len = 9;			/* Maximal nick length allowed on the network. */
 size_t nick_len = 9;			/* Maximal nick length allowed on the network. */
 
 
+static bool double_mode = 0;		/* allow a msgs to be twice in a queue? */
+static bool double_server = 0;
+static bool double_help = 0;
+static bool double_warned = 0;
+
 static void empty_msgq(void);
 static void empty_msgq(void);
 static void next_server(int *, char *, port_t *, char *);
 static void next_server(int *, char *, port_t *, char *);
 static void disconnect_server(int, int);
 static void disconnect_server(int, int);
@@ -483,6 +488,7 @@ void queue_server(int which, char *buf, int len)
   struct msgq_head *h = NULL, tempq;
   struct msgq_head *h = NULL, tempq;
   struct msgq *q = NULL;
   struct msgq *q = NULL;
   int qnext = 0;
   int qnext = 0;
+  bool doublemsg = 0;
 
 
   switch (which) {
   switch (which) {
   case DP_MODE_NEXT:
   case DP_MODE_NEXT:
@@ -491,6 +497,8 @@ void queue_server(int which, char *buf, int len)
   case DP_MODE:
   case DP_MODE:
     h = &modeq;
     h = &modeq;
     tempq = modeq;
     tempq = modeq;
+    if (double_mode)
+      doublemsg = 1;
     break;
     break;
 
 
   case DP_SERVER_NEXT:
   case DP_SERVER_NEXT:
@@ -499,6 +507,8 @@ void queue_server(int which, char *buf, int len)
   case DP_SERVER:
   case DP_SERVER:
     h = &mq;
     h = &mq;
     tempq = mq;
     tempq = mq;
+    if (double_server)
+      doublemsg = 1;
     break;
     break;
 
 
   case DP_HELP_NEXT:
   case DP_HELP_NEXT:
@@ -507,6 +517,8 @@ void queue_server(int which, char *buf, int len)
   case DP_HELP:
   case DP_HELP:
     h = &hq;
     h = &hq;
     tempq = hq;
     tempq = hq;
+    if (double_help)
+      doublemsg = 1;
     break;
     break;
 
 
   default:
   default:
@@ -515,6 +527,22 @@ void queue_server(int which, char *buf, int len)
   }
   }
 
 
   if (h->tot < maxqmsg) {
   if (h->tot < maxqmsg) {
+    /* Don't queue msg if it's already queued?  */
+    if (!doublemsg) {
+      for (tq = tempq.head; tq; tq = tqq) {
+	tqq = tq->next;
+	if (!egg_strcasecmp(tq->msg, buf)) {
+	  if (!double_warned) {
+	    if (buf[len - 1] == '\n')
+	      buf[len - 1] = 0;
+	    debug1("msg already queued. skipping: %s", buf);
+	    double_warned = 1;
+	  }
+	  return;
+	}
+      }
+    }
+
     q = (struct msgq *) my_calloc(1, sizeof(struct msgq));
     q = (struct msgq *) my_calloc(1, sizeof(struct msgq));
     if (qnext)
     if (qnext)
       q->next = h->head;
       q->next = h->head;
@@ -533,6 +561,7 @@ void queue_server(int which, char *buf, int len)
     strlcpy(q->msg, buf, len + 1);
     strlcpy(q->msg, buf, len + 1);
     h->tot++;
     h->tot++;
     h->warned = 0;
     h->warned = 0;
+    double_warned = 0;
   } else {
   } else {
     if (!h->warned) {
     if (!h->warned) {
       switch (which) {   
       switch (which) {