mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-13 15:04:42 +00:00
MEDIUM: mworker: store the leaving state of a process
Previously we were assuming than a process was in a leaving state when its number of reload was greater than 0. With mworker programs it's not the case anymore so we need to store a leaving state.
This commit is contained in:
parent
9df86f997e
commit
4528611ed6
@ -180,6 +180,14 @@ struct global {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* options for mworker_proc */
|
||||
|
||||
#define PROC_O_TYPE_MASTER 0x00000001
|
||||
#define PROC_O_TYPE_WORKER 0x00000002
|
||||
#define PROC_O_TYPE_PROG 0x00000004
|
||||
/* 0x00000008 unused */
|
||||
#define PROC_O_LEAVING 0x00000010 /* this process should be leaving */
|
||||
|
||||
/*
|
||||
* Structure used to describe the processes in master worker mode
|
||||
*/
|
||||
@ -187,6 +195,7 @@ struct mworker_proc {
|
||||
int pid;
|
||||
char type; /* m(aster), w(orker) */
|
||||
/* 3 bytes hole here */
|
||||
int options;
|
||||
char *id;
|
||||
char **command;
|
||||
char *path;
|
||||
|
@ -66,7 +66,7 @@ int mworker_current_child(int pid)
|
||||
struct mworker_proc *child;
|
||||
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
if ((child->type == 'w' || child->type == 'e') && (child->reloads == 0) && (child->pid == pid))
|
||||
if ((child->type == 'w' || child->type == 'e') && (!(child->options & PROC_O_LEAVING)) && (child->pid == pid))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -156,6 +156,8 @@ void mworker_env_to_proc_list()
|
||||
free(child);
|
||||
|
||||
}
|
||||
/* this is a process inherited from a reload that should be leaving */
|
||||
child->options |= PROC_O_LEAVING;
|
||||
}
|
||||
|
||||
unsetenv("HAPROXY_PROCESSES");
|
||||
@ -246,7 +248,7 @@ restart_wait:
|
||||
ha_warning("Process %d exited with code %d (%s)\n", exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
|
||||
} else {
|
||||
/* check if exited child is a current child */
|
||||
if (child->reloads == 0) {
|
||||
if (!(child->options & PROC_O_LEAVING)) {
|
||||
if (child->type == 'w')
|
||||
ha_alert("Current worker #%d (%d) exited with code %d (%s)\n", child->relative_pid, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
|
||||
else if (child->type == 'e')
|
||||
@ -415,7 +417,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
if (child->type != 'w')
|
||||
continue;
|
||||
|
||||
if (child->reloads > 0) {
|
||||
if (child->options & PROC_O_LEAVING) {
|
||||
old++;
|
||||
continue;
|
||||
}
|
||||
@ -434,7 +436,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
if (child->type != 'w')
|
||||
continue;
|
||||
|
||||
if (child->reloads > 0) {
|
||||
if (child->options & PROC_O_LEAVING) {
|
||||
memprintf(&msg, "[was: %u]", child->relative_pid);
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %dd %02dh%02dm%02ds\n", child->pid, "worker", msg, child->reloads, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
}
|
||||
@ -451,7 +453,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
if (child->type != 'e')
|
||||
continue;
|
||||
|
||||
if (child->reloads > 0) {
|
||||
if (child->options & PROC_O_LEAVING) {
|
||||
old++;
|
||||
continue;
|
||||
}
|
||||
@ -466,7 +468,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
if (child->type != 'e')
|
||||
continue;
|
||||
|
||||
if (child->reloads > 0) {
|
||||
if (child->options & PROC_O_LEAVING) {
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %dd %02dh%02dm%02ds\n", child->pid, child->id, "-", child->reloads, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user