aboutsummaryrefslogtreecommitdiffstats
path: root/perl/rspamd.xs
diff options
context:
space:
mode:
authorcebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>2008-09-21 07:23:29 +0400
committercebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>2008-09-21 07:23:29 +0400
commit82e2d7ab53eb60bdc52d2e736b097d68d489aa9c (patch)
treeec77bdc53fdde60016583b0ca012eb11d57f5302 /perl/rspamd.xs
parentf67c28af2aaf03b60e5bbf606fc694b04ccc68c5 (diff)
downloadrspamd-82e2d7ab53eb60bdc52d2e736b097d68d489aa9c.tar.gz
rspamd-82e2d7ab53eb60bdc52d2e736b097d68d489aa9c.zip
* Use internal task pool for memcached operation exported for perl
* Make AV reference mortal as it is described in perlxs (3)
Diffstat (limited to 'perl/rspamd.xs')
-rw-r--r--perl/rspamd.xs15
1 files changed, 8 insertions, 7 deletions
diff --git a/perl/rspamd.xs b/perl/rspamd.xs
index 1632ebade..6bbaaddf1 100644
--- a/perl/rspamd.xs
+++ b/perl/rspamd.xs
@@ -13,6 +13,7 @@
#include "../config.h"
#include "../main.h"
#include "../perl.h"
+#include "../mem_pool.h"
#define perl_set_session(r) \
r = INT2PTR(struct worker_task *, SvIV((SV *) SvRV(ST(0))))
@@ -136,14 +137,14 @@ read_memcached_key (r, key, datalen, callback)
callback = SvRV(ST(3));
/* Copy old ctx to new one */
- ctx = malloc (sizeof (memcached_ctx_t));
+ ctx = memory_pool_alloc (r->task_pool, sizeof (memcached_ctx_t));
if (ctx == NULL) {
XSRETURN_UNDEF;
}
memcpy (ctx, r->memc_ctx, sizeof (memcached_ctx_t));
/* Set perl callback */
ctx->callback = perl_call_memcached_callback;
- callback_data = malloc (sizeof (struct _param));
+ callback_data = memory_pool_alloc (r->task_pool, sizeof (struct _param));
if (callback_data == NULL) {
XSRETURN_UNDEF;
}
@@ -152,7 +153,7 @@ read_memcached_key (r, key, datalen, callback)
ctx->callback_data = (void *)callback_data;
strlcpy (param.key, key, sizeof (param.key));
- param.buf = malloc (datalen);
+ param.buf = memory_pool_alloc (r->task_pool, datalen);
if (param.buf != NULL) {
param.bufsize = datalen;
}
@@ -186,14 +187,14 @@ write_memcached_key (r, key, data, expire, callback)
callback = SvRV(ST(4));
/* Copy old ctx to new one */
- ctx = malloc (sizeof (memcached_ctx_t));
+ ctx = memory_pool_alloc (r->task_pool, sizeof (memcached_ctx_t));
if (ctx == NULL) {
XSRETURN_UNDEF;
}
memcpy (ctx, r->memc_ctx, sizeof (memcached_ctx_t));
/* Set perl callback */
ctx->callback = perl_call_memcached_callback;
- callback_data = malloc (sizeof (struct _param));
+ callback_data = memory_pool_alloc (r->task_pool, sizeof (struct _param));
if (callback_data == NULL) {
XSRETURN_UNDEF;
}
@@ -231,14 +232,14 @@ delete_memcached_key (r, key, callback)
callback = SvRV(ST(2));
/* Copy old ctx to new one */
- ctx = malloc (sizeof (memcached_ctx_t));
+ ctx = memory_pool_alloc (r->task_pool, sizeof (memcached_ctx_t));
if (ctx == NULL) {
XSRETURN_UNDEF;
}
memcpy (ctx, r->memc_ctx, sizeof (memcached_ctx_t));
/* Set perl callback */
ctx->callback = perl_call_memcached_callback;
- callback_data = malloc (sizeof (struct _param));
+ callback_data = memory_pool_alloc (r->task_pool, sizeof (struct _param));
if (callback_data == NULL) {
XSRETURN_UNDEF;
}