Author: tjansen Date: Thu Oct 8 13:12:57 2009 New Revision: 1051 Log: Commented out several sleep() calls. Sleeping is not really a good idea in a single-threaded daemon, as we can't process any packets in that time. If we really have need for delayed/scheduled actions we should use a scheduler for that purpose. pisacd has something similar already in place for resending the PISA packets (see cdpending.c). As all occurrences of sleep are in preauth/handover code, they are just commented out for now until someone rewrites that code or it is removed altogether. These sleeps are suspected to cause the mysterious phenomenon that PISA from time to time does not process packets for 4-5 seconds. Modified: trunk/libpisa/dhcp.c trunk/pisacd/cdmain.c trunk/pisasd/sdmain.c Modified: trunk/libpisa/dhcp.c ============================================================================== --- trunk/libpisa/dhcp.c Thu Oct 8 12:43:48 2009 (r1050) +++ trunk/libpisa/dhcp.c Thu Oct 8 13:12:57 2009 (r1051) @@ -336,7 +336,9 @@ bytes = read(fd, &packet, sizeof(pisa_udp_dhcp_packet)); if (bytes < 0) { PISA_ERROR("couldn't read on raw listening socket -- ignoring\n"); - usleep(500000); /* possible down interface, looping condition */ +/* TODO: rewrite this code. Sleeping is not a recommended in a single-threaded + * application. -- Thomas */ +/* usleep(500000);*/ /* possible down interface, looping condition */ return -1; } Modified: trunk/pisacd/cdmain.c ============================================================================== --- trunk/pisacd/cdmain.c Thu Oct 8 12:43:48 2009 (r1050) +++ trunk/pisacd/cdmain.c Thu Oct 8 13:12:57 2009 (r1051) @@ -655,8 +655,10 @@ if (currentTime - init_pareq_period > cd_cfg.pareq_interval) { if (cd_ctx.pareq_tries_count > cd_cfg.pareq_maxretry) { /* PISA_INFO("WARNING: reached maximum preauth request count. Sleeping...\n");*/ -/* TODO: Is sleeping in a singlethreaded daemon a good idea? */ +/* TODO: Rewrite/remove handover/preauth code. Disabled sleep for now. + * -- Thomas sleep(5); +*/ /* PISA_INFO("Resetting tries count...\n");*/ cd_ctx.pareq_tries_count = 0; } @@ -888,6 +890,7 @@ #if 0 if (cd_ctx.pareq_tries_count > cd_cfg.pareq_maxretry) { PISA_INFO("WARNING: reached maximum client request count. Sleeping...\n"); +/* TODO: Rewrite/remove handover/preauth code. Do *NOT* use sleep */ sleep(5); PISA_INFO("Resetting tries count...\n"); cd_ctx.pareq_tries_count = 0; Modified: trunk/pisasd/sdmain.c ============================================================================== --- trunk/pisasd/sdmain.c Thu Oct 8 12:43:48 2009 (r1050) +++ trunk/pisasd/sdmain.c Thu Oct 8 13:12:57 2009 (r1051) @@ -609,7 +609,10 @@ if (sd_ctx.vreqtrg_tries_count > sd_cfg.vreqtrg_maxretry) { PISA_INFO("WARNING: reached maximum client request count. Sleeping...\n"); +/* TODO: Rewrite/remove handover/preauth code. Disabled sleep for now. + * -- Thomas sleep(5); + */ PISA_INFO("Resetting tries count...\n"); sd_ctx.vreqtrg_tries_count = 0; }