]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: add an error code in connections
authorWilly Tarreau <w@1wt.eu>
Fri, 30 Nov 2012 16:33:05 +0000 (17:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 3 Dec 2012 13:22:13 +0000 (14:22 +0100)
This will be needed to improve error reporting, especially for SSL.

include/types/connection.h
src/checks.c
src/peers.c
src/proto_http.c
src/session.c

index 6149dd598a5cf3e0528d797ae5c7cda88f7a4489..6f8a59f2dbda5a44ce965db6b5a99ff2a668b159 100644 (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 */
index a0637c29df4d76a36f1bb75e558b610cd1604376..394d29ef75be1936e4b498d2e0eceb6e70473277 100644 (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);
 
index 6870f8f86f98019bb19baa54cb9af1392eff9915..688d64cf9f9f3a8f6c6d3cc2af140cabe2857993 100644 (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;
index c01dfd288fbf92e7d253b42ffd865ea4c752890e..0e51c089f45a5907870f22188b8e67bd09fcaeed 100644 (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;
index 330d7228f87b728a84bc3af05fd8b08b76908d0d..f7c802b8dd57ba07650a10e06dc87fa79eb23419 100644 (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;