enum healthcheck_status tout = HCHK_STATUS_L7TOUT;
/* connection established but expired check */
- if (check->current_step && check->current_step->action == TCPCHK_ACT_EXPECT)
+ if (check->current_step && check->current_step->action == TCPCHK_ACT_EXPECT &&
+ check->current_step->expect.tout_status != HCHK_STATUS_UNKNOWN)
tout = check->current_step->expect.tout_status;
set_server_check_status(check, tout, err_msg);
}
* FIXME : it can be cool to use MySQL Version for other purpose,
* like mark as down old MySQL server.
*/
- set_server_check_status(check, rule->expect.ok_status, b_peek(&check->bi, 5));
+ status = ((rule->expect.ok_status != HCHK_STATUS_UNKNOWN) ? rule->expect.ok_status : HCHK_STATUS_L7OKD);
+ set_server_check_status(check, status, b_peek(&check->bi, 5));
out:
free_trash_chunk(msg);
goto error;
}
- set_server_check_status(check, rule->expect.ok_status, "Success");
+ status = ((rule->expect.ok_status != HCHK_STATUS_UNKNOWN) ? rule->expect.ok_status : HCHK_STATUS_L7OKD);
+ set_server_check_status(check, status, "Success");
out:
free_trash_chunk(msg);
goto error;
}
- set_server_check_status(check, rule->expect.ok_status, "SPOA server is ok");
+ status = ((rule->expect.ok_status != HCHK_STATUS_UNKNOWN) ? rule->expect.ok_status : HCHK_STATUS_L7OKD);
+ set_server_check_status(check, status, "SPOA server is ok");
out:
free_trash_chunk(msg);
goto wait_more_data;
}
if (is_empty) {
+ int status;
+
chunk_printf(&trash, "TCPCHK got an empty response at step %d",
tcpcheck_get_step_id(check, rule));
if (rule->comment)
chunk_appendf(&trash, " comment: '%s'", rule->comment);
- set_server_check_status(check, rule->expect.err_status, trash.area);
+
+ status = ((rule->expect.err_status != HCHK_STATUS_UNKNOWN) ? rule->expect.err_status : HCHK_STATUS_L7RSP);
+ set_server_check_status(check, status, trash.area);
goto stop;
}
}
}
/* Set status and description in case of error */
- status = HCHK_STATUS_L7STS;
- desc = htx_sl_res_reason(sl);
+ status = ((rule->expect.err_status != HCHK_STATUS_UNKNOWN) ? rule->expect.err_status : HCHK_STATUS_L7STS);
+ if (LIST_ISEMPTY(&expect->onerror_fmt))
+ desc = htx_sl_res_reason(sl);
break;
case TCPCHK_EXPECT_HTTP_REGEX_STATUS:
match = regex_exec2(expect->regex, HTX_SL_RES_CPTR(sl), HTX_SL_RES_CLEN(sl));
/* Set status and description in case of error */
- status = HCHK_STATUS_L7STS;
- desc = htx_sl_res_reason(sl);
+ status = ((rule->expect.err_status != HCHK_STATUS_UNKNOWN) ? rule->expect.err_status : HCHK_STATUS_L7STS);
+ if (LIST_ISEMPTY(&expect->onerror_fmt))
+ desc = htx_sl_res_reason(sl);
break;
case TCPCHK_EXPECT_HTTP_BODY:
if (!b_data(&trash)) {
if (!last_read)
goto wait_more_data;
- status = HCHK_STATUS_L7RSP;
- desc = ist("HTTP content check could not find a response body");
+ status = ((rule->expect.err_status != HCHK_STATUS_UNKNOWN) ? rule->expect.err_status : HCHK_STATUS_L7RSP);
+ if (LIST_ISEMPTY(&expect->onerror_fmt))
+ desc = ist("HTTP content check could not find a response body");
goto error;
}
match = regex_exec2(expect->regex, b_orig(&trash), b_data(&trash));
/* Set status and description in case of error */
- status = HCHK_STATUS_L7RSP;
- desc = (inverse
- ? ist("HTTP check matched unwanted content")
- : ist("HTTP content check did not match"));
+ status = ((rule->expect.err_status != HCHK_STATUS_UNKNOWN) ? rule->expect.err_status : HCHK_STATUS_L7RSP);
+ if (LIST_ISEMPTY(&expect->onerror_fmt))
+ desc = (inverse
+ ? ist("HTTP check matched unwanted content")
+ : ist("HTTP content check did not match"));
break;
default:
/* should never happen */
- status = HCHK_STATUS_L7RSP;
+ status = ((rule->expect.err_status != HCHK_STATUS_UNKNOWN) ? rule->expect.err_status : HCHK_STATUS_L7RSP);
goto error;
}
enum tcpcheck_eval_ret ret = TCPCHK_EVAL_CONTINUE;
struct tcpcheck_expect *expect = &rule->expect;
struct buffer *msg = NULL;
+ enum healthcheck_status status;
int match, inverse;
last_read |= b_full(&check->bi);
msg = alloc_trash_chunk();
if (msg)
tcpcheck_expect_onerror_message(msg, check, rule, match, IST_NULL);
- set_server_check_status(check, expect->err_status, (msg ? b_head(msg) : NULL));
+
+ status = ((rule->expect.err_status != HCHK_STATUS_UNKNOWN) ? rule->expect.err_status : HCHK_STATUS_L7RSP);
+ set_server_check_status(check, status, (msg ? b_head(msg) : NULL));
free_trash_chunk(msg);
ret = TCPCHK_EVAL_STOP;
if (rule->action == TCPCHK_ACT_EXPECT) {
struct buffer *msg;
+ enum healthcheck_status status;
if (check->server &&
(check->server->proxy->options & PR_O_DISABLE404) &&
msg = alloc_trash_chunk();
if (msg)
tcpcheck_expect_onsuccess_message(msg, check, rule, IST_NULL);
- set_server_check_status(check, rule->expect.ok_status,
- (msg ? b_head(msg) : "(tcp-check)"));
+ status = ((rule->expect.ok_status != HCHK_STATUS_UNKNOWN) ? rule->expect.ok_status : HCHK_STATUS_L7OKD);
+ set_server_check_status(check, status, (msg ? b_head(msg) : "(tcp-check)"));
free_trash_chunk(msg);
}
else if (rule->action == TCPCHK_ACT_CONNECT) {
struct sample_expr *status_expr = NULL;
char *on_success_msg, *on_error_msg, *comment, *pattern;
enum tcpcheck_expect_type type = TCPCHK_EXPECT_UNDEF;
- enum healthcheck_status ok_st = HCHK_STATUS_L7OKD;
- enum healthcheck_status err_st = HCHK_STATUS_L7RSP;
- enum healthcheck_status tout_st = HCHK_STATUS_L7TOUT;
+ enum healthcheck_status ok_st = HCHK_STATUS_UNKNOWN;
+ enum healthcheck_status err_st = HCHK_STATUS_UNKNOWN;
+ enum healthcheck_status tout_st = HCHK_STATUS_UNKNOWN;
long min_recv = -1;
int inverse = 0;
goto error;
}
cur_arg++;
- free(on_success_msg);
- on_success_msg = strdup(args[cur_arg]);
- if (!on_success_msg) {
- memprintf(errmsg, "out of memory");
- goto error;
- }
+ on_success_msg = args[cur_arg];
}
else if (strcmp(args[cur_arg], "on-error") == 0) {
if (in_pattern) {
goto error;
}
cur_arg++;
- free(on_error_msg);
- on_error_msg = strdup(args[cur_arg]);
- if (!on_error_msg) {
- memprintf(errmsg, "out of memory");
- goto error;
- }
+ on_error_msg = args[cur_arg];
}
else if (strcmp(args[cur_arg], "ok-status") == 0) {
if (in_pattern) {
memprintf(errmsg, "'%s' invalid log-format string (%s).\n", on_success_msg, *errmsg);
goto error;
}
- free(on_success_msg);
- on_success_msg = NULL;
}
if (on_error_msg) {
px->conf.args.ctx = ARGC_SRV;
memprintf(errmsg, "'%s' invalid log-format string (%s).\n", on_error_msg, *errmsg);
goto error;
}
- free(on_error_msg);
- on_error_msg = NULL;
}
switch (chk->expect.type) {
error:
free_tcpcheck(chk, 0);
free(comment);
- free(on_success_msg);
- free(on_error_msg);
release_sample_expr(status_expr);
return NULL;
}