mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-16 16:34:42 +00:00
MEDIUM: cfgparse: Factor out check initialisation
This is in preparation for struct server having two elements of type struct check. Signed-off-by: Simon Horman <horms@verge.net.au>
This commit is contained in:
parent
4a741432be
commit
69d29f996b
@ -1620,6 +1620,34 @@ out:
|
|||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int init_check(struct check *check, int type, const char * file, int linenum)
|
||||||
|
{
|
||||||
|
check->type = type;
|
||||||
|
|
||||||
|
/* Allocate buffer for requests... */
|
||||||
|
if ((check->bi = calloc(sizeof(struct buffer) + global.tune.chksize, sizeof(char))) == NULL) {
|
||||||
|
Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum);
|
||||||
|
return ERR_ALERT | ERR_ABORT;
|
||||||
|
}
|
||||||
|
check->bi->size = global.tune.chksize;
|
||||||
|
|
||||||
|
/* Allocate buffer for responses... */
|
||||||
|
if ((check->bo = calloc(sizeof(struct buffer) + global.tune.chksize, sizeof(char))) == NULL) {
|
||||||
|
Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum);
|
||||||
|
return ERR_ALERT | ERR_ABORT;
|
||||||
|
}
|
||||||
|
check->bo->size = global.tune.chksize;
|
||||||
|
|
||||||
|
/* Allocate buffer for partial results... */
|
||||||
|
if ((check->conn = calloc(1, sizeof(struct connection))) == NULL) {
|
||||||
|
Alert("parsing [%s:%d] : out of memory while allocating check connection.\n", file, linenum);
|
||||||
|
return ERR_ALERT | ERR_ABORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
check->conn->t.sock.fd = -1; /* no agent in progress yet */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||||
{
|
{
|
||||||
@ -4273,6 +4301,9 @@ stats_error_parsing:
|
|||||||
|
|
||||||
newsrv->health = newsrv->rise; /* up, but will fall down at first failure */
|
newsrv->health = newsrv->rise; /* up, but will fall down at first failure */
|
||||||
|
|
||||||
|
newsrv->check.status = HCHK_STATUS_INI;
|
||||||
|
newsrv->check.server = newsrv;
|
||||||
|
|
||||||
cur_arg = 3;
|
cur_arg = 3;
|
||||||
} else {
|
} else {
|
||||||
newsrv = &curproxy->defsrv;
|
newsrv = &curproxy->defsrv;
|
||||||
@ -4832,6 +4863,8 @@ stats_error_parsing:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (do_check) {
|
if (do_check) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (newsrv->trackit) {
|
if (newsrv->trackit) {
|
||||||
Alert("parsing [%s:%d]: unable to enable checks and tracking at the same time!\n",
|
Alert("parsing [%s:%d]: unable to enable checks and tracking at the same time!\n",
|
||||||
file, linenum);
|
file, linenum);
|
||||||
@ -4877,33 +4910,14 @@ stats_error_parsing:
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate buffer for check requests... */
|
ret = init_check(&newsrv->check,
|
||||||
if ((newsrv->check.bi = calloc(sizeof(struct buffer) + global.tune.chksize, sizeof(char))) == NULL) {
|
curproxy->options2 & PR_O2_CHK_ANY,
|
||||||
Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum);
|
file, linenum);
|
||||||
err_code |= ERR_ALERT | ERR_ABORT;
|
if (ret) {
|
||||||
goto out;
|
err_code |= ret;
|
||||||
}
|
|
||||||
newsrv->check.bi->size = global.tune.chksize;
|
|
||||||
|
|
||||||
/* Allocate buffer for check responses... */
|
|
||||||
if ((newsrv->check.bo = calloc(sizeof(struct buffer) + global.tune.chksize, sizeof(char))) == NULL) {
|
|
||||||
Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum);
|
|
||||||
err_code |= ERR_ALERT | ERR_ABORT;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
newsrv->check.bo->size = global.tune.chksize;
|
|
||||||
|
|
||||||
/* Allocate buffer for partial check results... */
|
|
||||||
if ((newsrv->check.conn = calloc(1, sizeof(struct connection))) == NULL) {
|
|
||||||
Alert("parsing [%s:%d] : out of memory while allocating check connection.\n", file, linenum);
|
|
||||||
err_code |= ERR_ALERT | ERR_ABORT;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
newsrv->check.conn->t.sock.fd = -1; /* no check in progress yet */
|
|
||||||
newsrv->check.status = HCHK_STATUS_INI;
|
|
||||||
newsrv->check.type = curproxy->options2 & PR_O2_CHK_ANY;
|
|
||||||
newsrv->check.server = newsrv;
|
|
||||||
newsrv->state |= SRV_CHECKED;
|
newsrv->state |= SRV_CHECKED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user