diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2012-11-16 19:39:37 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2012-11-16 19:39:37 +0000 |
commit | 055fbd10787a85b4fc8db3e618a7dfc390f82c13 (patch) | |
tree | 6427913ea67031d0ca3068958160dfe496a8e244 /src/s_auth.c | |
parent | b2a2b2dc1adca9f089c693b520978dc4dd0e70bf (diff) |
- Implemented memory pool allocator which basically is taken from Tor's
mempool allocator for Tor cells
- Fixed compile warnings in conf_class.c
- ./configure --enable-assert works again
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@1654 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'src/s_auth.c')
-rw-r--r-- | src/s_auth.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/s_auth.c b/src/s_auth.c index c14cb22..3c4f2a7 100644 --- a/src/s_auth.c +++ b/src/s_auth.c @@ -39,7 +39,6 @@ #include "fdlist.h" #include "s_auth.h" #include "conf.h" -#include "balloc.h" #include "client.h" #include "event.h" #include "hook.h" @@ -50,6 +49,7 @@ #include "s_bsd.h" #include "log.h" #include "send.h" +#include "mempool.h" static const char *HeaderMessages[] = { @@ -76,7 +76,7 @@ enum { #define sendheader(c, i) sendto_one((c), HeaderMessages[(i)], me.name) -static BlockHeap *auth_heap = NULL; +static mp_pool_t *auth_pool = NULL; static dlink_list auth_doing_list = { NULL, NULL, 0 }; static EVH timeout_auth_queries_event; @@ -94,7 +94,7 @@ struct Callback *auth_cb = NULL; void init_auth(void) { - auth_heap = BlockHeapCreate("auth", sizeof(struct AuthRequest), AUTH_HEAP_SIZE); + auth_pool = mp_pool_new(sizeof(struct AuthRequest), MP_CHUNK_SIZE_AUTH); auth_cb = register_callback("start_auth", start_auth); eventAddIsh("timeout_auth_queries_event", timeout_auth_queries_event, NULL, 1); } @@ -105,8 +105,9 @@ init_auth(void) static struct AuthRequest * make_auth_request(struct Client *client) { - struct AuthRequest *request = BlockHeapAlloc(auth_heap); + struct AuthRequest *request = mp_pool_get(auth_pool); + memset(request, 0, sizeof(*request)); client->localClient->auth = request; request->client = client; request->timeout = CurrentTime + CONNECTTIMEOUT; @@ -129,7 +130,7 @@ release_auth_client(struct AuthRequest *auth) client->localClient->auth = NULL; dlinkDelete(&auth->node, &auth_doing_list); - BlockHeapFree(auth_heap, auth); + mp_pool_release(auth); /* * When a client has auth'ed, we want to start reading what it sends @@ -594,5 +595,5 @@ delete_auth(struct AuthRequest *auth) fd_close(&auth->fd); dlinkDelete(&auth->node, &auth_doing_list); - BlockHeapFree(auth_heap, auth); + mp_pool_release(auth); } |