]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: always initialize conn->objt_type to OBJ_TYPE_CONN
authorWilly Tarreau <w@1wt.eu>
Sun, 29 Sep 2013 08:47:38 +0000 (10:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Dec 2013 14:40:22 +0000 (15:40 +0100)
We do this everywhere we prepare a connection so that we can safely
switch to objt_conn() next.

src/peers.c
src/proto_http.c
src/session.c

index 04385acd410993d63af310e8ad958400b24af961..8a474ad429f6c99d172c1ebb4712862263c846f0 100644 (file)
@@ -1162,6 +1162,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
 
        s->req = s->rep = NULL; /* will be allocated later */
 
+       s->si[0].conn->obj_type = OBJ_TYPE_CONN;
        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;
@@ -1180,6 +1181,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
        s->si[0].applet.st0 = PEER_SESSION_CONNECT;
        s->si[0].applet.ptr = (void *)ps;
 
+       s->si[1].conn->obj_type = OBJ_TYPE_CONN;
        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;
index 2234b9106819b946ad4c30faed4282e34343c372..dc3c9a9e3bdf1b12619c8be6d3419724f4ff65b7 100644 (file)
@@ -4283,6 +4283,7 @@ void http_end_txn_clean_session(struct session *s)
        s->target = NULL;
 
        s->req->cons->state     = s->req->cons->prev_state = SI_ST_INI;
+       s->req->cons->conn->obj_type = OBJ_TYPE_CONN;
        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;
index b7f68bc5f348662601c6db7d564de7fe26c30391..90bf3de7b22103009d9b75c9d005ecc78f30f4cb 100644 (file)
@@ -105,6 +105,7 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
        s->fe  = p;
 
        /* OK, we're keeping the session, so let's properly initialize the session */
+       s->si[0].conn->obj_type = OBJ_TYPE_CONN;
        s->si[0].conn->t.sock.fd = cfd;
        s->si[0].conn->ctrl = l->proto;
        s->si[0].conn->flags = CO_FL_NONE | CO_FL_ADDR_FROM_SET;
@@ -112,6 +113,11 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
        s->si[0].conn->addr.from = *addr;
        s->si[0].conn->target = &l->obj_type;
 
+       /* FIXME: this should be replaced with OBJ_TYPE_NONE once all users check the
+        * object type before dereferencing the connection pointer.
+        */
+       s->si[1].conn->obj_type = OBJ_TYPE_CONN;
+
        s->logs.accept_date = date; /* user-visible date for logging */
        s->logs.tv_accept = now;  /* corrected date for internal use */
        s->uniq_id = totalconn;
@@ -453,6 +459,7 @@ int session_complete(struct session *s)
        /* pre-initialize the other side's stream interface to an INIT state. The
         * callbacks will be initialized before attempting to connect.
         */
+       s->si[1].conn->obj_type = OBJ_TYPE_CONN;
        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;