Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

兼容3.0和4.0版本 #89

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-cayman
37 changes: 26 additions & 11 deletions hircluster.c
Original file line number Diff line number Diff line change
@@ -853,7 +853,7 @@ parse_cluster_slots(redisClusterContext *cc,
}else{
elem_nodes = elem_slots->element[idx];
if(elem_nodes->type != REDIS_REPLY_ARRAY ||
elem_nodes->elements != 3){
elem_nodes->elements < 2){
__redisClusterSetError(cc, REDIS_ERR_OTHER,
"Command(cluster slots) reply error: "
"nodes sub_reply is not an correct array.");
@@ -3436,23 +3436,27 @@ static void *command_post_fragment(redisClusterContext *cc,
reply = sub_command->reply;
if(reply == NULL)
{
listReleaseIterator(list_iter);
return NULL;
}
else if(reply->type == REDIS_REPLY_ERROR)
{
listReleaseIterator(list_iter);
return reply;
}

if (command->type == CMD_REQ_REDIS_MGET) {
if(reply->type != REDIS_REPLY_ARRAY)
{
__redisClusterSetError(cc,REDIS_ERR_OTHER,"reply type is error(here only can be array)");
listReleaseIterator(list_iter);
return NULL;
}
}else if(command->type == CMD_REQ_REDIS_DEL){
if(reply->type != REDIS_REPLY_INTEGER)
{
__redisClusterSetError(cc,REDIS_ERR_OTHER,"reply type is error(here only can be integer)");
listReleaseIterator(list_iter);
return NULL;
}

@@ -3462,13 +3466,19 @@ static void *command_post_fragment(redisClusterContext *cc,
reply->len != 2 || strcmp(reply->str, REDIS_STATUS_OK) != 0)
{
__redisClusterSetError(cc,REDIS_ERR_OTHER,"reply type is error(here only can be status and ok)");
listReleaseIterator(list_iter);
return NULL;
}
}else {
NOT_REACHED();
}
}

if(list_iter != NULL)
{
listReleaseIterator(list_iter);
}

reply = hi_calloc(1,sizeof(*reply));

if (reply == NULL)
@@ -3677,16 +3687,23 @@ void *redisClusterFormattedCommand(redisClusterContext *cc, char *cmd, int len)
reply = redis_cluster_command_execute(cc, sub_command);
if(reply == NULL)
{
listReleaseIterator(list_iter);
goto error;
}
else if(reply->type == REDIS_REPLY_ERROR)
{
listReleaseIterator(list_iter);
goto done;
}

sub_command->reply = reply;
}

if(list_iter != NULL)
{
listReleaseIterator(list_iter);
}

reply = command_post_fragment(cc, command, commands);

done:
@@ -3699,11 +3716,6 @@ void *redisClusterFormattedCommand(redisClusterContext *cc, char *cmd, int len)
listRelease(commands);
}

if(list_iter != NULL)
{
listReleaseIterator(list_iter);
}

cc->retry_count = 0;

return reply;
@@ -3721,11 +3733,6 @@ void *redisClusterFormattedCommand(redisClusterContext *cc, char *cmd, int len)
listRelease(commands);
}

if(list_iter != NULL)
{
listReleaseIterator(list_iter);
}

cc->retry_count = 0;

return NULL;
@@ -4135,6 +4142,7 @@ int redisClusterGetReply(redisClusterContext *cc, void **reply) {
{
__redisClusterSetError(cc,REDIS_ERR_OTHER,
"sub_command is null");
listReleaseIterator(list_iter);
goto error;
}

@@ -4143,17 +4151,24 @@ int redisClusterGetReply(redisClusterContext *cc, void **reply) {
{
__redisClusterSetError(cc,REDIS_ERR_OTHER,
"sub_command slot_num is less then zero");
listReleaseIterator(list_iter);
goto error;
}

if(__redisClusterGetReply(cc, slot_num, &sub_reply) != REDIS_OK)
{
listReleaseIterator(list_iter);
goto error;
}

sub_command->reply = sub_reply;
}

if(list_iter != NULL)
{
listReleaseIterator(list_iter);
}

*reply = command_post_fragment(cc, command, commands);
if(*reply == NULL)
{