[eggheads-patches] PATCH1.4: fastdeq.patch

Florian Sander gquann at gmx.de
Sun Oct 24 13:44:55 CST 1999


Hi :)

This patch stacks as many cmds as possible.
(PRIVMSG #chan1,#chan2,#chan3....)

  bye

-- 
G`Quann at IRCNet
http://www.visions-of-fantasy.de
-------------- next part --------------
diff -rc eggdrop1.4/src/mod/server.mod/server.c patched1.4/src/mod/server.mod/server.c
*** eggdrop1.4/src/mod/server.mod/server.c	Tue Oct 12 12:28:27 1999
--- patched1.4/src/mod/server.mod/server.c	Sat Oct 16 18:52:24 1999
***************
*** 85,90 ****
--- 85,92 ----
  static time_t last_time = 0;
  static int use_penalties;
  #define MAXPENALTY 10
+ static int use_fastdeq;
+ static int fast_deq(int);
  
  #include "servmsg.c"
  
***************
*** 127,132 ****
--- 129,138 ----
    /* send upto 4 msgs to server if the *critical queue* has anything in it */
    if (modeq.head) {
      while (modeq.head && (burst < 4) && ((last_time - now) < MAXPENALTY)) {
+       if (fast_deq(DP_MODE)) {
+         burst++;
+         continue;
+       }
        tputs(serv, modeq.head->msg, modeq.head->len);
        if (debug_output) {
          putlog(LOG_SRVOUT, "*", "[m->] %s", modeq.head->msg);
***************
*** 148,153 ****
--- 154,161 ----
      return;
    if (mq.head) {
      burst++;
+     if (fast_deq(DP_SERVER))
+       return;
      tputs(serv, mq.head->msg, mq.head->len);
      if (debug_output) {
        putlog(LOG_SRVOUT, "*", "[s->] %s", mq.head->msg);
***************
*** 166,171 ****
--- 174,181 ----
     * finished */
    if (!hq.head || burst || !ok)
      return;
+   if (fast_deq(DP_HELP))
+     return;
    tputs(serv, hq.head->msg, hq.head->len);
    if (debug_output) {
      putlog(LOG_SRVOUT, "*", "[h->] %s", hq.head->msg);
***************
*** 307,312 ****
--- 317,414 ----
    return r;
  }
  
+ static int fast_deq(int which)
+ {
+   struct msgq_head *h;
+   struct msgq *m, *nm;
+   char msgstr[511], nextmsgstr[511], tosend[511], victims[511];
+   char *msg, *nextmsg, *cmd, *nextcmd, *to, *nextto;
+   int len, doit = 0;
+ 
+   context;
+   if (!use_fastdeq)
+     return 0;
+   switch (which) {
+     case DP_MODE:
+       h = &modeq;
+       break;
+     case DP_SERVER:
+       h = &mq;
+       break;
+     case DP_HELP:
+       h = &hq;
+       break;
+     default:  
+       return 0;
+   }
+   m = h->head;
+   strncpy(msgstr, m->msg, 510);
+   msgstr[510] = 0;
+   msg = msgstr;
+   cmd = newsplit(&msg);
+   to = newsplit(&msg);
+   len = strlen(to);
+   if (to[len - 1] == '\n')
+     to[len -1] = 0;
+   simple_sprintf(victims, "%s", to);
+   while (m) {
+     nm = m->next;
+     if (!nm)
+       break;
+     strncpy(nextmsgstr, nm->msg, 510);
+     nextmsgstr[510] = 0;
+     nextmsg = nextmsgstr;
+     nextcmd = newsplit(&nextmsg);
+     nextto = newsplit(&nextmsg);
+     len = strlen(nextto);
+     if (nextto[len-1] == '\n')
+       nextto[len-1] = 0;
+     if (!strcmp(cmd, nextcmd) && !strcmp(msg, nextmsg)
+         && ((strlen(cmd) + strlen(victims) + strlen(nextto) + strlen(msg) + 2) < 510)) {
+       simple_sprintf(victims, "%s,%s", victims, nextto);
+       doit = 1;
+       m->next = nm->next;
+       if (!nm->next)
+         h->last = m;
+       nfree(nm->msg);
+       nfree(nm);
+       h->tot--;
+     } else
+       m = m->next;
+   }
+   if (doit) {
+     simple_sprintf(tosend, "%s %s %s", cmd, victims, msg);
+     len = strlen(tosend);
+     tosend[len - 1] = '\n';
+     tputs(serv, tosend, len);
+     m = h->head->next;
+     nfree(h->head->msg);
+     nfree(h->head);
+     h->head = m;
+     if (!h->head)
+       h->last = 0;
+     h->tot--;
+     if (debug_output) {
+       tosend[len - 1] = 0;
+       switch (which) {
+         case DP_MODE:
+           putlog(LOG_SRVOUT, "*", "[m=>] %s", tosend);
+           break;
+         case DP_SERVER:
+           putlog(LOG_SRVOUT, "*", "[s=>] %s", tosend);
+           break;
+         case DP_HELP:
+           putlog(LOG_SRVOUT, "*", "[h=>] %s", tosend);
+           break;
+       }
+     }
+     last_time += calc_penalty(tosend);
+     return 1;
+   }
+   context;
+   return 0;
+ }
+ 
  /* clean out the msg queues (like when changing servers) */
  static void empty_msgq()
  {
***************
*** 776,781 ****
--- 878,884 ----
    {"double-server", &double_server, 0},
    {"double-help", &double_help, 0},
    {"use-penalties", &use_penalties, 0},
+   {"use-fastdeq", &use_fastdeq, 0},
    {0, 0, 0}
  };
  
***************
*** 1536,1541 ****
--- 1639,1645 ----
    double_server = 0;
    double_help = 0;
    use_penalties = 0;
+   use_fastdeq = 0;
    context;
    server_table[4] = (Function) botname;
    module_register(MODULE_NAME, server_table, 1, 0);


More information about the Patches mailing list