]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/packet.c
Add topic TS and channel TS constraints for /LIST.
[irc/rqf/shadowircd.git] / src / packet.c
index f7779ac3ff529267fd3f87e475202365aaaddfee..707ddbb5156da3288f4dab1b5e2191d0f26cb0a2 100644 (file)
@@ -21,7 +21,6 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: packet.c 3446 2007-05-14 22:21:16Z jilles $
  */
 #include "stdinc.h"
 #include "s_conf.h"
@@ -31,7 +30,7 @@
 #include "ircd.h"
 #include "parse.h"
 #include "packet.h"
-#include "irc_string.h"
+#include "match.h"
 #include "hook.h"
 #include "send.h"
 
@@ -99,7 +98,12 @@ parse_client_queued(struct Client *client_p)
        {
 
                if(IsOper(client_p) && ConfigFileEntry.no_oper_flood)
-                       checkflood = 0;
+               {
+                       if (ConfigFileEntry.true_no_oper_flood)
+                               checkflood = -1;
+                       else
+                               checkflood = 0;
+               }
                /*
                 * Handle flood protection here - if we exceed our flood limit on
                 * messages in this loop, we simply drop out of the loop prematurely.
@@ -129,7 +133,7 @@ parse_client_queued(struct Client *client_p)
                        /* allow opers 4 times the amount of messages as users. why 4?
                         * why not. :) --fl_
                         */
-                       else if(client_p->localClient->sent_parsed >= (4 * client_p->localClient->allow_read))
+                       else if(client_p->localClient->sent_parsed >= (4 * client_p->localClient->allow_read) && checkflood != -1)
                                break;
 
                        dolen = rb_linebuf_get(&client_p->localClient->
@@ -165,70 +169,70 @@ flood_endgrace(struct Client *client_p)
        client_p->localClient->sent_parsed = 0;
 }
 
-/*\r
- * flood_recalc\r
- *\r
- * recalculate the number of allowed flood lines. this should be called\r
- * once a second on any given client. We then attempt to flush some data.\r
- */\r
-void\r
-flood_recalc(void *unused)\r
-{\r
-       rb_dlink_node *ptr, *next;\r
-       struct Client *client_p;\r
-\r
-       RB_DLINK_FOREACH_SAFE(ptr, next, lclient_list.head)\r
-       {\r
-               client_p = ptr->data;\r
-\r
-               if(unlikely(IsMe(client_p)))\r
-                       continue;\r
-                       \r
-               if(unlikely(client_p->localClient == NULL))\r
-                       continue;\r
-               \r
-               if(IsFloodDone(client_p))\r
-                       client_p->localClient->sent_parsed -= 2;\r
-               else\r
-                       client_p->localClient->sent_parsed = 0;\r
-                       \r
-               if(client_p->localClient->sent_parsed < 0)\r
-                       client_p->localClient->sent_parsed = 0;\r
-\r
-               if(--client_p->localClient->actually_read < 0)\r
-                       client_p->localClient->actually_read = 0;\r
-\r
-               parse_client_queued(client_p);\r
-               \r
-               if(unlikely(IsAnyDead(client_p)))\r
-                       continue;\r
-\r
-       }\r
-\r
-       RB_DLINK_FOREACH_SAFE(ptr, next, unknown_list.head)\r
-       {\r
-               client_p = ptr->data;\r
-\r
-               if(client_p->localClient == NULL)\r
-                       continue;\r
-\r
-               client_p->localClient->sent_parsed--;\r
-\r
-               if(client_p->localClient->sent_parsed < 0)\r
-                       client_p->localClient->sent_parsed = 0;\r
-\r
-               if(--client_p->localClient->actually_read < 0)\r
-                       client_p->localClient->actually_read = 0;\r
-\r
-               parse_client_queued(client_p);\r
-       }\r
+/*
+ * flood_recalc
+ *
+ * recalculate the number of allowed flood lines. this should be called
+ * once a second on any given client. We then attempt to flush some data.
+ */
+void
+flood_recalc(void *unused)
+{
+       rb_dlink_node *ptr, *next;
+       struct Client *client_p;
+
+       RB_DLINK_FOREACH_SAFE(ptr, next, lclient_list.head)
+       {
+               client_p = ptr->data;
+
+               if(rb_unlikely(IsMe(client_p)))
+                       continue;
+                       
+               if(rb_unlikely(client_p->localClient == NULL))
+                       continue;
+               
+               if(IsFloodDone(client_p))
+                       client_p->localClient->sent_parsed -= 2;
+               else
+                       client_p->localClient->sent_parsed = 0;
+                       
+               if(client_p->localClient->sent_parsed < 0)
+                       client_p->localClient->sent_parsed = 0;
+
+               if(--client_p->localClient->actually_read < 0)
+                       client_p->localClient->actually_read = 0;
+
+               parse_client_queued(client_p);
+               
+               if(rb_unlikely(IsAnyDead(client_p)))
+                       continue;
+
+       }
+
+       RB_DLINK_FOREACH_SAFE(ptr, next, unknown_list.head)
+       {
+               client_p = ptr->data;
+
+               if(client_p->localClient == NULL)
+                       continue;
+
+               client_p->localClient->sent_parsed--;
+
+               if(client_p->localClient->sent_parsed < 0)
+                       client_p->localClient->sent_parsed = 0;
+
+               if(--client_p->localClient->actually_read < 0)
+                       client_p->localClient->actually_read = 0;
+
+               parse_client_queued(client_p);
+       }
 }
 
 /*
  * read_packet - Read a 'packet' of data from a connection and process it.
  */
 void
-read_packet(int fd, void *data)
+read_packet(rb_fde_t * F, void *data)
 {
        struct Client *client_p = data;
        struct LocalUser *lclient_p = client_p->localClient;
@@ -239,81 +243,83 @@ read_packet(int fd, void *data)
 #ifdef USE_IODEBUG_HOOKS
        hook_data_int hdata;
 #endif
-       if(IsAnyDead(client_p))
-               return;
-
-       /*
-        * Read some data. We *used to* do anti-flood protection here, but
-        * I personally think it makes the code too hairy to make sane.
-        *     -- adrian
-        */
-       length = client_p->localClient->F->read_impl(client_p->localClient->F, readBuf, READBUF_SIZE);
 
-       if(length <= 0)
+       while(1)
        {
-               if((length == -1) && ignoreErrno(errno))
+               if(IsAnyDead(client_p))
+                       return;
+
+               /*
+                * Read some data. We *used to* do anti-flood protection here, but
+                * I personally think it makes the code too hairy to make sane.
+                *     -- adrian
+                */
+               length = rb_read(client_p->localClient->F, readBuf, READBUF_SIZE);
+
+               if(length < 0)
                {
-                       rb_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
-                                      COMM_SELECT_READ, read_packet, client_p, 0);
+                       if(rb_ignore_errno(errno))
+                               rb_setselect(client_p->localClient->F, 
+                                               RB_SELECT_READ, read_packet, client_p);
+                       else
+                               error_exit_client(client_p, length);
+                       return;
+               }
+               else if(length == 0)
+               {
+                       error_exit_client(client_p, length);
                        return;
                }
-               error_exit_client(client_p, length);
-               return;
-       }
 
 #ifdef USE_IODEBUG_HOOKS
-       hdata.client = client_p;
-       hdata.arg1 = readBuf;
-       hdata.arg2 = length;
-       call_hook(h_iorecv_id, &hdata);
+               hdata.client = client_p;
+               hdata.arg1 = readBuf;
+               hdata.arg2 = length;
+               call_hook(h_iorecv_id, &hdata);
 #endif
 
-       if(client_p->localClient->lasttime < rb_current_time())
-               client_p->localClient->lasttime = rb_current_time();
-       client_p->flags &= ~FLAGS_PINGSENT;
+               if(client_p->localClient->lasttime < rb_current_time())
+                       client_p->localClient->lasttime = rb_current_time();
+               client_p->flags &= ~FLAGS_PINGSENT;
 
-       /*
-        * Before we even think of parsing what we just read, stick
-        * it on the end of the receive queue and do it when its
-        * turn comes around.
-        */
-       if(IsHandshake(client_p) || IsUnknown(client_p))
-               binary = 1;
+               /*
+                * Before we even think of parsing what we just read, stick
+                * it on the end of the receive queue and do it when its
+                * turn comes around.
+                */
+               if(IsHandshake(client_p) || IsUnknown(client_p))
+                       binary = 1;
 
-       lbuf_len = rb_linebuf_parse(&client_p->localClient->buf_recvq, readBuf, length, binary);
+               lbuf_len = rb_linebuf_parse(&client_p->localClient->buf_recvq, readBuf, length, binary);
 
-       lclient_p->actually_read += lbuf_len;
+               lclient_p->actually_read += lbuf_len;
 
-       if(IsAnyDead(client_p))
-               return;
-               
-       /* Attempt to parse what we have */
-       parse_client_queued(client_p);
+               if(IsAnyDead(client_p))
+                       return;
+                       
+               /* Attempt to parse what we have */
+               parse_client_queued(client_p);
 
-       if(IsAnyDead(client_p))
-               return;
-               
-       /* Check to make sure we're not flooding */
-       if(!IsAnyServer(client_p) &&
-          (rb_linebuf_alloclen(&client_p->localClient->buf_recvq) > ConfigFileEntry.client_flood))
-       {
-               if(!(ConfigFileEntry.no_oper_flood && IsOper(client_p)))
-               {
-                       exit_client(client_p, client_p, client_p, "Excess Flood");
+               if(IsAnyDead(client_p))
                        return;
+                       
+               /* Check to make sure we're not flooding */
+               if(!IsAnyServer(client_p) &&
+                  (rb_linebuf_alloclen(&client_p->localClient->buf_recvq) > ConfigFileEntry.client_flood))
+               {
+                       if(!(ConfigFileEntry.no_oper_flood && IsOper(client_p)))
+                       {
+                               exit_client(client_p, client_p, client_p, "Excess Flood");
+                               return;
+                       }
                }
-       }
 
-       /* If we get here, we need to register for another COMM_SELECT_READ */
-       if(PARSE_AS_SERVER(client_p))
-       {
-               rb_setselect(client_p->localClient->F->fd, FDLIST_SERVER, COMM_SELECT_READ,
-                             read_packet, client_p, 0);
-       }
-       else
-       {
-               rb_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
-                              COMM_SELECT_READ, read_packet, client_p, 0);
+               /* bail if short read */
+               if(length < READBUF_SIZE)
+               {
+                       rb_setselect(client_p->localClient->F, RB_SELECT_READ, read_packet, client_p);
+                       return;
+               }
        }
 }