MEDIUM: stream-int: Move SI err_type in the stream

Only the server side is concerned by the stream-interface error type. It is
useless to have an err_type field on the client side. So, it is now move to
the stream. SI_ET_* are renames STRM_ET_* and moved in stream-t.h header
file.
This commit is contained in:
Christopher Faulet 2022-03-30 19:39:30 +02:00
parent a70a3548bc
commit 50264b41c8
9 changed files with 107 additions and 111 deletions

View File

@ -15,7 +15,7 @@
#define SHOW_AS_CONN 0x00000004 #define SHOW_AS_CONN 0x00000004
#define SHOW_AS_CS 0x00000008 #define SHOW_AS_CS 0x00000008
#define SHOW_AS_SI 0x00000010 #define SHOW_AS_SI 0x00000010
#define SHOW_AS_SIET 0x00000020 #define SHOW_AS_SET 0x00000020
#define SHOW_AS_STRM 0x00000040 #define SHOW_AS_STRM 0x00000040
#define SHOW_AS_TASK 0x00000080 #define SHOW_AS_TASK 0x00000080
#define SHOW_AS_TXN 0x00000100 #define SHOW_AS_TXN 0x00000100
@ -233,25 +233,25 @@ void show_cs_flags(unsigned int f)
putchar('\n'); putchar('\n');
} }
void show_si_et(unsigned int f) void show_strm_et(unsigned int f)
{ {
printf("si->et = "); printf("strm->et = ");
if (!f) { if (!f) {
printf("SI_ET_NONE\n"); printf("STRM_ET_NONE\n");
return; return;
} }
SHOW_FLAG(f, SI_ET_QUEUE_TO); SHOW_FLAG(f, STRM_ET_QUEUE_TO);
SHOW_FLAG(f, SI_ET_QUEUE_ERR); SHOW_FLAG(f, STRM_ET_QUEUE_ERR);
SHOW_FLAG(f, SI_ET_QUEUE_ABRT); SHOW_FLAG(f, STRM_ET_QUEUE_ABRT);
SHOW_FLAG(f, SI_ET_CONN_TO); SHOW_FLAG(f, STRM_ET_CONN_TO);
SHOW_FLAG(f, SI_ET_CONN_ERR); SHOW_FLAG(f, STRM_ET_CONN_ERR);
SHOW_FLAG(f, SI_ET_CONN_ABRT); SHOW_FLAG(f, STRM_ET_CONN_ABRT);
SHOW_FLAG(f, SI_ET_CONN_RES); SHOW_FLAG(f, STRM_ET_CONN_RES);
SHOW_FLAG(f, SI_ET_CONN_OTHER); SHOW_FLAG(f, STRM_ET_CONN_OTHER);
SHOW_FLAG(f, SI_ET_DATA_TO); SHOW_FLAG(f, STRM_ET_DATA_TO);
SHOW_FLAG(f, SI_ET_DATA_ERR); SHOW_FLAG(f, STRM_ET_DATA_ERR);
SHOW_FLAG(f, SI_ET_DATA_ABRT); SHOW_FLAG(f, STRM_ET_DATA_ABRT);
if (f) { if (f) {
printf("EXTRA(0x%08x)", f); printf("EXTRA(0x%08x)", f);
@ -503,7 +503,7 @@ int main(int argc, char **argv)
if (show_as & SHOW_AS_CS) show_cs_flags(flags); if (show_as & SHOW_AS_CS) show_cs_flags(flags);
if (show_as & SHOW_AS_ENDP) show_endp_flags(flags); if (show_as & SHOW_AS_ENDP) show_endp_flags(flags);
if (show_as & SHOW_AS_SI) show_si_flags(flags); if (show_as & SHOW_AS_SI) show_si_flags(flags);
if (show_as & SHOW_AS_SIET) show_si_et(flags); if (show_as & SHOW_AS_SET) show_strm_et(flags);
if (show_as & SHOW_AS_STRM) show_strm_flags(flags); if (show_as & SHOW_AS_STRM) show_strm_flags(flags);
if (show_as & SHOW_AS_TASK) show_task_state(flags); if (show_as & SHOW_AS_TASK) show_task_state(flags);
if (show_as & SHOW_AS_TXN) show_txn_flags(flags); if (show_as & SHOW_AS_TXN) show_txn_flags(flags);

View File

@ -79,8 +79,8 @@ static inline struct conn_stream *cs_opposite(struct conn_stream *cs)
/* to be called only when in SI_ST_DIS with SI_FL_ERR */ /* to be called only when in SI_ST_DIS with SI_FL_ERR */
static inline void cs_report_error(struct conn_stream *cs) static inline void cs_report_error(struct conn_stream *cs)
{ {
if (!cs->si->err_type) if (!__cs_strm(cs)->conn_err_type)
cs->si->err_type = SI_ET_DATA_ERR; __cs_strm(cs)->conn_err_type = STRM_ET_DATA_ERR;
cs_oc(cs)->flags |= CF_WRITE_ERROR; cs_oc(cs)->flags |= CF_WRITE_ERROR;
cs_ic(cs)->flags |= CF_READ_ERROR; cs_ic(cs)->flags |= CF_READ_ERROR;

View File

@ -90,6 +90,23 @@
#define PCLI_F_PROMPT 0x10000 #define PCLI_F_PROMPT 0x10000
#define PCLI_F_PAYLOAD 0x20000 #define PCLI_F_PAYLOAD 0x20000
/* error types reported on the streams for more accurate reporting */
enum {
STRM_ET_NONE = 0x0000, /* no error yet, leave it to zero */
STRM_ET_QUEUE_TO = 0x0001, /* queue timeout */
STRM_ET_QUEUE_ERR = 0x0002, /* queue error (eg: full) */
STRM_ET_QUEUE_ABRT = 0x0004, /* aborted in queue by external cause */
STRM_ET_CONN_TO = 0x0008, /* connection timeout */
STRM_ET_CONN_ERR = 0x0010, /* connection error (eg: no server available) */
STRM_ET_CONN_ABRT = 0x0020, /* connection aborted by external cause (eg: abort) */
STRM_ET_CONN_RES = 0x0040, /* connection aborted due to lack of resources */
STRM_ET_CONN_OTHER = 0x0080, /* connection aborted for other reason (eg: 500) */
STRM_ET_DATA_TO = 0x0100, /* timeout during data phase */
STRM_ET_DATA_ERR = 0x0200, /* error during data phase */
STRM_ET_DATA_ABRT = 0x0400, /* data phase aborted by external cause */
};
struct conn_stream; struct conn_stream;
struct hlua; struct hlua;
struct proxy; struct proxy;
@ -143,6 +160,7 @@ struct stream {
int conn_retries; /* number of connect retries performed */ int conn_retries; /* number of connect retries performed */
unsigned int conn_exp; /* wake up time for connect, queue, turn-around, ... */ unsigned int conn_exp; /* wake up time for connect, queue, turn-around, ... */
unsigned int conn_err_type; /* first error detected, one of STRM_ET_* */
enum si_state prev_conn_state; /* SI_ST*, copy of previous state of the server conn-stream */ enum si_state prev_conn_state; /* SI_ST*, copy of previous state of the server conn-stream */
struct list list; /* position in the thread's streams list */ struct list list; /* position in the thread's streams list */

View File

@ -64,22 +64,6 @@ enum si_state_bit {
SI_SB_ALL = SI_SB_INI|SI_SB_REQ|SI_SB_QUE|SI_SB_TAR|SI_SB_ASS|SI_SB_CON|SI_SB_CER|SI_SB_RDY|SI_SB_EST|SI_SB_DIS|SI_SB_CLO, SI_SB_ALL = SI_SB_INI|SI_SB_REQ|SI_SB_QUE|SI_SB_TAR|SI_SB_ASS|SI_SB_CON|SI_SB_CER|SI_SB_RDY|SI_SB_EST|SI_SB_DIS|SI_SB_CLO,
}; };
/* error types reported on the streams interface for more accurate reporting */
enum {
SI_ET_NONE = 0x0000, /* no error yet, leave it to zero */
SI_ET_QUEUE_TO = 0x0001, /* queue timeout */
SI_ET_QUEUE_ERR = 0x0002, /* queue error (eg: full) */
SI_ET_QUEUE_ABRT = 0x0004, /* aborted in queue by external cause */
SI_ET_CONN_TO = 0x0008, /* connection timeout */
SI_ET_CONN_ERR = 0x0010, /* connection error (eg: no server available) */
SI_ET_CONN_ABRT = 0x0020, /* connection aborted by external cause (eg: abort) */
SI_ET_CONN_RES = 0x0040, /* connection aborted due to lack of resources */
SI_ET_CONN_OTHER = 0x0080, /* connection aborted for other reason (eg: 500) */
SI_ET_DATA_TO = 0x0100, /* timeout during data phase */
SI_ET_DATA_ERR = 0x0200, /* error during data phase */
SI_ET_DATA_ABRT = 0x0400, /* data phase aborted by external cause */
};
/* flags set after I/O (32 bit) */ /* flags set after I/O (32 bit) */
enum { enum {
SI_FL_NONE = 0x00000000, /* nothing */ SI_FL_NONE = 0x00000000, /* nothing */
@ -117,9 +101,6 @@ struct stream_interface {
struct conn_stream *cs; /* points to the conn-streams that owns the endpoint (connection or applet) */ struct conn_stream *cs; /* points to the conn-streams that owns the endpoint (connection or applet) */
struct si_ops *ops; /* general operations at the stream interface layer */ struct si_ops *ops; /* general operations at the stream interface layer */
/* struct members below are the "remote" part, as seen from the buffer side */
unsigned int err_type; /* first error detected, one of SI_ET_* */
struct wait_event wait_event; /* We're in a wait list */ struct wait_event wait_event; /* We're in a wait list */
}; };

View File

@ -106,7 +106,6 @@ static inline struct stream_interface *si_opposite(struct stream_interface *si)
*/ */
static inline int si_init(struct stream_interface *si) static inline int si_init(struct stream_interface *si)
{ {
si->err_type = SI_ET_NONE;
si->flags &= SI_FL_ISBACK; si->flags &= SI_FL_ISBACK;
si->cs = NULL; si->cs = NULL;
si->state = SI_ST_INI; si->state = SI_ST_INI;

View File

@ -1824,8 +1824,8 @@ int srv_redispatch_connect(struct stream *s)
goto redispatch; goto redispatch;
} }
if (!cs_si(s->csb)->err_type) { if (!s->conn_err_type) {
cs_si(s->csb)->err_type = SI_ET_QUEUE_ERR; s->conn_err_type = STRM_ET_QUEUE_ERR;
} }
_HA_ATOMIC_INC(&srv->counters.failed_conns); _HA_ATOMIC_INC(&srv->counters.failed_conns);
@ -1834,8 +1834,8 @@ int srv_redispatch_connect(struct stream *s)
case SRV_STATUS_NOSRV: case SRV_STATUS_NOSRV:
/* note: it is guaranteed that srv == NULL here */ /* note: it is guaranteed that srv == NULL here */
if (!cs_si(s->csb)->err_type) { if (!s->conn_err_type) {
cs_si(s->csb)->err_type = SI_ET_CONN_ERR; s->conn_err_type = STRM_ET_CONN_ERR;
} }
_HA_ATOMIC_INC(&s->be->be_counters.failed_conns); _HA_ATOMIC_INC(&s->be->be_counters.failed_conns);
@ -1849,8 +1849,8 @@ int srv_redispatch_connect(struct stream *s)
case SRV_STATUS_INTERNAL: case SRV_STATUS_INTERNAL:
default: default:
if (!cs_si(s->csb)->err_type) { if (!s->conn_err_type) {
cs_si(s->csb)->err_type = SI_ET_CONN_OTHER; s->conn_err_type = STRM_ET_CONN_OTHER;
} }
if (srv) if (srv)
@ -1902,7 +1902,7 @@ void back_try_conn_req(struct stream *s)
* request may be aborted instead. * request may be aborted instead.
*/ */
if (back_may_abort_req(req, s)) { if (back_may_abort_req(req, s)) {
cs->si->err_type |= SI_ET_CONN_ABRT; s->conn_err_type |= STRM_ET_CONN_ABRT;
DBG_TRACE_STATE("connection aborted", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s); DBG_TRACE_STATE("connection aborted", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s);
goto abort_connection; goto abort_connection;
} }
@ -1924,8 +1924,8 @@ void back_try_conn_req(struct stream *s)
* abort, retry immediately or redispatch. * abort, retry immediately or redispatch.
*/ */
if (conn_err == SF_ERR_INTERNAL) { if (conn_err == SF_ERR_INTERNAL) {
if (!cs->si->err_type) { if (!s->conn_err_type) {
cs->si->err_type = SI_ET_CONN_OTHER; s->conn_err_type = STRM_ET_CONN_OTHER;
} }
if (srv) if (srv)
@ -2005,8 +2005,8 @@ void back_try_conn_req(struct stream *s)
si_shutr(cs->si); si_shutr(cs->si);
si_shutw(cs->si); si_shutw(cs->si);
req->flags |= CF_WRITE_TIMEOUT; req->flags |= CF_WRITE_TIMEOUT;
if (!cs->si->err_type) if (!s->conn_err_type)
cs->si->err_type = SI_ET_QUEUE_TO; s->conn_err_type = STRM_ET_QUEUE_TO;
cs->si->state = SI_ST_CLO; cs->si->state = SI_ST_CLO;
if (s->srv_error) if (s->srv_error)
s->srv_error(s, cs->si); s->srv_error(s, cs->si);
@ -2021,7 +2021,7 @@ void back_try_conn_req(struct stream *s)
/* we may need to know the position in the queue for logging */ /* we may need to know the position in the queue for logging */
pendconn_cond_unlink(s->pend_pos); pendconn_cond_unlink(s->pend_pos);
cs->si->err_type |= SI_ET_QUEUE_ABRT; s->conn_err_type |= STRM_ET_QUEUE_ABRT;
DBG_TRACE_STATE("abort queued connection request", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s); DBG_TRACE_STATE("abort queued connection request", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s);
goto abort_connection; goto abort_connection;
} }
@ -2031,7 +2031,7 @@ void back_try_conn_req(struct stream *s)
else if (cs->si->state == SI_ST_TAR) { else if (cs->si->state == SI_ST_TAR) {
/* Connection request might be aborted */ /* Connection request might be aborted */
if (back_may_abort_req(req, s)) { if (back_may_abort_req(req, s)) {
cs->si->err_type |= SI_ET_CONN_ABRT; s->conn_err_type |= STRM_ET_CONN_ABRT;
DBG_TRACE_STATE("connection aborted", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s); DBG_TRACE_STATE("connection aborted", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s);
goto abort_connection; goto abort_connection;
} }
@ -2103,7 +2103,7 @@ void back_handle_st_req(struct stream *s)
si_shutr(cs->si); si_shutr(cs->si);
si_shutw(cs->si); si_shutw(cs->si);
s->req.flags |= CF_WRITE_ERROR; s->req.flags |= CF_WRITE_ERROR;
cs->si->err_type = SI_ET_CONN_RES; s->conn_err_type = STRM_ET_CONN_RES;
cs->si->state = SI_ST_CLO; cs->si->state = SI_ST_CLO;
if (s->srv_error) if (s->srv_error)
s->srv_error(s, cs->si); s->srv_error(s, cs->si);
@ -2115,7 +2115,7 @@ void back_handle_st_req(struct stream *s)
s->logs.tv_request = now; s->logs.tv_request = now;
s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now); s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
cs->si->state = SI_ST_EST; cs->si->state = SI_ST_EST;
cs->si->err_type = SI_ET_NONE; s->conn_err_type = STRM_ET_NONE;
be_set_sess_last(s->be); be_set_sess_last(s->be);
DBG_TRACE_STATE("applet registered", STRM_EV_STRM_PROC|STRM_EV_SI_ST, s); DBG_TRACE_STATE("applet registered", STRM_EV_STRM_PROC|STRM_EV_SI_ST, s);
@ -2137,8 +2137,8 @@ void back_handle_st_req(struct stream *s)
si_shutr(cs->si); si_shutr(cs->si);
si_shutw(cs->si); si_shutw(cs->si);
s->req.flags |= CF_WRITE_ERROR; s->req.flags |= CF_WRITE_ERROR;
if (!cs->si->err_type) if (!s->conn_err_type)
cs->si->err_type = SI_ET_CONN_OTHER; s->conn_err_type = STRM_ET_CONN_OTHER;
cs->si->state = SI_ST_CLO; cs->si->state = SI_ST_CLO;
if (s->srv_error) if (s->srv_error)
s->srv_error(s, cs->si); s->srv_error(s, cs->si);
@ -2177,7 +2177,7 @@ void back_handle_st_con(struct stream *s)
(channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) { (channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
cs->flags |= CS_FL_NOLINGER; cs->flags |= CS_FL_NOLINGER;
si_shutw(cs->si); si_shutw(cs->si);
cs->si->err_type |= SI_ET_CONN_ABRT; s->conn_err_type |= STRM_ET_CONN_ABRT;
if (s->srv_error) if (s->srv_error)
s->srv_error(s, cs->si); s->srv_error(s, cs->si);
/* Note: state = SI_ST_DIS now */ /* Note: state = SI_ST_DIS now */
@ -2188,11 +2188,11 @@ void back_handle_st_con(struct stream *s)
done: done:
/* retryable error ? */ /* retryable error ? */
if ((s->flags & SF_CONN_EXP) || (cs->endp->flags & CS_EP_ERROR)) { if ((s->flags & SF_CONN_EXP) || (cs->endp->flags & CS_EP_ERROR)) {
if (!cs->si->err_type) { if (!s->conn_err_type) {
if (cs->endp->flags & CS_EP_ERROR) if (cs->endp->flags & CS_EP_ERROR)
cs->si->err_type = SI_ET_CONN_ERR; s->conn_err_type = STRM_ET_CONN_ERR;
else else
cs->si->err_type = SI_ET_CONN_TO; s->conn_err_type = STRM_ET_CONN_TO;
} }
cs->si->state = SI_ST_CER; cs->si->state = SI_ST_CER;
@ -2260,8 +2260,8 @@ void back_handle_st_cer(struct stream *s)
/* ensure that we have enough retries left */ /* ensure that we have enough retries left */
if (s->conn_retries >= s->be->conn_retries || !(s->be->retry_type & PR_RE_CONN_FAILED)) { if (s->conn_retries >= s->be->conn_retries || !(s->be->retry_type & PR_RE_CONN_FAILED)) {
if (!cs->si->err_type) { if (!s->conn_err_type) {
cs->si->err_type = SI_ET_CONN_ERR; s->conn_err_type = STRM_ET_CONN_ERR;
} }
if (objt_server(s->target)) if (objt_server(s->target))
@ -2295,8 +2295,8 @@ void back_handle_st_cer(struct stream *s)
* ST_TAR and CS_EP_ERROR and SF_CONN_EXP flags will be unset. * ST_TAR and CS_EP_ERROR and SF_CONN_EXP flags will be unset.
*/ */
if (cs_reset_endp(cs) < 0) { if (cs_reset_endp(cs) < 0) {
if (!cs->si->err_type) if (!s->conn_err_type)
cs->si->err_type = SI_ET_CONN_OTHER; s->conn_err_type = STRM_ET_CONN_OTHER;
if (objt_server(s->target)) if (objt_server(s->target))
_HA_ATOMIC_INC(&objt_server(s->target)->counters.internal_errors); _HA_ATOMIC_INC(&objt_server(s->target)->counters.internal_errors);
@ -2336,8 +2336,8 @@ void back_handle_st_cer(struct stream *s)
if (s->be->timeout.connect && s->be->timeout.connect < delay) if (s->be->timeout.connect && s->be->timeout.connect < delay)
delay = s->be->timeout.connect; delay = s->be->timeout.connect;
if (!cs->si->err_type) if (!s->conn_err_type)
cs->si->err_type = SI_ET_CONN_ERR; s->conn_err_type = STRM_ET_CONN_ERR;
/* only wait when we're retrying on the same server */ /* only wait when we're retrying on the same server */
if ((cs->si->state == SI_ST_ASS || if ((cs->si->state == SI_ST_ASS ||
@ -2393,7 +2393,7 @@ void back_handle_st_rdy(struct stream *s)
/* give up */ /* give up */
cs->flags |= CS_FL_NOLINGER; cs->flags |= CS_FL_NOLINGER;
si_shutw(cs->si); si_shutw(cs->si);
cs->si->err_type |= SI_ET_CONN_ABRT; s->conn_err_type |= STRM_ET_CONN_ABRT;
if (s->srv_error) if (s->srv_error)
s->srv_error(s, cs->si); s->srv_error(s, cs->si);
DBG_TRACE_STATE("client abort during connection attempt", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s); DBG_TRACE_STATE("client abort during connection attempt", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s);
@ -2402,8 +2402,8 @@ void back_handle_st_rdy(struct stream *s)
/* retryable error ? */ /* retryable error ? */
if (cs->endp->flags & CS_EP_ERROR) { if (cs->endp->flags & CS_EP_ERROR) {
if (!cs->si->err_type) if (!s->conn_err_type)
cs->si->err_type = SI_ET_CONN_ERR; s->conn_err_type = STRM_ET_CONN_ERR;
cs->si->state = SI_ST_CER; cs->si->state = SI_ST_CER;
DBG_TRACE_STATE("connection failed, retry", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s); DBG_TRACE_STATE("connection failed, retry", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s);
goto end; goto end;
@ -2414,8 +2414,8 @@ void back_handle_st_rdy(struct stream *s)
* now take over. * now take over.
*/ */
DBG_TRACE_STATE("connection established", STRM_EV_STRM_PROC|STRM_EV_SI_ST, s); DBG_TRACE_STATE("connection established", STRM_EV_STRM_PROC|STRM_EV_SI_ST, s);
cs->si->err_type = SI_ET_NONE; s->conn_err_type = STRM_ET_NONE;
cs->si->state = SI_ST_EST; cs->si->state = SI_ST_EST;
end: end:
DBG_TRACE_LEAVE(STRM_EV_STRM_PROC|STRM_EV_SI_ST, s); DBG_TRACE_LEAVE(STRM_EV_STRM_PROC|STRM_EV_SI_ST, s);

View File

@ -2756,8 +2756,8 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
if (!si_conn_ready(cs_si(s->csb))) { if (!si_conn_ready(cs_si(s->csb))) {
s->srv_conn = NULL; s->srv_conn = NULL;
if (cs_reset_endp(s->csb) < 0) { if (cs_reset_endp(s->csb) < 0) {
if (!cs_si(s->csb)->err_type) if (!s->conn_err_type)
cs_si(s->csb)->err_type = SI_ET_CONN_OTHER; s->conn_err_type = STRM_ET_CONN_OTHER;
if (s->srv_error) if (s->srv_error)
s->srv_error(s, cs_si(s->csb)); s->srv_error(s, cs_si(s->csb));
return 1; return 1;
@ -2767,7 +2767,6 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
sockaddr_free(&s->csb->dst); sockaddr_free(&s->csb->dst);
si_set_state(cs_si(s->csb), SI_ST_INI); si_set_state(cs_si(s->csb), SI_ST_INI);
cs_si(s->csb)->err_type = SI_ET_NONE;
cs_si(s->csb)->flags &= SI_FL_ISBACK; /* we're in the context of process_stream */ cs_si(s->csb)->flags &= SI_FL_ISBACK; /* we're in the context of process_stream */
s->csb->flags &= CS_FL_ISBACK | CS_FL_DONT_WAKE; /* we're in the context of process_stream */ s->csb->flags &= CS_FL_ISBACK | CS_FL_DONT_WAKE; /* we're in the context of process_stream */
s->req.flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WROTE_DATA); s->req.flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WROTE_DATA);
@ -2777,6 +2776,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
s->flags &= ~(SF_ERR_MASK|SF_FINST_MASK|SF_REDISP); s->flags &= ~(SF_ERR_MASK|SF_FINST_MASK|SF_REDISP);
s->conn_retries = 0; /* used for logging too */ s->conn_retries = 0; /* used for logging too */
s->conn_exp = TICK_ETERNITY; s->conn_exp = TICK_ETERNITY;
s->conn_err_type = STRM_ET_NONE;
/* reinitialise the current rule list pointer to NULL. We are sure that /* reinitialise the current rule list pointer to NULL. We are sure that
* any rulelist match the NULL pointer. * any rulelist match the NULL pointer.
*/ */

View File

@ -1248,7 +1248,7 @@ static __inline int do_l7_retry(struct stream *s, struct stream_interface *si)
res->flags &= ~(CF_READ_ERROR | CF_READ_TIMEOUT | CF_SHUTR | CF_EOI | CF_READ_NULL | CF_SHUTR_NOW); res->flags &= ~(CF_READ_ERROR | CF_READ_TIMEOUT | CF_SHUTR | CF_EOI | CF_READ_NULL | CF_SHUTR_NOW);
res->analysers &= AN_RES_FLT_END; res->analysers &= AN_RES_FLT_END;
si->flags &= ~SI_FL_RXBLK_SHUT; si->flags &= ~SI_FL_RXBLK_SHUT;
si->err_type = SI_ET_NONE; s->conn_err_type = STRM_ET_NONE;
s->flags &= ~(SF_CONN_EXP | SF_ERR_MASK | SF_FINST_MASK); s->flags &= ~(SF_CONN_EXP | SF_ERR_MASK | SF_FINST_MASK);
s->conn_exp = TICK_ETERNITY; s->conn_exp = TICK_ETERNITY;
stream_choose_redispatch(s); stream_choose_redispatch(s);
@ -4262,8 +4262,8 @@ void http_perform_server_redirect(struct stream *s, struct stream_interface *si)
/* return without error. */ /* return without error. */
si_shutr(si); si_shutr(si);
si_shutw(si); si_shutw(si);
si->err_type = SI_ET_NONE; s->conn_err_type = STRM_ET_NONE;
si->state = SI_ST_CLO; si->state = SI_ST_CLO;
if (!(s->flags & SF_ERR_MASK)) if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_LOCAL; s->flags |= SF_ERR_LOCAL;
@ -4797,7 +4797,7 @@ int http_reply_message(struct stream *s, struct http_reply *reply)
return -1; return -1;
} }
/* Return the error message corresponding to si->err_type. It is assumed /* Return the error message corresponding to s->conn_err_type. It is assumed
* that the server side is closed. Note that err_type is actually a * that the server side is closed. Note that err_type is actually a
* bitmask, where almost only aborts may be cumulated with other * bitmask, where almost only aborts may be cumulated with other
* values. We consider that aborted operations are more important * values. We consider that aborted operations are more important
@ -4810,46 +4810,46 @@ int http_reply_message(struct stream *s, struct http_reply *reply)
*/ */
void http_return_srv_error(struct stream *s, struct stream_interface *si) void http_return_srv_error(struct stream *s, struct stream_interface *si)
{ {
int err_type = si->err_type; int err_type = s->conn_err_type;
/* set s->txn->status for http_error_message(s) */ /* set s->txn->status for http_error_message(s) */
if (err_type & SI_ET_QUEUE_ABRT) { if (err_type & STRM_ET_QUEUE_ABRT) {
s->txn->status = -1; s->txn->status = -1;
http_server_error(s, si, SF_ERR_CLICL, SF_FINST_Q, NULL); http_server_error(s, si, SF_ERR_CLICL, SF_FINST_Q, NULL);
} }
else if (err_type & SI_ET_CONN_ABRT) { else if (err_type & STRM_ET_CONN_ABRT) {
s->txn->status = -1; s->txn->status = -1;
http_server_error(s, si, SF_ERR_CLICL, SF_FINST_C, NULL); http_server_error(s, si, SF_ERR_CLICL, SF_FINST_C, NULL);
} }
else if (err_type & SI_ET_QUEUE_TO) { else if (err_type & STRM_ET_QUEUE_TO) {
s->txn->status = 503; s->txn->status = 503;
http_server_error(s, si, SF_ERR_SRVTO, SF_FINST_Q, http_server_error(s, si, SF_ERR_SRVTO, SF_FINST_Q,
http_error_message(s)); http_error_message(s));
} }
else if (err_type & SI_ET_QUEUE_ERR) { else if (err_type & STRM_ET_QUEUE_ERR) {
s->txn->status = 503; s->txn->status = 503;
http_server_error(s, si, SF_ERR_SRVCL, SF_FINST_Q, http_server_error(s, si, SF_ERR_SRVCL, SF_FINST_Q,
http_error_message(s)); http_error_message(s));
} }
else if (err_type & SI_ET_CONN_TO) { else if (err_type & STRM_ET_CONN_TO) {
s->txn->status = 503; s->txn->status = 503;
http_server_error(s, si, SF_ERR_SRVTO, SF_FINST_C, http_server_error(s, si, SF_ERR_SRVTO, SF_FINST_C,
(s->txn->flags & TX_NOT_FIRST) ? NULL : (s->txn->flags & TX_NOT_FIRST) ? NULL :
http_error_message(s)); http_error_message(s));
} }
else if (err_type & SI_ET_CONN_ERR) { else if (err_type & STRM_ET_CONN_ERR) {
s->txn->status = 503; s->txn->status = 503;
http_server_error(s, si, SF_ERR_SRVCL, SF_FINST_C, http_server_error(s, si, SF_ERR_SRVCL, SF_FINST_C,
(s->flags & SF_SRV_REUSED) ? NULL : (s->flags & SF_SRV_REUSED) ? NULL :
http_error_message(s)); http_error_message(s));
} }
else if (err_type & SI_ET_CONN_RES) { else if (err_type & STRM_ET_CONN_RES) {
s->txn->status = 503; s->txn->status = 503;
http_server_error(s, si, SF_ERR_RESOURCE, SF_FINST_C, http_server_error(s, si, SF_ERR_RESOURCE, SF_FINST_C,
(s->txn->flags & TX_NOT_FIRST) ? NULL : (s->txn->flags & TX_NOT_FIRST) ? NULL :
http_error_message(s)); http_error_message(s));
} }
else { /* SI_ET_CONN_OTHER and others */ else { /* STRM_ET_CONN_OTHER and others */
s->txn->status = 500; s->txn->status = 500;
http_server_error(s, si, SF_ERR_INTERNAL, SF_FINST_C, http_server_error(s, si, SF_ERR_INTERNAL, SF_FINST_C,
http_error_message(s)); http_error_message(s));

View File

@ -206,13 +206,12 @@ static void strm_trace(enum trace_level level, uint64_t mask, const struct trace
/* If txn defined info about HTTP msgs, otherwise info about SI. */ /* If txn defined info about HTTP msgs, otherwise info about SI. */
if (txn) { if (txn) {
chunk_appendf(&trace_buf, " - t=%p s=(%p,0x%08x) txn.flags=0x%08x, http.flags=(0x%08x,0x%08x) status=%d", chunk_appendf(&trace_buf, " - t=%p s=(%p,0x%08x,0x%x) txn.flags=0x%08x, http.flags=(0x%08x,0x%08x) status=%d",
task, s, s->flags, txn->flags, txn->req.flags, txn->rsp.flags, txn->status); task, s, s->flags, s->conn_err_type, txn->flags, txn->req.flags, txn->rsp.flags, txn->status);
} }
else { else {
chunk_appendf(&trace_buf, " - t=%p s=(%p,0x%08x) si_f=(%p,0x%08x,0x%x) si_b=(%p,0x%08x,0x%x) retries=%d", chunk_appendf(&trace_buf, " - t=%p s=(%p,0x%08x,0x%x) si_f=(%p,0x%08x) si_b=(%p,0x%08x) retries=%d",
task, s, s->flags, si_f, si_f->flags, si_f->err_type, task, s, s->flags, s->conn_err_type, si_f, si_f->flags, si_b, si_b->flags, s->conn_retries);
si_b, si_b->flags, si_b->err_type, s->conn_retries);
} }
if (src->verbosity == STRM_VERB_MINIMAL) if (src->verbosity == STRM_VERB_MINIMAL)
@ -422,6 +421,7 @@ struct stream *stream_new(struct session *sess, struct conn_stream *cs, struct b
s->pending_events = 0; s->pending_events = 0;
s->conn_retries = 0; s->conn_retries = 0;
s->conn_exp = TICK_ETERNITY; s->conn_exp = TICK_ETERNITY;
s->conn_err_type = STRM_ET_NONE;
s->prev_conn_state = SI_ST_INI; s->prev_conn_state = SI_ST_INI;
t->process = process_stream; t->process = process_stream;
t->context = s; t->context = s;
@ -886,7 +886,7 @@ static void back_establish(struct stream *s)
if (conn && conn->err_code != CO_ER_SSL_EARLY_FAILED) if (conn && conn->err_code != CO_ER_SSL_EARLY_FAILED)
req->flags |= CF_WRITE_ERROR; req->flags |= CF_WRITE_ERROR;
rep->flags |= CF_READ_ERROR; rep->flags |= CF_READ_ERROR;
si->err_type = SI_ET_DATA_ERR; s->conn_err_type = STRM_ET_DATA_ERR;
DBG_TRACE_STATE("read/write error", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s); DBG_TRACE_STATE("read/write error", STRM_EV_STRM_PROC|STRM_EV_SI_ST|STRM_EV_STRM_ERR, s);
} }
@ -1690,10 +1690,10 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
*/ */
if (!stream_alloc_work_buffer(s)) { if (!stream_alloc_work_buffer(s)) {
s->csf->endp->flags |= CS_EP_ERROR; s->csf->endp->flags |= CS_EP_ERROR;
si_f->err_type = SI_ET_CONN_RES; s->conn_err_type = STRM_ET_CONN_RES;
s->csb->endp->flags |= CS_EP_ERROR; s->csb->endp->flags |= CS_EP_ERROR;
si_b->err_type = SI_ET_CONN_RES; s->conn_err_type = STRM_ET_CONN_RES;
if (!(s->flags & SF_ERR_MASK)) if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_RESOURCE; s->flags |= SF_ERR_RESOURCE;
@ -2621,38 +2621,38 @@ void sess_change_server(struct stream *strm, struct server *newsrv)
*/ */
void default_srv_error(struct stream *s, struct stream_interface *si) void default_srv_error(struct stream *s, struct stream_interface *si)
{ {
int err_type = si->err_type; int err_type = s->conn_err_type;
int err = 0, fin = 0; int err = 0, fin = 0;
if (err_type & SI_ET_QUEUE_ABRT) { if (err_type & STRM_ET_QUEUE_ABRT) {
err = SF_ERR_CLICL; err = SF_ERR_CLICL;
fin = SF_FINST_Q; fin = SF_FINST_Q;
} }
else if (err_type & SI_ET_CONN_ABRT) { else if (err_type & STRM_ET_CONN_ABRT) {
err = SF_ERR_CLICL; err = SF_ERR_CLICL;
fin = SF_FINST_C; fin = SF_FINST_C;
} }
else if (err_type & SI_ET_QUEUE_TO) { else if (err_type & STRM_ET_QUEUE_TO) {
err = SF_ERR_SRVTO; err = SF_ERR_SRVTO;
fin = SF_FINST_Q; fin = SF_FINST_Q;
} }
else if (err_type & SI_ET_QUEUE_ERR) { else if (err_type & STRM_ET_QUEUE_ERR) {
err = SF_ERR_SRVCL; err = SF_ERR_SRVCL;
fin = SF_FINST_Q; fin = SF_FINST_Q;
} }
else if (err_type & SI_ET_CONN_TO) { else if (err_type & STRM_ET_CONN_TO) {
err = SF_ERR_SRVTO; err = SF_ERR_SRVTO;
fin = SF_FINST_C; fin = SF_FINST_C;
} }
else if (err_type & SI_ET_CONN_ERR) { else if (err_type & STRM_ET_CONN_ERR) {
err = SF_ERR_SRVCL; err = SF_ERR_SRVCL;
fin = SF_FINST_C; fin = SF_FINST_C;
} }
else if (err_type & SI_ET_CONN_RES) { else if (err_type & STRM_ET_CONN_RES) {
err = SF_ERR_RESOURCE; err = SF_ERR_RESOURCE;
fin = SF_FINST_C; fin = SF_FINST_C;
} }
else /* SI_ET_CONN_OTHER and others */ { else /* STRM_ET_CONN_OTHER and others */ {
err = SF_ERR_INTERNAL; err = SF_ERR_INTERNAL;
fin = SF_FINST_C; fin = SF_FINST_C;
} }
@ -3150,13 +3150,13 @@ static int stats_dump_full_strm_to_buffer(struct conn_stream *cs, struct stream
} }
chunk_appendf(&trash, chunk_appendf(&trash,
" flags=0x%x, conn_retries=%d, conn_exp=%s srv_conn=%p, pend_pos=%p waiting=%d epoch=%#x\n", " flags=0x%x, conn_retries=%d, conn_exp=%s conn_et=0x%03x srv_conn=%p, pend_pos=%p waiting=%d epoch=%#x\n",
strm->flags, strm->conn_retries, strm->flags, strm->conn_retries,
strm->conn_exp ? strm->conn_exp ?
tick_is_expired(strm->conn_exp, now_ms) ? "<PAST>" : tick_is_expired(strm->conn_exp, now_ms) ? "<PAST>" :
human_time(TICKS_TO_MS(strm->conn_exp - now_ms), human_time(TICKS_TO_MS(strm->conn_exp - now_ms),
TICKS_TO_MS(1000)) : "<NEVER>", TICKS_TO_MS(1000)) : "<NEVER>",
strm->srv_conn, strm->pend_pos, strm->conn_err_type, strm->srv_conn, strm->pend_pos,
LIST_INLIST(&strm->buffer_wait.list), strm->stream_epoch); LIST_INLIST(&strm->buffer_wait.list), strm->stream_epoch);
chunk_appendf(&trash, chunk_appendf(&trash,
@ -3251,22 +3251,20 @@ static int stats_dump_full_strm_to_buffer(struct conn_stream *cs, struct stream
strm->txn->req.flags, strm->txn->rsp.flags); strm->txn->req.flags, strm->txn->rsp.flags);
chunk_appendf(&trash, chunk_appendf(&trash,
" si[0]=%p (state=%s flags=0x%02x endp0=%s:%p et=0x%03x sub=%d)\n", " si[0]=%p (state=%s flags=0x%02x endp0=%s:%p sub=%d)\n",
strm->csf->si, strm->csf->si,
si_state_str(strm->csf->si->state), si_state_str(strm->csf->si->state),
strm->csf->si->flags, strm->csf->si->flags,
(strm->csf->endp->flags & CS_EP_T_MUX ? "CONN" : "APPCTX"), (strm->csf->endp->flags & CS_EP_T_MUX ? "CONN" : "APPCTX"),
__cs_endp_target(strm->csf), __cs_endp_target(strm->csf), strm->csf->si->wait_event.events);
strm->csf->si->err_type, strm->csf->si->wait_event.events);
chunk_appendf(&trash, chunk_appendf(&trash,
" si[1]=%p (state=%s flags=0x%02x endp1=%s:%p et=0x%03x sub=%d)\n", " si[1]=%p (state=%s flags=0x%02x endp1=%s:%p sub=%d)\n",
strm->csb->si, strm->csb->si,
si_state_str(strm->csb->si->state), si_state_str(strm->csb->si->state),
strm->csb->si->flags, strm->csb->si->flags,
(strm->csb->endp->flags & CS_EP_T_MUX ? "CONN" : "APPCTX"), (strm->csb->endp->flags & CS_EP_T_MUX ? "CONN" : "APPCTX"),
__cs_endp_target(strm->csb), __cs_endp_target(strm->csb), strm->csb->si->wait_event.events);
strm->csb->si->err_type, strm->csb->si->wait_event.events);
csf = strm->csf; csf = strm->csf;
chunk_appendf(&trash, " cs=%p csf=0x%08x endp=%p,0x%08x\n", csf, csf->flags, csf->endp->target, csf->endp->flags); chunk_appendf(&trash, " cs=%p csf=0x%08x endp=%p,0x%08x\n", csf, csf->flags, csf->endp->target, csf->endp->flags);