mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-18 19:50:54 +00:00
CLEANUP: checks: make use of the post-init registration to start checks
Instead of calling the checks directly from the init code, we now register the start_checks() function to be run at this point. This also allows to unexport the check init function and to remove one include from haproxy.c.
This commit is contained in:
parent
e694573fa0
commit
865c5148e6
@ -27,7 +27,6 @@
|
||||
|
||||
const char *get_check_status_description(short check_status);
|
||||
const char *get_check_status_info(short check_status);
|
||||
int start_checks();
|
||||
void __health_adjust(struct server *s, short status);
|
||||
int trigger_resolution(struct server *s);
|
||||
|
||||
|
21
src/checks.c
21
src/checks.c
@ -2331,9 +2331,10 @@ static int start_check_task(struct check *check, int mininter,
|
||||
|
||||
/*
|
||||
* Start health-check.
|
||||
* Returns 0 if OK, -1 if error, and prints the error in this case.
|
||||
* Returns 0 if OK, ERR_FATAL on error, and prints the error in this case.
|
||||
*/
|
||||
int start_checks() {
|
||||
static int start_checks()
|
||||
{
|
||||
|
||||
struct proxy *px;
|
||||
struct server *s;
|
||||
@ -2352,7 +2353,7 @@ int start_checks() {
|
||||
if (s->slowstart) {
|
||||
if ((t = task_new()) == NULL) {
|
||||
Alert("Starting [%s:%s] check: out of memory.\n", px->id, s->id);
|
||||
return -1;
|
||||
return ERR_ALERT | ERR_FATAL;
|
||||
}
|
||||
/* We need a warmup task that will be called when the server
|
||||
* state switches from down to up.
|
||||
@ -2396,7 +2397,7 @@ int start_checks() {
|
||||
if ((px->options2 & PR_O2_CHK_ANY) == PR_O2_EXT_CHK) {
|
||||
if (init_pid_list()) {
|
||||
Alert("Starting [%s] check: out of memory.\n", px->id);
|
||||
return -1;
|
||||
return ERR_ALERT | ERR_FATAL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2405,17 +2406,17 @@ int start_checks() {
|
||||
if (s->check.state & CHK_ST_CONFIGURED) {
|
||||
if (s->check.type == PR_O2_EXT_CHK) {
|
||||
if (!prepare_external_check(&s->check))
|
||||
return -1;
|
||||
return ERR_ALERT | ERR_FATAL;
|
||||
}
|
||||
if (!start_check_task(&s->check, mininter, nbcheck, srvpos))
|
||||
return -1;
|
||||
return ERR_ALERT | ERR_FATAL;
|
||||
srvpos++;
|
||||
}
|
||||
|
||||
/* A task for a auxiliary agent check */
|
||||
if (s->agent.state & CHK_ST_CONFIGURED) {
|
||||
if (!start_check_task(&s->agent, mininter, nbcheck, srvpos)) {
|
||||
return -1;
|
||||
return ERR_ALERT | ERR_FATAL;
|
||||
}
|
||||
srvpos++;
|
||||
}
|
||||
@ -3455,6 +3456,12 @@ int srv_check_healthcheck_port(struct check *chk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((constructor))
|
||||
static void __check_init(void)
|
||||
{
|
||||
hap_register_post_check(start_checks);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
@ -89,7 +89,6 @@
|
||||
#include <proto/auth.h>
|
||||
#include <proto/backend.h>
|
||||
#include <proto/channel.h>
|
||||
#include <proto/checks.h>
|
||||
#include <proto/connection.h>
|
||||
#include <proto/fd.h>
|
||||
#include <proto/filters.h>
|
||||
@ -946,9 +945,6 @@ static void init(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (start_checks() < 0)
|
||||
exit(1);
|
||||
|
||||
list_for_each_entry(pcf, &post_check_list, list) {
|
||||
err_code |= pcf->fct();
|
||||
if (err_code & (ERR_ABORT|ERR_FATAL))
|
||||
|
Loading…
Reference in New Issue
Block a user