static void tcpcheck_main(struct connection *);
static const struct check_status check_statuses[HCHK_STATUS_SIZE] = {
- [HCHK_STATUS_UNKNOWN] = { SRV_CHK_UNKNOWN, "UNK", "Unknown" },
- [HCHK_STATUS_INI] = { SRV_CHK_UNKNOWN, "INI", "Initializing" },
+ [HCHK_STATUS_UNKNOWN] = { CHK_RES_UNKNOWN, "UNK", "Unknown" },
+ [HCHK_STATUS_INI] = { CHK_RES_UNKNOWN, "INI", "Initializing" },
[HCHK_STATUS_START] = { /* SPECIAL STATUS*/ },
- [HCHK_STATUS_HANA] = { SRV_CHK_FAILED, "HANA", "Health analyze" },
+ [HCHK_STATUS_HANA] = { CHK_RES_FAILED, "HANA", "Health analyze" },
- [HCHK_STATUS_SOCKERR] = { SRV_CHK_FAILED, "SOCKERR", "Socket error" },
+ [HCHK_STATUS_SOCKERR] = { CHK_RES_FAILED, "SOCKERR", "Socket error" },
- [HCHK_STATUS_L4OK] = { SRV_CHK_PASSED, "L4OK", "Layer4 check passed" },
- [HCHK_STATUS_L4TOUT] = { SRV_CHK_FAILED, "L4TOUT", "Layer4 timeout" },
- [HCHK_STATUS_L4CON] = { SRV_CHK_FAILED, "L4CON", "Layer4 connection problem" },
+ [HCHK_STATUS_L4OK] = { CHK_RES_PASSED, "L4OK", "Layer4 check passed" },
+ [HCHK_STATUS_L4TOUT] = { CHK_RES_FAILED, "L4TOUT", "Layer4 timeout" },
+ [HCHK_STATUS_L4CON] = { CHK_RES_FAILED, "L4CON", "Layer4 connection problem" },
- [HCHK_STATUS_L6OK] = { SRV_CHK_PASSED, "L6OK", "Layer6 check passed" },
- [HCHK_STATUS_L6TOUT] = { SRV_CHK_FAILED, "L6TOUT", "Layer6 timeout" },
- [HCHK_STATUS_L6RSP] = { SRV_CHK_FAILED, "L6RSP", "Layer6 invalid response" },
+ [HCHK_STATUS_L6OK] = { CHK_RES_PASSED, "L6OK", "Layer6 check passed" },
+ [HCHK_STATUS_L6TOUT] = { CHK_RES_FAILED, "L6TOUT", "Layer6 timeout" },
+ [HCHK_STATUS_L6RSP] = { CHK_RES_FAILED, "L6RSP", "Layer6 invalid response" },
- [HCHK_STATUS_L7TOUT] = { SRV_CHK_FAILED, "L7TOUT", "Layer7 timeout" },
- [HCHK_STATUS_L7RSP] = { SRV_CHK_FAILED, "L7RSP", "Layer7 invalid response" },
+ [HCHK_STATUS_L7TOUT] = { CHK_RES_FAILED, "L7TOUT", "Layer7 timeout" },
+ [HCHK_STATUS_L7RSP] = { CHK_RES_FAILED, "L7RSP", "Layer7 invalid response" },
[HCHK_STATUS_L57DATA] = { /* DUMMY STATUS */ },
- [HCHK_STATUS_L7OKD] = { SRV_CHK_PASSED, "L7OK", "Layer7 check passed" },
- [HCHK_STATUS_L7OKCD] = { SRV_CHK_PASSED | SRV_CHK_DISABLE, "L7OKC", "Layer7 check conditionally passed" },
- [HCHK_STATUS_L7STS] = { SRV_CHK_FAILED, "L7STS", "Layer7 wrong status" },
+ [HCHK_STATUS_L7OKD] = { CHK_RES_PASSED, "L7OK", "Layer7 check passed" },
+ [HCHK_STATUS_L7OKCD] = { CHK_RES_CONDPASS, "L7OKC", "Layer7 check conditionally passed" },
+ [HCHK_STATUS_L7STS] = { CHK_RES_FAILED, "L7STS", "Layer7 wrong status" },
};
static const struct analyze_status analyze_statuses[HANA_STATUS_SIZE] = { /* 0: ignore, 1: error, 2: OK */
/*
* Set check->status, update check->duration and fill check->result with
- * an adequate SRV_CHK_* value.
+ * an adequate CHK_RES_* value.
*
* Show information in logs about failed health check if server is UP
* or succeeded health checks if server is DOWN.
struct server *s = check->server;
if (status == HCHK_STATUS_START) {
- check->result = SRV_CHK_UNKNOWN; /* no result yet */
+ check->result = CHK_RES_UNKNOWN; /* no result yet */
check->desc[0] = '\0';
check->start = now;
return;
return;
if (s->proxy->options2 & PR_O2_LOGHCHKS &&
- (((check->health != 0) && (check->result & SRV_CHK_FAILED)) ||
+ (((check->health != 0) && (check->result == CHK_RES_FAILED)) ||
(((check->health != check->rise + check->fall - 1) ||
(!s->uweight && !(s->state & SRV_DRAIN)) ||
(s->uweight && (s->state & SRV_DRAIN))) &&
- (check->result & SRV_CHK_PASSED)) ||
- ((s->state & SRV_GOINGDOWN) && !(check->result & SRV_CHK_DISABLE)) ||
- (!(s->state & SRV_GOINGDOWN) && (check->result & SRV_CHK_DISABLE)))) {
+ (check->result >= CHK_RES_PASSED)) ||
+ ((s->state & SRV_GOINGDOWN) && (check->result != CHK_RES_CONDPASS)) ||
+ (!(s->state & SRV_GOINGDOWN) && (check->result == CHK_RES_CONDPASS)))) {
int health, rise, fall, state;
fall = check->fall;
state = s->state;
- if (check->result & SRV_CHK_FAILED) {
+ switch (check->result) {
+ case CHK_RES_FAILED:
if (health > rise) {
health--; /* still good */
} else {
health = 0;
}
- }
+ break;
- if (check->result & SRV_CHK_PASSED) {
+ case CHK_RES_PASSED:
+ case CHK_RES_CONDPASS:
if (health < rise + fall - 1) {
health++; /* was bad, stays for a while */
/* clear consecutive_errors if observing is enabled */
if (s->onerror)
s->consecutive_errors = 0;
+ break;
+ default:
+ break;
}
- /* FIXME end: calculate local version of the health/rise/fall/state */
chunk_appendf(&trash,
"Health check for %sserver %s/%s %s%s",
s->state & SRV_BACKUP ? "backup " : "",
s->proxy->id, s->id,
- (check->result & SRV_CHK_DISABLE)?"conditionally ":"",
- (check->result & SRV_CHK_PASSED)?"succeeded":"failed");
+ (check->result == CHK_RES_CONDPASS) ? "conditionally ":"",
+ (check->result >= CHK_RES_PASSED) ? "succeeded":"failed");
server_status_printf(&trash, s, check, -1);
const char *err_msg;
struct chunk *chk;
- if (check->result != SRV_CHK_UNKNOWN)
+ if (check->result != CHK_RES_UNKNOWN)
return;
errno = errno_bck;
struct server *s = check->server;
struct task *t = check->task;
- if (unlikely(check->result & SRV_CHK_FAILED))
+ if (unlikely(check->result == CHK_RES_FAILED))
goto out_wakeup;
if (conn->flags & (CO_FL_HANDSHAKE | CO_FL_WAIT_WR))
int done;
unsigned short msglen;
- if (unlikely(check->result & SRV_CHK_FAILED))
+ if (unlikely(check->result == CHK_RES_FAILED))
goto out_wakeup;
if (conn->flags & (CO_FL_HANDSHAKE | CO_FL_WAIT_RD))
conn->xprt->shutw(conn, 0);
/* OK, let's not stay here forever */
- if (check->result & SRV_CHK_FAILED)
+ if (check->result == CHK_RES_FAILED)
conn->flags |= CO_FL_ERROR;
__conn_data_stop_both(conn);
task_wakeup(check->task, TASK_WOKEN_IO);
}
- if (check->result & (SRV_CHK_FAILED|SRV_CHK_PASSED)) {
+ if (check->result != CHK_RES_UNKNOWN) {
/* We're here because nobody wants to handle the error, so we
* sure want to abort the hard way.
*/
* First, let's check whether there was an uncaught error,
* which can happen on connect timeout or error.
*/
- if (s->check.result == SRV_CHK_UNKNOWN) {
+ if (s->check.result == CHK_RES_UNKNOWN) {
/* good connection is enough for pure TCP check */
if ((conn->flags & CO_FL_CONNECTED) && !check->type) {
if (check->use_ssl)
conn_force_close(conn);
}
- if (check->result & SRV_CHK_FAILED) /* a failure or timeout detected */
+ if (check->result == CHK_RES_FAILED) /* a failure or timeout detected */
check_failed(check);
else { /* check was OK */
/* we may have to add/remove this server from the LB group */
if ((s->state & SRV_RUNNING) && (s->proxy->options & PR_O_DISABLE404)) {
- if ((s->state & SRV_GOINGDOWN) && !(check->result & SRV_CHK_DISABLE))
+ if ((s->state & SRV_GOINGDOWN) && (check->result != CHK_RES_CONDPASS))
set_server_enabled(check);
- else if (!(s->state & SRV_GOINGDOWN) && (check->result & SRV_CHK_DISABLE))
+ else if (!(s->state & SRV_GOINGDOWN) && (check->result == CHK_RES_CONDPASS))
set_server_disabled(check);
}
}
/* here, we know that the connection is established */
- if (check->result & (SRV_CHK_FAILED | SRV_CHK_PASSED)) {
+ if (check->result != CHK_RES_UNKNOWN)
goto out_end_tcpcheck;
- }
/* head is be the first element of the double chained list */
head = &s->proxy->tcpcheck_rules;
check->current_step = cur;
} /* end 'send' */
else if (check->current_step->action == TCPCHK_ACT_EXPECT) {
- if (unlikely(check->result & SRV_CHK_FAILED))
+ if (unlikely(check->result == CHK_RES_FAILED))
goto out_end_tcpcheck;
if ((conn->flags & CO_FL_WAIT_RD) ||
check->current_step = NULL;
- if (check->result & SRV_CHK_FAILED)
+ if (check->result == CHK_RES_FAILED)
conn->flags |= CO_FL_ERROR;
__conn_data_stop_both(conn);