mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-08 02:01:33 +00:00
CLEANUP: mworker: use the proxy helper functions in mworker_cli_proxy_create()
Cleanup the mworker_cli_proxy_create() function by removing the allocation and init of the proxy which is done manually, and replace it by alloc_new_proxy(). Do the same with the free_proxy() function. This patch also move the insertion at the end of the function.
This commit is contained in:
parent
e7f74623e4
commit
ae787bad80
28
src/cli.c
28
src/cli.c
@ -2675,16 +2675,11 @@ int mworker_cli_proxy_create()
|
|||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
char *errmsg = NULL;
|
char *errmsg = NULL;
|
||||||
|
|
||||||
mworker_proxy = calloc(1, sizeof(*mworker_proxy));
|
mworker_proxy = alloc_new_proxy("MASTER", PR_CAP_LISTEN|PR_CAP_INT, &errmsg);
|
||||||
if (!mworker_proxy)
|
if (!mworker_proxy)
|
||||||
return -1;
|
goto error_proxy;
|
||||||
|
|
||||||
init_new_proxy(mworker_proxy);
|
|
||||||
mworker_proxy->next = proxies_list;
|
|
||||||
proxies_list = mworker_proxy;
|
|
||||||
mworker_proxy->id = strdup("MASTER");
|
|
||||||
mworker_proxy->mode = PR_MODE_CLI;
|
mworker_proxy->mode = PR_MODE_CLI;
|
||||||
mworker_proxy->last_change = now.tv_sec;
|
|
||||||
mworker_proxy->cap = PR_CAP_LISTEN | PR_CAP_INT; /* this is a listen section */
|
mworker_proxy->cap = PR_CAP_LISTEN | PR_CAP_INT; /* this is a listen section */
|
||||||
mworker_proxy->maxconn = 10; /* default to 10 concurrent connections */
|
mworker_proxy->maxconn = 10; /* default to 10 concurrent connections */
|
||||||
mworker_proxy->timeout.client = 0; /* no timeout */
|
mworker_proxy->timeout.client = 0; /* no timeout */
|
||||||
@ -2697,11 +2692,6 @@ int mworker_cli_proxy_create()
|
|||||||
* the request parsing code */
|
* the request parsing code */
|
||||||
mworker_proxy->default_target = NULL;
|
mworker_proxy->default_target = NULL;
|
||||||
|
|
||||||
/* the check_config_validity() will get an ID for the proxy */
|
|
||||||
mworker_proxy->uuid = -1;
|
|
||||||
|
|
||||||
proxy_store_name(mworker_proxy);
|
|
||||||
|
|
||||||
/* create all servers using the mworker_proc list */
|
/* create all servers using the mworker_proc list */
|
||||||
list_for_each_entry(child, &proc_list, list) {
|
list_for_each_entry(child, &proc_list, list) {
|
||||||
struct server *newsrv = NULL;
|
struct server *newsrv = NULL;
|
||||||
@ -2750,22 +2740,26 @@ int mworker_cli_proxy_create()
|
|||||||
|
|
||||||
child->srv = newsrv;
|
child->srv = newsrv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mworker_proxy->next = proxies_list;
|
||||||
|
proxies_list = mworker_proxy;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
ha_alert("%s\n", errmsg);
|
|
||||||
|
|
||||||
list_for_each_entry(child, &proc_list, list) {
|
list_for_each_entry(child, &proc_list, list) {
|
||||||
free((char *)child->srv->conf.file); /* cast because of const char * */
|
free((char *)child->srv->conf.file); /* cast because of const char * */
|
||||||
free(child->srv->id);
|
free(child->srv->id);
|
||||||
ha_free(&child->srv);
|
ha_free(&child->srv);
|
||||||
}
|
}
|
||||||
free(mworker_proxy->id);
|
free_proxy(mworker_proxy);
|
||||||
free(mworker_proxy->conf.file);
|
|
||||||
ha_free(&mworker_proxy);
|
|
||||||
free(errmsg);
|
|
||||||
free(msg);
|
free(msg);
|
||||||
|
|
||||||
|
error_proxy:
|
||||||
|
ha_alert("%s\n", errmsg);
|
||||||
|
free(errmsg);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user