ndb_redis: redisc_free_reply only frees redisReply structure.
authorVicente Hernando <vhernando@systemonenoc.com>
Fri, 6 Jul 2012 16:12:36 +0000 (12:12 -0400)
committerVicente Hernando <vhernando@systemonenoc.com>
Fri, 6 Jul 2012 16:18:53 +0000 (18:18 +0200)
- freeing whole redisc_reply_t structure causes a bug, so better remove only inner data.

modules/ndb_redis/doc/ndb_redis_admin.xml
modules/ndb_redis/redis_client.c

index 54d6788..ec48d7f 100644 (file)
@@ -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>
index ae97583..267c8f5 100644 (file)
@@ -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;
        }