Author: tjansen Date: Thu Oct 15 15:15:25 2009 New Revision: 1169 Log: Switched timeout checking in the client over to the scheduler. Modified: trunk/pisacd/cdmain.c trunk/pisacd/cdtimeout.c trunk/pisacd/cdtimeout.h Modified: trunk/pisacd/cdmain.c ============================================================================== --- trunk/pisacd/cdmain.c Thu Oct 15 15:12:23 2009 (r1168) +++ trunk/pisacd/cdmain.c Thu Oct 15 15:15:25 2009 (r1169) @@ -277,6 +277,8 @@ pisa_sched_init(&cd_ctx.scheduler); pisa_sched_add_now(pisa_task_heartbeat, NULL); pisa_sched_add_now(pisa_task_pending, NULL); + if (cd_cfg.idle_disconnect_delay > 0) + pisa_sched_add_now(pisa_task_timeout, NULL); } static void cd_deinit(void) @@ -347,10 +349,6 @@ select_to.tv_sec = 1; select_to.tv_usec = 0; - /* deregister idle connections after a timeout */ - if (cd_cfg.idle_disconnect_delay > 0) - pisa_cd_timeout_collect(); - /* sockets.tunnel needs to be always included in the reading fd list */ FD_ZERO(&readfds); FD_SET(cd_ctx.tunnel, &readfds); Modified: trunk/pisacd/cdtimeout.c ============================================================================== --- trunk/pisacd/cdtimeout.c Thu Oct 15 15:12:23 2009 (r1168) +++ trunk/pisacd/cdtimeout.c Thu Oct 15 15:15:25 2009 (r1169) @@ -14,6 +14,7 @@ #include "cdctx.h" #include "cdconf.h" #include "cdderegister.h" +#include "scheduler.h" /** * Check if a connection was idle for too long and disconnect. @@ -38,16 +39,15 @@ } /** - * Disconnect idle connections. Only check every 10 seconds for it. + * Disconnect idle connections. Checked every second. */ -void pisa_cd_timeout_collect(void) +void pisa_task_timeout(void *data) { - static time_t last = 0; + struct timeval delay = {1, 0}; time_t current; time(¤t); - if (last + 10 < current) { - pisa_conmgr_iterate_connected(cd_ctx.conlist, pisa_cd_check_timeout, ¤t); - last = current; - } + pisa_conmgr_iterate_connected(cd_ctx.conlist, pisa_cd_check_timeout, ¤t); + + pisa_sched_add(pisa_task_timeout, &delay, NULL); } Modified: trunk/pisacd/cdtimeout.h ============================================================================== --- trunk/pisacd/cdtimeout.h Thu Oct 15 15:12:23 2009 (r1168) +++ trunk/pisacd/cdtimeout.h Thu Oct 15 15:15:25 2009 (r1169) @@ -6,6 +6,6 @@ #ifndef PISA_CDTIMEOUT_H #define PISA_CDTIMEOUT_H -void pisa_cd_timeout_collect(void); +void pisa_task_timeout(void *data); #endif /* PISA_CDTIMEOUT_H */