[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)
Log:
- 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
* 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"
@ -317,39 +317,51 @@ comm_setflush(int fd, time_t timeout, PF * callback, void *cbdata)
void
comm_checktimeouts(void *notused)
{
int fd;
PF *hdl;
void *data;
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);
if(F == NULL)
continue;
if(!F->flags.open)
continue;
if(F->flags.closing)
bucket = &fd_table[i];
if (dlink_list_length(bucket) <= 0)
continue;
/* check flush functions */
if(F->flush_handler &&
F->flush_timeout > 0 && F->flush_timeout < CurrentTime)
DLINK_FOREACH_SAFE(n, n2, bucket->head)
{
hdl = F->flush_handler;
data = F->flush_data;
comm_setflush(F->fd, 0, NULL, NULL);
hdl(F->fd, data);
}
F = (fde_t *) n->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);
if(F == NULL)
continue;
if(!F->flags.open)
continue;
if(F->flags.closing)
continue;
/* check flush functions */
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);
}
}
}
}