]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: make use of conn_init() to initialize the connection
authorWilly Tarreau <w@1wt.eu>
Mon, 14 Oct 2013 21:40:49 +0000 (23:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Dec 2013 14:40:23 +0000 (15:40 +0100)
Use this instead of open-coding to initialize the outgoing connection.
It saves us from forgetting some fields.

src/peers.c

index 6a1a8a4ae3a2fa157b5035bca8c702dd56d8c684..f3754cb7c3b567f2cf49f4f960dab7b90a6cec8d 100644 (file)
@@ -1177,12 +1177,6 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
        s->si[0].appctx.st0 = PEER_SESSION_CONNECT;
        s->si[0].appctx.ctx.peers.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;
-       s->si[1].conn->target = &s->be->obj_type;
-
        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;
@@ -1196,10 +1190,11 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
        /* will automatically prepare the stream interface to connect to the
         * pre-initialized connection in si->conn.
         */
+       conn_init(s->si[1].conn);
        si_prepare_conn(&s->si[1], peer->proto, peer->xprt);
 
        session_init_srv_conn(s);
-       s->target = &s->be->obj_type;
+       s->si[1].conn->target = s->target = &s->be->obj_type;
        s->pend_pos = NULL;
 
        /* init store persistence */