MEDIUM: connection: add an error code in connections
This will be needed to improve error reporting, especially for SSL.
diff --git a/include/types/connection.h b/include/types/connection.h
index 6149dd5..6f8a59f 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -142,6 +142,12 @@
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 @@
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 @@
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 */
diff --git a/src/checks.c b/src/checks.c
index a0637c2..394d29e 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -1298,6 +1298,7 @@
/* 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);
diff --git a/src/peers.c b/src/peers.c
index 6870f8f..688d64c 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1156,6 +1156,7 @@
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 @@
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;
diff --git a/src/proto_http.c b/src/proto_http.c
index c01dfd2..0e51c08 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -4093,6 +4093,7 @@
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;
diff --git a/src/session.c b/src/session.c
index 330d722..f7c802b 100644
--- a/src/session.c
+++ b/src/session.c
@@ -109,6 +109,7 @@
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 @@
*/
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;