From c53d169463d628d43e0ab20c7644d77bc835052d Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 25 Nov 2014 19:45:11 +0100 Subject: MINOR: buffers: only use b_free to release buffers We don't call pool_free2(pool2_buffers) anymore, we only call b_free() to do the job. This ensures that we can start to centralize the releasing of buffers. --- include/common/buffer.h | 7 +++++++ src/peers.c | 2 +- src/session.c | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/common/buffer.h b/include/common/buffer.h index b293f54..f325aed 100644 --- a/include/common/buffer.h +++ b/include/common/buffer.h @@ -409,6 +409,13 @@ static inline struct buffer *b_alloc(struct buffer **buf) return *buf; } +/* Releases buffer *buf. + */ +static inline void b_free(struct buffer **buf) +{ + pool_free2(pool2_buffer, *buf); +} + #endif /* _COMMON_BUFFER_H */ /* diff --git a/src/peers.c b/src/peers.c index af413c6..5371e49 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1302,7 +1302,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio out_fail_rep_buf: pool_free2(pool2_channel, s->rep); out_fail_rep: - pool_free2(pool2_buffer, s->req->buf); + b_free(&s->req->buf); out_fail_req_buf: pool_free2(pool2_channel, s->req); out_fail_req: diff --git a/src/session.c b/src/session.c index 6770ee4..ebe992b 100644 --- a/src/session.c +++ b/src/session.c @@ -565,11 +565,11 @@ int session_complete(struct session *s) /* Error unrolling */ out_free_rep_buf: - pool_free2(pool2_buffer, s->rep->buf); + b_free(&s->rep->buf); out_free_rep: pool_free2(pool2_channel, s->rep); out_free_req_buf: - pool_free2(pool2_buffer, s->req->buf); + b_free(&s->req->buf); out_free_req: pool_free2(pool2_channel, s->req); out_free_task: @@ -618,8 +618,8 @@ static void session_free(struct session *s) if (s->rep->pipe) put_pipe(s->rep->pipe); - pool_free2(pool2_buffer, s->req->buf); - pool_free2(pool2_buffer, s->rep->buf); + b_free(&s->req->buf); + b_free(&s->rep->buf); pool_free2(pool2_channel, s->req); pool_free2(pool2_channel, s->rep); -- 1.7.12.1