Przeglądaj źródła

ndb_redis: redis_cmd() check reply type to detect command errors

fix #2300

(cherry picked from commit d00b14704805d728f5a845a6af900eff1ed372ac)
Victor Seva 5 lat temu
rodzic
commit
13f4b108e1
1 zmienionych plików z 15 dodań i 0 usunięć
  1. 15 0
      src/modules/ndb_redis/redis_client.c

+ 15 - 0
src/modules/ndb_redis/redis_client.c

@@ -953,6 +953,14 @@ int redisc_exec(str *srv, str *res, str *cmd, ...)
 			goto error_exec;
 		}
 	}
+
+	LM_DBG("rpl->rplRedis->type:%d\n", rpl->rplRedis->type);
+	if(rpl->rplRedis->type == REDIS_REPLY_ERROR) {
+		LM_ERR("Redis error:%.*s\n",
+			(int)rpl->rplRedis->len, rpl->rplRedis->str);
+		goto error_exec;
+	}
+
 	if (check_cluster_reply(rpl->rplRedis, &rsrv)) {
 		LM_DBG("rsrv->ctxRedis = %p\n", rsrv->ctxRedis);
 		if(rsrv->ctxRedis==NULL)
@@ -987,6 +995,13 @@ int redisc_exec(str *srv, str *res, str *cmd, ...)
 				goto error_exec;
 			}
 		}
+
+		LM_DBG("rpl->rplRedis->type:%d\n", rpl->rplRedis->type);
+		if(rpl->rplRedis->type == REDIS_REPLY_ERROR) {
+			LM_ERR("Redis error:%.*s\n",
+				(int)rpl->rplRedis->len, rpl->rplRedis->str);
+			goto error_exec;
+		}
 	}
 	cmd->s[cmd->len] = c;
 	rsrv->disable.consecutive_errors = 0;