summaryrefslogtreecommitdiffstats
path: root/worker.c
diff options
context:
space:
mode:
authorcebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>2008-09-18 19:27:53 +0400
committercebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>2008-09-18 19:27:53 +0400
commit2c879bedd2c9b835fb083a152e5f09d48b1dbca6 (patch)
tree30dfc5cd240481ec6cd7320eb2de79e02017cbf8 /worker.c
parentbb2e8a89d2e4caf5345e565f4da5aeb6fc39655b (diff)
downloadrspamd-2c879bedd2c9b835fb083a152e5f09d48b1dbca6.tar.gz
rspamd-2c879bedd2c9b835fb083a152e5f09d48b1dbca6.zip
* Add memory pool support.
- memory pools would be used in modules for allocating task specific data without freeing it separately - memory pools growth is implemented as multiplying by 2 its length (for avoiding multiply reallocs) - when memory pool is freed all data that was allocated from this pool is freed too
Diffstat (limited to 'worker.c')
-rw-r--r--worker.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/worker.c b/worker.c
index 34a096629..8493aff25 100644
--- a/worker.c
+++ b/worker.c
@@ -97,6 +97,9 @@ free_task (struct worker_task *task)
memc_close_ctx (task->memc_ctx);
free (task->memc_ctx);
}
+ if (task->task_pool) {
+ memory_pool_free (task->task_pool);
+ }
while (!TAILQ_EMPTY (&task->urls)) {
cur = TAILQ_FIRST (&task->urls);
TAILQ_REMOVE (&task->urls, cur, next);
@@ -610,6 +613,7 @@ accept_socket (int fd, short what, void *arg)
TAILQ_INIT (&new_task->results);
TAILQ_INIT (&new_task->parts);
new_task->memc_ctx = malloc (sizeof (memcached_ctx_t));
+ new_task->task_pool = memory_pool_new (1024);
if (new_task->memc_ctx == NULL) {
msg_err ("accept_socket: cannot allocate memory for memcached ctx, %m");
}