* $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"
#include "parse.h"
#include "packet.h"
#include "irc_string.h"
-#include "memory.h"
#include "hook.h"
#include "send.h"
if(client_p->localClient->sent_parsed >= client_p->localClient->allow_read)
break;
- dolen = linebuf_get(&client_p->localClient->
+ dolen = rb_linebuf_get(&client_p->localClient->
buf_recvq, readBuf, READBUF_SIZE,
LINEBUF_COMPLETE, LINEBUF_PARSED);
if(IsAnyServer(client_p) || IsExemptFlood(client_p))
{
- while (!IsAnyDead(client_p) && (dolen = linebuf_get(&client_p->localClient->buf_recvq,
+ while (!IsAnyDead(client_p) && (dolen = rb_linebuf_get(&client_p->localClient->buf_recvq,
readBuf, READBUF_SIZE, LINEBUF_COMPLETE,
LINEBUF_PARSED)) > 0)
{
else if(client_p->localClient->sent_parsed >= (4 * client_p->localClient->allow_read))
break;
- dolen = linebuf_get(&client_p->localClient->
+ dolen = rb_linebuf_get(&client_p->localClient->
buf_recvq, readBuf, READBUF_SIZE,
LINEBUF_COMPLETE, LINEBUF_PARSED);
client_p->localClient->sent_parsed = 0;
}
-/*
- * 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(int fd, void *data)
-{
- struct Client *client_p = data;
- struct LocalUser *lclient_p = client_p->localClient;
-
- /* This can happen in the event that the client detached. */
- if(!lclient_p)
- return;
-
- /* allow a bursting client their allocation per second, allow
- * a client whos flooding an extra 2 per second
- */
- if(IsFloodDone(client_p))
- lclient_p->sent_parsed -= 2;
- else
- lclient_p->sent_parsed = 0;
-
- if(lclient_p->sent_parsed < 0)
- lclient_p->sent_parsed = 0;
-
- if(--lclient_p->actually_read < 0)
- lclient_p->actually_read = 0;
-
- parse_client_queued(client_p);
-
- if(IsAnyDead(client_p))
- return;
-
- /* and finally, reset the flood check */
- comm_setflush(fd, 1000, flood_recalc, client_p);
+/*\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
}
/*
reply->datalen |= *len;
reply->gotdatalen++;
if(reply->datalen > 0)
- reply->data = MyMalloc(reply->datalen);
+ reply->data = rb_malloc(reply->datalen);
}
if(reply->gotdatalen < 2)
/* reset SlinkRpl */
if(reply->datalen > 0)
- MyFree(reply->data);
+ rb_free(reply->data);
reply->command = 0;
if(IsAnyDead(server))
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);
}
/*
{
if((length == -1) && ignoreErrno(errno))
{
- comm_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
+ rb_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
COMM_SELECT_READ, read_packet, client_p, 0);
return;
}
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;
/*
if(IsHandshake(client_p) || IsUnknown(client_p))
binary = 1;
- lbuf_len = 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;
/* Check to make sure we're not flooding */
if(!IsAnyServer(client_p) &&
- (linebuf_alloclen(&client_p->localClient->buf_recvq) > ConfigFileEntry.client_flood))
+ (rb_linebuf_alloclen(&client_p->localClient->buf_recvq) > ConfigFileEntry.client_flood))
{
if(!(ConfigFileEntry.no_oper_flood && IsOper(client_p)))
{
/* If we get here, we need to register for another COMM_SELECT_READ */
if(PARSE_AS_SERVER(client_p))
{
- comm_setselect(client_p->localClient->F->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->F->fd, FDLIST_IDLECLIENT,
+ rb_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
COMM_SELECT_READ, read_packet, client_p, 0);
}
}