mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MINOR: mworker: allocate and initialize a mworker_proc
mworker_proc_new() allocates and initializes correctly a mworker_proc structure.
This commit is contained in:
parent
7e01878e45
commit
56be0e0146
@ -41,6 +41,7 @@ int mworker_ext_launch_all(void);
|
|||||||
|
|
||||||
void mworker_kill_max_reloads(int sig);
|
void mworker_kill_max_reloads(int sig);
|
||||||
|
|
||||||
|
struct mworker_proc *mworker_proc_new();
|
||||||
void mworker_free_child(struct mworker_proc *);
|
void mworker_free_child(struct mworker_proc *);
|
||||||
void mworker_cleanup_proc();
|
void mworker_cleanup_proc();
|
||||||
|
|
||||||
|
@ -1937,37 +1937,25 @@ static void init(int argc, char **argv)
|
|||||||
|
|
||||||
if (getenv("HAPROXY_MWORKER_REEXEC") == NULL) {
|
if (getenv("HAPROXY_MWORKER_REEXEC") == NULL) {
|
||||||
|
|
||||||
tmproc = calloc(1, sizeof(*tmproc));
|
tmproc = mworker_proc_new();
|
||||||
if (!tmproc) {
|
if (!tmproc) {
|
||||||
ha_alert("Cannot allocate process structures.\n");
|
ha_alert("Cannot allocate process structures.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
tmproc->options |= PROC_O_TYPE_MASTER; /* master */
|
tmproc->options |= PROC_O_TYPE_MASTER; /* master */
|
||||||
tmproc->failedreloads = 0;
|
|
||||||
tmproc->reloads = 0;
|
|
||||||
tmproc->pid = pid;
|
tmproc->pid = pid;
|
||||||
tmproc->timestamp = start_date.tv_sec;
|
tmproc->timestamp = start_date.tv_sec;
|
||||||
tmproc->ipc_fd[0] = -1;
|
|
||||||
tmproc->ipc_fd[1] = -1;
|
|
||||||
|
|
||||||
proc_self = tmproc;
|
proc_self = tmproc;
|
||||||
|
|
||||||
LIST_APPEND(&proc_list, &tmproc->list);
|
LIST_APPEND(&proc_list, &tmproc->list);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmproc = calloc(1, sizeof(*tmproc));
|
tmproc = mworker_proc_new();
|
||||||
if (!tmproc) {
|
if (!tmproc) {
|
||||||
ha_alert("Cannot allocate process structures.\n");
|
ha_alert("Cannot allocate process structures.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmproc->options |= PROC_O_TYPE_WORKER; /* worker */
|
tmproc->options |= PROC_O_TYPE_WORKER; /* worker */
|
||||||
tmproc->pid = -1;
|
|
||||||
tmproc->failedreloads = 0;
|
|
||||||
tmproc->reloads = 0;
|
|
||||||
tmproc->timestamp = -1;
|
|
||||||
tmproc->ipc_fd[0] = -1;
|
|
||||||
tmproc->ipc_fd[1] = -1;
|
|
||||||
|
|
||||||
if (mworker_cli_sockpair_new(tmproc, 0) < 0) {
|
if (mworker_cli_sockpair_new(tmproc, 0) < 0) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -128,6 +128,25 @@ void mworker_proc_list_to_env()
|
|||||||
setenv("HAPROXY_PROCESSES", msg, 1);
|
setenv("HAPROXY_PROCESSES", msg, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct mworker_proc *mworker_proc_new()
|
||||||
|
{
|
||||||
|
struct mworker_proc *child;
|
||||||
|
|
||||||
|
child = calloc(1, sizeof(*child));
|
||||||
|
if (!child)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
child->failedreloads = 0;
|
||||||
|
child->reloads = 0;
|
||||||
|
child->pid = -1;
|
||||||
|
child->ipc_fd[0] = -1;
|
||||||
|
child->ipc_fd[1] = -1;
|
||||||
|
child->timestamp = -1;
|
||||||
|
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* unserialize the proc list from the environment
|
* unserialize the proc list from the environment
|
||||||
*/
|
*/
|
||||||
@ -147,7 +166,7 @@ int mworker_env_to_proc_list()
|
|||||||
|
|
||||||
msg = NULL;
|
msg = NULL;
|
||||||
|
|
||||||
child = calloc(1, sizeof(*child));
|
child = mworker_proc_new();
|
||||||
if (!child) {
|
if (!child) {
|
||||||
ha_alert("Out of memory while trying to allocate a worker process structure.");
|
ha_alert("Out of memory while trying to allocate a worker process structure.");
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user