From: Willy Tarreau Date: Mon, 14 Oct 2013 21:44:03 +0000 (+0200) Subject: MINOR: session: use conn_init() to initialize the connections X-Git-Tag: v1.5-dev20~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f826c2205b07e723a98bd3a4d6eba2cb33ea45d8;p=thirdparty%2Fhaproxy.git MINOR: session: use conn_init() to initialize the connections Proceeding like this is safer to ensure we don't forget a field. --- diff --git a/src/session.c b/src/session.c index 94e4b0f9e1..9afa1f517c 100644 --- a/src/session.c +++ b/src/session.c @@ -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))