Skip to content

Commit

Permalink
Remove internal func __valkeyClusterGetReply()
Browse files Browse the repository at this point in the history
  • Loading branch information
bjosv committed Jun 21, 2024
1 parent 4149a4b commit b425b4d
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/valkeycluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -2112,21 +2112,6 @@ static int valkeyClusterGetReplyFromNode(valkeyClusterContext *cc,
return VALKEY_OK;
}

static int __valkeyClusterGetReply(valkeyClusterContext *cc, int slot_num,
void **reply) {
valkeyClusterNode *node;

if (cc == NULL || slot_num < 0 || reply == NULL)
return VALKEY_ERR;

node = node_get_by_table(cc, (uint32_t)slot_num);
if (node == NULL) {
return VALKEY_ERR;
}

return valkeyClusterGetReplyFromNode(cc, node, reply);
}

/* Parses a MOVED or ASK error reply and returns the destination node. The slot
* is returned by pointer, if provided. */
static valkeyClusterNode *getNodeFromRedirectReply(valkeyClusterContext *cc,
Expand Down Expand Up @@ -3414,6 +3399,7 @@ int valkeyClusterGetReply(valkeyClusterContext *cc, void **reply) {
listNode *list_command, *list_sub_command;
int slot_num;
void *sub_reply;
valkeyClusterNode *node;

if (cc == NULL || reply == NULL)
return VALKEY_ERR;
Expand Down Expand Up @@ -3445,7 +3431,9 @@ int valkeyClusterGetReply(valkeyClusterContext *cc, void **reply) {
if (slot_num >= 0) {
/* Command was sent via single slot */
listDelNode(cc->requests, list_command);
return __valkeyClusterGetReply(cc, slot_num, reply);
if ((node = node_get_by_table(cc, (uint32_t)slot_num)) == NULL)
return VALKEY_ERR;
return valkeyClusterGetReplyFromNode(cc, node, reply);

} else if (command->node_addr) {
/* Command was sent to a single node */
Expand Down Expand Up @@ -3488,8 +3476,10 @@ int valkeyClusterGetReply(valkeyClusterContext *cc, void **reply) {
"sub_command slot_num is less then zero");
goto error;
}

if (__valkeyClusterGetReply(cc, slot_num, &sub_reply) != VALKEY_OK) {
if ((node = node_get_by_table(cc, (uint32_t)slot_num)) == NULL) {
goto error;
}
if (valkeyClusterGetReplyFromNode(cc, node, &sub_reply) != VALKEY_OK) {
goto error;
}

Expand Down

0 comments on commit b425b4d

Please sign in to comment.