فهرست منبع

ndb_redis: redisc_free_reply only frees redisReply structure.

- freeing whole redisc_reply_t structure causes a bug, so better remove only inner data.
Vicente Hernando 13 سال پیش
والد
کامیت
b237db588f
2فایلهای تغییر یافته به همراه6 افزوده شده و 19 حذف شده
  1. 3 4
      modules/ndb_redis/doc/ndb_redis_admin.xml
  2. 3 15
      modules/ndb_redis/redis_client.c

+ 3 - 4
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>

+ 3 - 15
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;
 	}