summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-02-04 00:19:40 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2019-02-04 02:25:48 -0500
commitaa34dfd32ba380eab11596156c762d1f882de1c2 (patch)
treedd54afd55cb8828c4206c39e6824e7f28d26e5cc
parentfb9b8ad8ae515ac1568b49d46ffc2775d15d1e0e (diff)
downloadlighttpd1.4-aa34dfd32ba380eab11596156c762d1f882de1c2.tar.gz
lighttpd1.4-aa34dfd32ba380eab11596156c762d1f882de1c2.zip
[core] some server_main_loop() cleanup
-rw-r--r--src/server.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/server.c b/src/server.c
index 11c0332b..a2f376d0 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1977,6 +1977,12 @@ static int server_main_loop (server * const srv) {
if (graceful_shutdown) {
server_graceful_state(srv);
srv->sockets_disabled = 1;
+ if (srv->conns->used == 0) {
+ /* we are in graceful shutdown phase and all connections are closed
+ * we are ready to terminate without harming anyone */
+ srv_shutdown = 1;
+ break;
+ }
} else if (srv->sockets_disabled) {
/* our server sockets are disabled, why ? */
@@ -2003,13 +2009,6 @@ static int server_main_loop (server * const srv) {
}
}
- if (graceful_shutdown && srv->conns->used == 0) {
- /* we are in graceful shutdown phase and all connections are closed
- * we are ready to terminate without harming anyone */
- srv_shutdown = 1;
- break;
- }
-
/* we still have some fds to share */
if (srv->want_fds) {
/* check the fdwaitqueue for waiting fds */
@@ -2061,26 +2060,6 @@ static int server_main_loop (server * const srv) {
srv->joblist->used = 0;
}
- if (graceful_shutdown || graceful_restart) {
- server_graceful_state(srv);
- }
-
- if (2 == graceful_shutdown) { /* value 2 indicates idle timeout */
- log_error_write(srv, __FILE__, __LINE__, "s",
- "server stopped after idle timeout");
- } else {
-#ifdef HAVE_SIGACTION
- log_error_write(srv, __FILE__, __LINE__, "sdsd",
- "server stopped by UID =",
- last_sigterm_info.si_uid,
- "PID =",
- last_sigterm_info.si_pid);
-#else
- log_error_write(srv, __FILE__, __LINE__, "s",
- "server stopped");
-#endif
- }
-
return 0;
}
@@ -2111,7 +2090,27 @@ int main (int argc, char **argv) {
}
rc = server_main(srv, argc, argv);
- if (rc > 0) rc = server_main_loop(srv);
+ if (rc > 0 && 0 == (rc = server_main_loop(srv))) {
+ if (graceful_shutdown || graceful_restart) {
+ server_graceful_state(srv);
+ }
+
+ if (2 == graceful_shutdown) { /* value 2 indicates idle timeout */
+ log_error_write(srv, __FILE__, __LINE__, "s",
+ "server stopped after idle timeout");
+ } else {
+ #ifdef HAVE_SIGACTION
+ log_error_write(srv, __FILE__, __LINE__, "sdsd",
+ "server stopped by UID =",
+ last_sigterm_info.si_uid,
+ "PID =",
+ last_sigterm_info.si_pid);
+ #else
+ log_error_write(srv, __FILE__, __LINE__, "s",
+ "server stopped");
+ #endif
+ }
+ }
/* clean-up */
remove_pid_file(srv);