From 5ff29e4f32beae01133d002f599e9a876da6ee79 Mon Sep 17 00:00:00 2001 From: Konstantin Shulgin <konstantin.shulgin@gmail.com> Date: Wed, 18 Jan 2012 18:14:47 +0400 Subject: [PATCH] Test suite: Valgrind tests was fixed. --- mod/box/box.m | 1 + mod/box/memcached.h | 3 +++ mod/box/memcached.m | 19 ++++++++++++++----- test/share/tarantool_box.sup | 11 +++++++++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/mod/box/box.m b/mod/box/box.m index b3489b9010..e50d4ba9c8 100644 --- a/mod/box/box.m +++ b/mod/box/box.m @@ -1428,6 +1428,7 @@ void mod_free(void) { space_free(); + memcached_free(); } void diff --git a/mod/box/memcached.h b/mod/box/memcached.h index b5ec2c64bb..10d4df108c 100644 --- a/mod/box/memcached.h +++ b/mod/box/memcached.h @@ -33,6 +33,9 @@ struct tarantool_cfg; void memcached_init(); +void +memcached_free(); + void memcached_space_init(); diff --git a/mod/box/memcached.m b/mod/box/memcached.m index 903b58ca82..1209cb3cbe 100644 --- a/mod/box/memcached.m +++ b/mod/box/memcached.m @@ -47,6 +47,7 @@ static int stat_base; static struct fiber *memcached_expire = NULL; static Index *memcached_index; +static struct iterator *memcached_it; /* memcached tuple format: <key, meta, data> */ @@ -418,6 +419,13 @@ memcached_init(void) memcached_index = space[cfg.memcached_space].index[0]; } +void +memcached_free() +{ + if (memcached_it) + memcached_it->free(memcached_it); +} + void memcached_space_init() { @@ -488,17 +496,17 @@ memcached_expire_loop(void *data __attribute__((unused))) struct box_tuple *tuple = NULL; say_info("memcached expire fiber started"); - struct iterator *it = [memcached_index allocIterator]; + memcached_it = [memcached_index allocIterator]; @try { restart: if (tuple == NULL) - [memcached_index initIterator: it]; + [memcached_index initIterator: memcached_it]; struct tbuf *keys_to_delete = tbuf_alloc(fiber->gc_pool); for (int j = 0; j < cfg.memcached_expire_per_loop; j++) { - tuple = it->next(it); + tuple = memcached_it->next(memcached_it); if (tuple == NULL) break; @@ -513,7 +521,8 @@ restart: fiber_gc(); goto restart; } @finally { - it->free(it); + memcached_it->free(memcached_it); + memcached_it = NULL; } } @@ -523,7 +532,7 @@ void memcached_start_expire() return; assert(memcached_expire == NULL); - memcached_expire = fiber_create("memecached_expire", -1, + memcached_expire = fiber_create("memcached_expire", -1, -1, memcached_expire_loop, NULL); if (memcached_expire == NULL) say_error("can't start the expire fiber"); diff --git a/test/share/tarantool_box.sup b/test/share/tarantool_box.sup index e8cef3c8bf..b7fbfebafa 100644 --- a/test/share/tarantool_box.sup +++ b/test/share/tarantool_box.sup @@ -139,6 +139,17 @@ ... } +{ + <box upadte command> + Memcheck:Leak + fun:salloc + fun:tuple_alloc + fun:prepare_update + fun:box_dispatch + fun:box_process* + ... +} + ## ## tarantool/lua suppressions ## -- GitLab