MEDIUM: connection: add an error code in connections

This will be needed to improve error reporting, especially for SSL.
This commit is contained in:
Willy Tarreau 2012-11-30 17:33:05 +01:00
parent d1b3f0498d
commit 14cba4b0b1
5 changed files with 14 additions and 1 deletions

View File

@ -142,6 +142,12 @@ enum {
CO_FL_XPRT_TRACKED = 0x80000000,
};
/* possible connection error codes */
enum {
CO_ER_NONE, /* no error */
};
/* xprt_ops describes transport-layer operations for a connection. They
* generally run over a socket-based control layer, but not always. Some
* of them are used for data transfer with the upper layer (rcv_*, snd_*)
@ -186,7 +192,7 @@ struct connection {
const struct protocol *ctrl; /* operations at the socket layer */
const struct xprt_ops *xprt; /* operations at the transport layer */
const struct data_cb *data; /* data layer callbacks */
unsigned int flags; /* CO_F_* */
unsigned int flags; /* CO_FL_* */
int xprt_st; /* transport layer state, initialized to zero */
void *xprt_ctx; /* general purpose pointer, initialized to NULL */
void *owner; /* pointer to upper layer's entity (eg: stream interface) */
@ -195,6 +201,7 @@ struct connection {
int fd; /* file descriptor for a stream driver when known */
} sock;
} t;
unsigned int err_code; /* CO_ER_* */
enum obj_type *target; /* the target to connect to (server, proxy, applet, ...) */
struct {
struct sockaddr_storage from; /* client address, or address to spoof when connecting to the server */

View File

@ -1298,6 +1298,7 @@ static struct task *process_chk(struct task *t)
/* prepare a new connection */
conn->flags = CO_FL_NONE;
conn->err_code = CO_ER_NONE;
conn->target = &s->obj_type;
conn_prepare(conn, &check_conn_cb, s->check.proto, s->check.xprt, s);

View File

@ -1156,6 +1156,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
s->si[0].conn->t.sock.fd = -1;
s->si[0].conn->flags = CO_FL_NONE;
s->si[0].conn->err_code = CO_ER_NONE;
s->si[0].owner = t;
s->si[0].state = s->si[0].prev_state = SI_ST_EST;
s->si[0].err_type = SI_ET_NONE;
@ -1174,6 +1175,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
s->si[1].conn->t.sock.fd = -1; /* just to help with debugging */
s->si[1].conn->flags = CO_FL_NONE;
s->si[1].conn->err_code = CO_ER_NONE;
s->si[1].owner = t;
s->si[1].state = s->si[1].prev_state = SI_ST_ASS;
s->si[1].conn_retries = p->conn_retries;

View File

@ -4093,6 +4093,7 @@ void http_end_txn_clean_session(struct session *s)
s->req->cons->state = s->req->cons->prev_state = SI_ST_INI;
s->req->cons->conn->t.sock.fd = -1; /* just to help with debugging */
s->req->cons->conn->flags = CO_FL_NONE;
s->req->cons->conn->err_code = CO_ER_NONE;
s->req->cons->err_type = SI_ET_NONE;
s->req->cons->conn_retries = 0; /* used for logging too */
s->req->cons->err_loc = NULL;

View File

@ -109,6 +109,7 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
s->si[0].conn->t.sock.fd = cfd;
s->si[0].conn->ctrl = l->proto;
s->si[0].conn->flags = CO_FL_NONE;
s->si[0].conn->err_code = CO_ER_NONE;
s->si[0].conn->addr.from = *addr;
s->si[0].conn->target = &l->obj_type;
@ -403,6 +404,7 @@ int session_complete(struct session *s)
*/
s->si[1].conn->t.sock.fd = -1; /* just to help with debugging */
s->si[1].conn->flags = CO_FL_NONE;
s->si[1].conn->err_code = CO_ER_NONE;
s->si[1].owner = t;
s->si[1].state = s->si[1].prev_state = SI_ST_INI;
s->si[1].err_type = SI_ET_NONE;