diff --git a/include/proto/buffers.h b/include/proto/buffers.h index 6c3996218..74efe8fdf 100644 --- a/include/proto/buffers.h +++ b/include/proto/buffers.h @@ -22,11 +22,19 @@ #ifndef _PROTO_BUFFERS_H #define _PROTO_BUFFERS_H +#include #include +#include #include +#include #include +extern struct pool_head *pool2_buffer; + +/* perform minimal intializations, report 0 in case of error, 1 if OK. */ +int init_buffer(); + /* Initializes all fields in the buffer. The ->rlim field is initialized last * so that the compiler can optimize it away if changed immediately after the * call to this function. diff --git a/include/types/buffers.h b/include/types/buffers.h index 9b781b842..09d1e3419 100644 --- a/include/types/buffers.h +++ b/include/types/buffers.h @@ -73,9 +73,6 @@ struct buffer { char data[BUFSIZE]; }; -#define sizeof_buffer sizeof(struct buffer) -extern void **pool_buffer; - #endif /* _TYPES_BUFFERS_H */ diff --git a/src/buffers.c b/src/buffers.c index 5739fcf52..658539c3a 100644 --- a/src/buffers.c +++ b/src/buffers.c @@ -15,9 +15,19 @@ #include #include +#include #include -void **pool_buffer = NULL; +struct pool_head *pool2_buffer; + + +/* perform minimal intializations, report 0 in case of error, 1 if OK. */ +int init_buffer() +{ + pool2_buffer = create_pool("buffer", sizeof(struct buffer), MEM_F_SHARED); + return pool2_buffer != NULL; +} + /* writes bytes from message to buffer . Returns 0 in case of * success, or the number of bytes available otherwise. diff --git a/src/client.c b/src/client.c index 6afb20636..6a1a3dfb6 100644 --- a/src/client.c +++ b/src/client.c @@ -347,7 +347,7 @@ int event_accept(int fd) { write(1, trash, len); } - if ((s->req = pool_alloc(buffer)) == NULL) { /* no memory */ + if ((s->req = pool_alloc2(pool2_buffer)) == NULL) { /* no memory */ if (txn->hdr_idx.v != NULL) pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v); if (txn->rsp.cap != NULL) @@ -369,8 +369,8 @@ int event_accept(int fd) { s->req->wto = s->be->srvtimeout; s->req->cto = s->be->srvtimeout; - if ((s->rep = pool_alloc(buffer)) == NULL) { /* no memory */ - pool_free(buffer, s->req); + if ((s->rep = pool_alloc2(pool2_buffer)) == NULL) { /* no memory */ + pool_free2(pool2_buffer, s->req); if (txn->hdr_idx.v != NULL) pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v); if (txn->rsp.cap != NULL) diff --git a/src/haproxy.c b/src/haproxy.c index 18bef8514..59c614978 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -374,6 +374,7 @@ void init(int argc, char **argv) localtime((time_t *)&now.tv_sec); start_date = now; + init_buffer(); init_task(); init_session(); init_proto_http(); @@ -661,7 +662,7 @@ void deinit(void) if (fdtab) free(fdtab); pool_destroy2(pool2_session); - pool_destroy(pool_buffer); + pool_destroy2(pool2_buffer); pool_destroy(pool_requri); pool_destroy2(pool2_task); pool_destroy(pool_capture); diff --git a/src/session.c b/src/session.c index 63bede3ee..1b574a00b 100644 --- a/src/session.c +++ b/src/session.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -38,9 +39,9 @@ void session_free(struct session *s) if (s->pend_pos) pendconn_free(s->pend_pos); if (s->req) - pool_free(buffer, s->req); + pool_free2(pool2_buffer, s->req); if (s->rep) - pool_free(buffer, s->rep); + pool_free2(pool2_buffer, s->rep); if (txn->hdr_idx.v != NULL) pool_free_to(s->fe->hdr_idx_pool, txn->hdr_idx.v);