mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 14:50:59 +01:00
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:
parent
4428a29e52
commit
909e267be0
10
src/peers.c
10
src/peers.c
@ -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->rto = s->fe->timeout.client;
|
||||||
s->req->wto = s->be->timeout.server;
|
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)
|
if ((s->rep = pool_alloc2(pool2_channel)) == NULL)
|
||||||
goto out_fail_rep; /* no memory */
|
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;
|
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))
|
if (unlikely(b_alloc(&s->rep->buf) == NULL))
|
||||||
goto out_fail_rep_buf; /* no memory */
|
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 */
|
/* Error unrolling */
|
||||||
out_fail_rep_buf:
|
out_fail_rep_buf:
|
||||||
pool_free2(pool2_channel, s->rep);
|
|
||||||
out_fail_rep:
|
|
||||||
b_free(&s->req->buf);
|
b_free(&s->req->buf);
|
||||||
out_fail_req_buf:
|
out_fail_req_buf:
|
||||||
|
pool_free2(pool2_channel, s->rep);
|
||||||
|
out_fail_rep:
|
||||||
pool_free2(pool2_channel, s->req);
|
pool_free2(pool2_channel, s->req);
|
||||||
out_fail_req:
|
out_fail_req:
|
||||||
conn_free(conn);
|
conn_free(conn);
|
||||||
|
|||||||
@ -492,11 +492,8 @@ int session_complete(struct session *s)
|
|||||||
s->req->wex = TICK_ETERNITY;
|
s->req->wex = TICK_ETERNITY;
|
||||||
s->req->analyse_exp = 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))
|
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);
|
channel_init(s->rep);
|
||||||
s->rep->prod = &s->si[1];
|
s->rep->prod = &s->si[1];
|
||||||
@ -515,9 +512,12 @@ int session_complete(struct session *s)
|
|||||||
s->rep->wex = TICK_ETERNITY;
|
s->rep->wex = TICK_ETERNITY;
|
||||||
s->rep->analyse_exp = 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 */
|
goto out_free_rep; /* no memory */
|
||||||
|
|
||||||
|
if (unlikely(b_alloc(&s->rep->buf) == NULL))
|
||||||
|
goto out_free_req_buf; /* no memory */
|
||||||
|
|
||||||
txn = &s->txn;
|
txn = &s->txn;
|
||||||
/* Those variables will be checked and freed if non-NULL in
|
/* Those variables will be checked and freed if non-NULL in
|
||||||
* session.c:session_free(). It is important that they are
|
* session.c:session_free(). It is important that they are
|
||||||
@ -566,10 +566,10 @@ int session_complete(struct session *s)
|
|||||||
/* Error unrolling */
|
/* Error unrolling */
|
||||||
out_free_rep_buf:
|
out_free_rep_buf:
|
||||||
b_free(&s->rep->buf);
|
b_free(&s->rep->buf);
|
||||||
out_free_rep:
|
|
||||||
pool_free2(pool2_channel, s->rep);
|
|
||||||
out_free_req_buf:
|
out_free_req_buf:
|
||||||
b_free(&s->req->buf);
|
b_free(&s->req->buf);
|
||||||
|
out_free_rep:
|
||||||
|
pool_free2(pool2_channel, s->rep);
|
||||||
out_free_req:
|
out_free_req:
|
||||||
pool_free2(pool2_channel, s->req);
|
pool_free2(pool2_channel, s->req);
|
||||||
out_free_task:
|
out_free_task:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user