22 Jun 2008 01:13
[PATCH] Moved MaxSpareServers exceeded check into function
Since the MaxSpareServers check needs to lock the servers_waiting variable, moved the code into its own function and removed the need for two SERVER_COUNT_UNLOCK() calls. Signed-off-by: Robert James Kaes <rjk@...> --- src/child.c | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/child.c b/src/child.c index f8f56cb..f5f26ca 100644 --- a/src/child.c +++ b/src/child.c <at> <at> -159,6 +159,24 <at> <at> child_configure(child_config_t type, int val) return 0; } + +/* + * Check to see if the number of waiting servers exceeds the limit requested + * by the user. + */ +static inline int +is_maxspareservers_exceeded(void) +{ + int pred; + + SERVER_COUNT_LOCK(); + pred = *servers_waiting > child_config.maxspareservers; + SERVER_COUNT_UNLOCK(); + + return pred; +} + + /* * This is the main (per child) loop. */ <at> <at> -229,21 +247,12 <at> <at> child_main(struct child_s *ptr) } } - SERVER_COUNT_LOCK(); - if (*servers_waiting > child_config.maxspareservers) { - /* - * There are too many spare children, kill ourself - * off. - */ + /* Kill off the child if there are too many waiting servers */ + if (is_maxspareservers_exceeded()) { log_message(LOG_NOTICE, - "Waiting servers (%d) exceeds MaxSpareServers (%d). Killing child.", - *servers_waiting, + "Waiting servers exceeds MaxSpareServers (%d). Killing child.", child_config.maxspareservers); - SERVER_COUNT_UNLOCK(); - break; - } else { - SERVER_COUNT_UNLOCK(); } SERVER_INC(); -- -- 1.5.5.4
RSS Feed