[svn] - rework comm_checktimeouts() to use the hashtable in an efficient manner.

This commit is contained in:
nenolod 2007-03-05 09:31:35 -08:00
parent c961476e55
commit d0e1e8ee78
3 changed files with 48 additions and 27 deletions

View file

@ -1,3 +1,12 @@
nenolod 2007/03/05 17:28:27 UTC (20070305-3233)
Log:
- clear up use of fd_table in ircd.
Changes: Modified:
+3 -2 trunk/src/s_serv.c (File Modified)
nenolod 2007/03/05 17:23:07 UTC (20070305-3229) nenolod 2007/03/05 17:23:07 UTC (20070305-3229)
Log: Log:
- use a hashtable for fdlist storage. first step to making the amount of allowed clients dynamic and removing MAXCONNECTIONS. - use a hashtable for fdlist storage. first step to making the amount of allowed clients dynamic and removing MAXCONNECTIONS.

View file

@ -1 +1 @@
#define SERNO "20070305-3229" #define SERNO "20070305-3233"

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA * USA
* *
* $Id: commio.c 3229 2007-03-05 17:23:07Z nenolod $ * $Id: commio.c 3235 2007-03-05 17:31:35Z nenolod $
*/ */
#include "libcharybdis.h" #include "libcharybdis.h"
@ -317,39 +317,51 @@ comm_setflush(int fd, time_t timeout, PF * callback, void *cbdata)
void void
comm_checktimeouts(void *notused) comm_checktimeouts(void *notused)
{ {
int fd;
PF *hdl; PF *hdl;
void *data; void *data;
fde_t *F; fde_t *F;
for (fd = 0; fd <= highest_fd; fd++) dlink_list *bucket;
int i;
dlink_node *n, *n2;
for (i = 0; i <= FD_HASH_SIZE; i)
{ {
F = comm_locate_fd(fd); bucket = &fd_table[i];
if(F == NULL)
continue; if (dlink_list_length(bucket) <= 0)
if(!F->flags.open)
continue;
if(F->flags.closing)
continue; continue;
/* check flush functions */ DLINK_FOREACH_SAFE(n, n2, bucket->head)
if(F->flush_handler &&
F->flush_timeout > 0 && F->flush_timeout < CurrentTime)
{ {
hdl = F->flush_handler; F = (fde_t *) n->data;
data = F->flush_data;
comm_setflush(F->fd, 0, NULL, NULL);
hdl(F->fd, data);
}
/* check timeouts */ if(F == NULL)
if(F->timeout_handler && continue;
F->timeout > 0 && F->timeout < CurrentTime) if(!F->flags.open)
{ continue;
/* Call timeout handler */ if(F->flags.closing)
hdl = F->timeout_handler; continue;
data = F->timeout_data;
comm_settimeout(F->fd, 0, NULL, NULL); /* check flush functions */
hdl(F->fd, data); if(F->flush_handler &&
F->flush_timeout > 0 && F->flush_timeout < CurrentTime)
{
hdl = F->flush_handler;
data = F->flush_data;
comm_setflush(F->fd, 0, NULL, NULL);
hdl(F->fd, data);
}
/* check timeouts */
if(F->timeout_handler &&
F->timeout > 0 && F->timeout < CurrentTime)
{
/* Call timeout handler */
hdl = F->timeout_handler;
data = F->timeout_data;
comm_settimeout(F->fd, 0, NULL, NULL);
hdl(F->fd, data);
}
} }
} }
} }