mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MINOR: mworker: simplify the code that sets PROC_O_LEAVING
When master performs a reexec it should set for an already existed worker the flag PROC_O_LEAVING. It means that existed worked is marked as the previous one and will be terminated after the reload. In the previous implementation master process was need to do the reexec twice (the first time for parsing its configuration and the second time to free unused ressources). So the logic of setting PROC_O_LEAVING was based on comparing the number of reloads, performed by each process from the processes list, except the master. Now, as being mentioned before, reexec is performed only once. So, in this case we need to set PROC_O_LEAVING flag, when we deserialize the list. It is done for all processes, which have the number of reloads stricly positive.
This commit is contained in:
parent
c8aac63893
commit
154848a314
@ -839,7 +839,10 @@ void mworker_reload(int hardreload)
|
||||
list_for_each_entry(ptdf, &per_thread_deinit_list, list)
|
||||
ptdf->fct();
|
||||
|
||||
/* increment the number of reloads */
|
||||
/* increment the number of reloads, child->reloads is checked in
|
||||
* mworker_env_to_proc_list() (after reload) in order to set
|
||||
* PROC_O_LEAVING flag for the process
|
||||
*/
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
child->reloads++;
|
||||
}
|
||||
|
@ -115,7 +115,6 @@ void mworker_proc_list_to_env()
|
||||
{
|
||||
char *msg = NULL;
|
||||
struct mworker_proc *child;
|
||||
int minreloads = INT_MAX; /* minimum number of reloads to chose which processes are "current" ones */
|
||||
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
char type = '?';
|
||||
@ -127,22 +126,11 @@ void mworker_proc_list_to_env()
|
||||
else if (child->options &= PROC_O_TYPE_WORKER)
|
||||
type = 'w';
|
||||
|
||||
if (child->reloads < minreloads)
|
||||
minreloads = child->reloads;
|
||||
|
||||
if (child->pid > -1)
|
||||
memprintf(&msg, "%s|type=%c;fd=%d;cfd=%d;pid=%d;reloads=%d;failedreloads=%d;timestamp=%d;id=%s;version=%s", msg ? msg : "", type, child->ipc_fd[0], child->ipc_fd[1], child->pid, child->reloads, child->failedreloads, child->timestamp, child->id ? child->id : "", child->version);
|
||||
}
|
||||
if (msg)
|
||||
setenv("HAPROXY_PROCESSES", msg, 1);
|
||||
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
if (child->reloads > minreloads && !(child->options & PROC_O_TYPE_MASTER)) {
|
||||
child->options |= PROC_O_LEAVING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
struct mworker_proc *mworker_proc_new()
|
||||
@ -172,7 +160,6 @@ int mworker_env_to_proc_list()
|
||||
{
|
||||
char *env, *msg, *omsg = NULL, *token = NULL, *s1;
|
||||
struct mworker_proc *child;
|
||||
int minreloads = INT_MAX; /* minimum number of reloads to chose which processes are "current" ones */
|
||||
int err = 0;
|
||||
|
||||
env = getenv("HAPROXY_PROCESSES");
|
||||
@ -229,9 +216,6 @@ int mworker_env_to_proc_list()
|
||||
} else if (strncmp(subtoken, "reloads=", 8) == 0) {
|
||||
/* we only increment the number of asked reload */
|
||||
child->reloads = atoi(subtoken+8);
|
||||
|
||||
if (child->reloads < minreloads)
|
||||
minreloads = child->reloads;
|
||||
} else if (strncmp(subtoken, "failedreloads=", 14) == 0) {
|
||||
child->failedreloads = atoi(subtoken+14);
|
||||
} else if (strncmp(subtoken, "timestamp=", 10) == 0) {
|
||||
@ -252,7 +236,7 @@ int mworker_env_to_proc_list()
|
||||
/* set the leaving processes once we know which number of reloads are the current processes */
|
||||
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
if (child->reloads > minreloads)
|
||||
if (child->reloads > 0)
|
||||
child->options |= PROC_O_LEAVING;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user