Module: sip-router Branch: master Commit: b237db588f4de8eb3e1f8bf321e010ce5f9cded3 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b237db58...
Author: Vicente Hernando vhernando@systemonenoc.com Committer: Vicente Hernando vhernando@systemonenoc.com Date: Fri Jul 6 12:12:36 2012 -0400
ndb_redis: redisc_free_reply only frees redisReply structure.
- freeing whole redisc_reply_t structure causes a bug, so better remove only inner data.
---
modules/ndb_redis/doc/ndb_redis_admin.xml | 7 +++---- modules/ndb_redis/redis_client.c | 18 +++--------------- 2 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/modules/ndb_redis/doc/ndb_redis_admin.xml b/modules/ndb_redis/doc/ndb_redis_admin.xml index 54d6788..ec48d7f 100644 --- a/modules/ndb_redis/doc/ndb_redis_admin.xml +++ b/modules/ndb_redis/doc/ndb_redis_admin.xml @@ -168,14 +168,13 @@ if(redis_cmd("srvN", "HMGET foo_key field1 field3", "r")) { <function moreinfo="none">redis_free(replyid)</function> </title> <para> - Free a previous reply from memory. + Frees data in a previous reply from memory. After this function call, accessing to a freed replyid returns null value. </para> <para> It is not necessary to free a reply to use it again in a new redis_cmd function. When ndb_redis module closes, all pending replies are freed - automatically, so you only need to use this function if you perform a - lot of redis command requests with different replyid. + automatically. </para> <example> <title><function>redis_free</function> usage</title> @@ -184,7 +183,7 @@ if(redis_cmd("srvN", "HMGET foo_key field1 field3", "r")) { After a redis command call: redis_cmd("srvN", "INCR cnt", "r");
-when reply not used anymore: +free reply data: redis_free("r"); ... </programlisting> diff --git a/modules/ndb_redis/redis_client.c b/modules/ndb_redis/redis_client.c index ae97583..267c8f5 100644 --- a/modules/ndb_redis/redis_client.c +++ b/modules/ndb_redis/redis_client.c @@ -407,37 +407,25 @@ redisc_reply_t *redisc_get_reply(str *name) */ int redisc_free_reply(str *name) { - redisc_reply_t *rpl, *prev_rpl, *next_rpl; + redisc_reply_t *rpl, *next_rpl; unsigned int hid;
hid = get_hash1_raw(name->s, name->len);
- prev_rpl = NULL; rpl = _redisc_rpl_list; while(rpl) {
if(rpl->hname==hid && rpl->rname.len==name->len && strncmp(rpl->rname.s, name->s, name->len)==0) { next_rpl = rpl->next; - if(rpl->rplRedis) + if(rpl->rplRedis) { freeReplyObject(rpl->rplRedis); - - if(rpl->rname.s != NULL) - pkg_free(rpl->rname.s); - - pkg_free(rpl); - - if(prev_rpl==NULL) { - /* We delete first element in the list. */ - _redisc_rpl_list = next_rpl; - } else { - prev_rpl->next = next_rpl; + rpl->rplRedis = NULL; }
return 0; }
- prev_rpl = rpl; rpl = rpl->next; }