# HG changeset patch # User jbe # Date 1497274707 -7200 # Node ID c78bb327ef6ad39d72e367daf152446c9546211b # Parent b355e259c81e813eef6fab2cb767ee21134fed53 Code-cleanup: removed redundancy in moonbr_initiate_shutdown() diff -r b355e259c81e -r c78bb327ef6a moonbridge.c --- a/moonbridge.c Mon Jun 12 15:28:33 2017 +0200 +++ b/moonbridge.c Mon Jun 12 15:38:27 2017 +0200 @@ -1133,6 +1133,8 @@ /* Sets global variable 'moonbr_shutdown_in_progress', closes listeners, and demands worker termination */ static void moonbr_initiate_shutdown() { struct moonbr_pool *pool; + int i; + struct moonbr_worker *worker; if (moonbr_shutdown_in_progress) { moonbr_log(LOG_NOTICE, "Shutdown already in progress"); return; @@ -1140,7 +1142,6 @@ moonbr_shutdown_in_progress = 1; moonbr_log(LOG_NOTICE, "Initiate shutdown"); for (pool = moonbr_first_pool; pool; pool = pool->next_pool) { - int i; for (i=0; ilistener_count; i++) { struct moonbr_listener *listener = &pool->listener[i]; if (listener->listenfd != -1) { @@ -1150,10 +1151,6 @@ } } } - } - moonbr_poll_shutdown(); /* avoids loops due to error condition when polling closed listeners */ - for (pool=moonbr_first_pool; pool; pool=pool->next_pool) { - struct moonbr_worker *worker; for (worker=pool->first_worker; worker; worker=worker->next_worker) { if (moonbr_debug) { moonbr_log(LOG_DEBUG, "Sending SIGTERM to child with PID %i", (int)worker->pid); @@ -1163,6 +1160,7 @@ } } } + moonbr_poll_shutdown(); /* avoids loops due to error condition when polling closed listeners */ }