]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mworker: displays more information when leaving
authorWilliam Lallemand <wlallemand@haproxy.com>
Tue, 6 Nov 2018 16:37:13 +0000 (17:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 6 Nov 2018 17:28:33 +0000 (18:28 +0100)
When a worker is leaving, we display the relative PID and the result of
the strsignal() function if it was killed by a signal.

src/haproxy.c

index 741aa7a386b33f7d05f846b3e270e70c01f72d42..6c4fe4448c8d8a5255688fe4eb7ea52f43fd7be3 100644 (file)
@@ -815,32 +815,33 @@ restart_wait:
 
                        LIST_DEL(&child->list);
                        close(child->ipc_fd[0]);
-                       free(child);
                        break;
                }
 
                if (!children) {
-                       ha_warning("Worker %d exited with code %d\n", exitpid, status);
+                       ha_warning("Worker %d exited with code %d (%s)\n", exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
                } else {
                        /* check if exited child was in the current children list */
                        if (current_child(exitpid)) {
-                               ha_alert("Current worker %d exited with code %d\n", exitpid, status);
+                               ha_alert("Current worker #%d (%d) exited with code %d (%s)\n", child->relative_pid, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
                                if (status != 0 && status != 130 && status != 143
                                    && !(global.tune.options & GTUNE_NOEXIT_ONFAILURE)) {
                                        ha_alert("exit-on-failure: killing every workers with SIGTERM\n");
                                        mworker_kill(SIGTERM);
                                }
                        } else {
-                               ha_warning("Former worker %d exited with code %d\n", exitpid, status);
+                               ha_warning("Former worker #%d (%d) exited with code %d (%s)\n", child->relative_pid, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
                                delete_oldpid(exitpid);
                        }
                }
+               free(child);
+
                /* do it again to check if it was the last worker */
                goto restart_wait;
        }
        /* Better rely on the system than on a list of process to check if it was the last one */
        else if (exitpid == -1 && errno == ECHILD) {
-               ha_warning("All workers exited. Exiting... (%d)\n", status);
+               ha_warning("All workers exited. Exiting... (%d)\n", (exitcode > 0) ? exitcode : status);
                atexit_flag = 0;
                exit(status); /* parent must leave using the latest status code known */
        }