]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: session: use conn_init() to initialize the connections
authorWilly Tarreau <w@1wt.eu>
Mon, 14 Oct 2013 21:44:03 +0000 (23:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Dec 2013 14:40:23 +0000 (15:40 +0100)
Proceeding like this is safer to ensure we don't forget a field.

src/session.c

index 94e4b0f9e12b3781c6523de626e1550506279c71..9afa1f517c73621a007e1c21b97bc0b16773b34d 100644 (file)
@@ -108,11 +108,10 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
        /* OK, we're keeping the session, so let's properly initialize the session.
         * We first have to initialize the client-side connection.
         */
-       cli_conn->obj_type = OBJ_TYPE_CONN;
+       conn_init(cli_conn);
        cli_conn->t.sock.fd = cfd;
        cli_conn->ctrl = l->proto;
-       cli_conn->flags = CO_FL_NONE | CO_FL_ADDR_FROM_SET;
-       cli_conn->err_code = CO_ER_NONE;
+       cli_conn->flags |= CO_FL_ADDR_FROM_SET;
        cli_conn->addr.from = *addr;
        cli_conn->target = &l->obj_type;
 
@@ -477,11 +476,6 @@ 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;
-       s->si[1].conn->target = NULL;
        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;
@@ -490,6 +484,8 @@ int session_complete(struct session *s)
        s->si[1].exp       = TICK_ETERNITY;
        s->si[1].flags     = SI_FL_NONE;
 
+       conn_init(s->si[1].conn);
+       s->si[1].conn->target = NULL;
        si_prepare_none(&s->si[1]);
 
        if (likely(s->fe->options2 & PR_O2_INDEPSTR))