MINOR: session: group buffer allocations together

We'll soon want to release buffers together upon failure so we need to
allocate them after the channels. Let's change this now. There's no
impact on the behaviour, only the error path is unrolled slightly
differently. The same was done in peers.
This commit is contained in:
Willy Tarreau 2014-11-25 19:54:11 +01:00
parent 4428a29e52
commit 909e267be0
2 changed files with 12 additions and 12 deletions

View File

@ -1256,9 +1256,6 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
s->req->rto = s->fe->timeout.client;
s->req->wto = s->be->timeout.server;
if (unlikely(b_alloc(&s->req->buf) == NULL))
goto out_fail_req_buf; /* no memory */
if ((s->rep = pool_alloc2(pool2_channel)) == NULL)
goto out_fail_rep; /* no memory */
@ -1280,6 +1277,9 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
s->rep->flags |= CF_READ_DONTWAIT;
if (unlikely(b_alloc(&s->req->buf) == NULL))
goto out_fail_req_buf; /* no memory */
if (unlikely(b_alloc(&s->rep->buf) == NULL))
goto out_fail_rep_buf; /* no memory */
@ -1300,10 +1300,10 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
/* Error unrolling */
out_fail_rep_buf:
pool_free2(pool2_channel, s->rep);
out_fail_rep:
b_free(&s->req->buf);
out_fail_req_buf:
pool_free2(pool2_channel, s->rep);
out_fail_rep:
pool_free2(pool2_channel, s->req);
out_fail_req:
conn_free(conn);

View File

@ -492,11 +492,8 @@ int session_complete(struct session *s)
s->req->wex = TICK_ETERNITY;
s->req->analyse_exp = TICK_ETERNITY;
if (unlikely(b_alloc(&s->req->buf) == NULL))
goto out_free_req; /* no memory */
if (unlikely((s->rep = pool_alloc2(pool2_channel)) == NULL))
goto out_free_req_buf; /* no memory */
goto out_free_req; /* no memory */
channel_init(s->rep);
s->rep->prod = &s->si[1];
@ -515,9 +512,12 @@ int session_complete(struct session *s)
s->rep->wex = TICK_ETERNITY;
s->rep->analyse_exp = TICK_ETERNITY;
if (unlikely(b_alloc(&s->rep->buf) == NULL))
if (unlikely(b_alloc(&s->req->buf) == NULL))
goto out_free_rep; /* no memory */
if (unlikely(b_alloc(&s->rep->buf) == NULL))
goto out_free_req_buf; /* no memory */
txn = &s->txn;
/* Those variables will be checked and freed if non-NULL in
* session.c:session_free(). It is important that they are
@ -566,10 +566,10 @@ int session_complete(struct session *s)
/* Error unrolling */
out_free_rep_buf:
b_free(&s->rep->buf);
out_free_rep:
pool_free2(pool2_channel, s->rep);
out_free_req_buf:
b_free(&s->req->buf);
out_free_rep:
pool_free2(pool2_channel, s->rep);
out_free_req:
pool_free2(pool2_channel, s->req);
out_free_task: