]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/packet.c
ok, trying to work on blockheap's stuff
[irc/rqf/shadowircd.git] / src / packet.c
index 7c8c87fd91428d11a18d0d01bb056eb14468c668..d8afef07ad204611889fe29a41b9de5dfdfad2f9 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: packet.c 262 2005-09-22 00:38:45Z jilles $
+ *  $Id: packet.c 3446 2007-05-14 22:21:16Z jilles $
  */
 #include "stdinc.h"
-#include "tools.h"
-#include "commio.h"
 #include "s_conf.h"
 #include "s_serv.h"
 #include "client.h"
@@ -34,7 +32,6 @@
 #include "parse.h"
 #include "packet.h"
 #include "irc_string.h"
-#include "memory.h"
 #include "hook.h"
 #include "send.h"
 
@@ -56,12 +53,9 @@ parse_client_queued(struct Client *client_p)
 
        if(IsUnknown(client_p))
        {
-               int i = 0;
-
                for (;;)
                {
-                       /* rate unknown clients at MAX_FLOOD per loop */
-                       if(i >= MAX_FLOOD)
+                       if(client_p->localClient->sent_parsed >= client_p->localClient->allow_read)
                                break;
 
                        dolen = linebuf_get(&client_p->localClient->
@@ -72,7 +66,7 @@ parse_client_queued(struct Client *client_p)
                                break;
 
                        client_dopacket(client_p, readBuf, dolen);
-                       i++;
+                       client_p->localClient->sent_parsed++;
 
                        /* He's dead cap'n */
                        if(IsAnyDead(client_p))
@@ -81,7 +75,13 @@ parse_client_queued(struct Client *client_p)
                         * to the parsing for their appropriate status.  --fl
                         */
                        if(!IsUnknown(client_p))
+                       {
+                               /* reset their flood limits, they're now
+                                * graced to flood
+                                */
+                               client_p->localClient->sent_parsed = 0;
                                break;
+                       }
 
                }
        }
@@ -201,7 +201,7 @@ flood_recalc(int fd, void *data)
                return;
 
        /* and finally, reset the flood check */
-       comm_setflush(fd, 1000, flood_recalc, client_p);
+       rb_setflush(fd, 1000, flood_recalc, client_p);
 }
 
 /*
@@ -282,7 +282,7 @@ read_ctrl_packet(int fd, void *data)
                        reply->datalen |= *len;
                        reply->gotdatalen++;
                        if(reply->datalen > 0)
-                               reply->data = MyMalloc(reply->datalen);
+                               reply->data = rb_malloc(reply->datalen);
                }
 
                if(reply->gotdatalen < 2)
@@ -319,7 +319,7 @@ read_ctrl_packet(int fd, void *data)
 
        /* reset SlinkRpl */
        if(reply->datalen > 0)
-               MyFree(reply->data);
+               rb_free(reply->data);
        reply->command = 0;
 
        if(IsAnyDead(server))
@@ -327,7 +327,7 @@ read_ctrl_packet(int fd, void *data)
 
       nodata:
        /* If we get here, we need to register for another COMM_SELECT_READ */
-       comm_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ, read_ctrl_packet, server, 0);
+       rb_setselect(fd, FDLIST_SERVER, COMM_SELECT_READ, read_ctrl_packet, server, 0);
 }
 
 /*
@@ -353,13 +353,13 @@ read_packet(int fd, void *data)
         * I personally think it makes the code too hairy to make sane.
         *     -- adrian
         */
-       length = read(client_p->localClient->fd, readBuf, READBUF_SIZE);
+       length = client_p->localClient->F->read_impl(client_p->localClient->F, readBuf, READBUF_SIZE);
 
        if(length <= 0)
        {
                if((length == -1) && ignoreErrno(errno))
                {
-                       comm_setselect(client_p->localClient->fd, FDLIST_IDLECLIENT,
+                       rb_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
                                       COMM_SELECT_READ, read_packet, client_p, 0);
                        return;
                }
@@ -374,8 +374,8 @@ read_packet(int fd, void *data)
        call_hook(h_iorecv_id, &hdata);
 #endif
 
-       if(client_p->localClient->lasttime < CurrentTime)
-               client_p->localClient->lasttime = CurrentTime;
+       if(client_p->localClient->lasttime < rb_current_time())
+               client_p->localClient->lasttime = rb_current_time();
        client_p->flags &= ~FLAGS_PINGSENT;
 
        /*
@@ -413,12 +413,12 @@ read_packet(int fd, void *data)
        /* If we get here, we need to register for another COMM_SELECT_READ */
        if(PARSE_AS_SERVER(client_p))
        {
-               comm_setselect(client_p->localClient->fd, FDLIST_SERVER, COMM_SELECT_READ,
+               rb_setselect(client_p->localClient->F->fd, FDLIST_SERVER, COMM_SELECT_READ,
                              read_packet, client_p, 0);
        }
        else
        {
-               comm_setselect(client_p->localClient->fd, FDLIST_IDLECLIENT,
+               rb_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
                               COMM_SELECT_READ, read_packet, client_p, 0);
        }
 }