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

Abrandoned/cleanup warnings #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int redisClustervAppendCommand(redisClusterContext *cc, const char *format, va_l
int redisClusterAppendCommand(redisClusterContext *cc, const char *format, ...);
int redisClusterAppendCommandArgv(redisClusterContext *cc, int argc, const char **argv, const size_t *argvlen);
int redisClusterGetReply(redisClusterContext *cc, void **reply);
void redisCLusterReset(redisClusterContext *cc);
void redisClusterReset(redisClusterContext *cc);

redisClusterAsyncContext *redisClusterAsyncConnect(const char *addrs, int flags);
int redisClusterAsyncSetConnectCallback(redisClusterAsyncContext *acc, redisConnectCallback *fn);
Expand Down Expand Up @@ -145,9 +145,9 @@ subsequent replies. The return value for this function is either `REDIS_OK` or `
the latter means an error occurred while reading a reply. Just as with the other commands,
the `err` field in the context can be used to find out what the cause of this error is.
```c
void redisCLusterReset(redisClusterContext *cc);
void redisClusterReset(redisClusterContext *cc);
```
Warning: You must call `redisCLusterReset` function after one pipelining anyway.
Warning: You must call `redisClusterReset` function after one pipelining anyway.

The following examples shows a simple cluster pipeline:
```c
Expand All @@ -158,7 +158,7 @@ redisClusterGetReply(clusterContext,&reply); // reply for SET
freeReplyObject(reply);
redisClusterGetReply(clusterContext,&reply); // reply for GET
freeReplyObject(reply);
redisCLusterReset(clusterContext);
redisClusterReset(clusterContext);
```
This API can also be used to implement a blocking subscriber:
```c
Expand All @@ -168,7 +168,7 @@ while(redisClusterGetReply(clusterContext,&reply) == REDIS_OK) {
// consume message
freeReplyObject(reply);
}
redisCLusterReset(clusterContext);
redisClusterReset(clusterContext);
```

## Cluster asynchronous API
Expand Down
3 changes: 2 additions & 1 deletion command.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __COMMAND_H_

#include <stdint.h>
#include <stdlib.h>

#include "hiredis.h"
#include "adlist.h"
Expand Down Expand Up @@ -162,7 +163,7 @@ struct cmd {
unsigned quit:1; /* quit request? */
unsigned noforward:1; /* not need forward (example: ping) */

int slot_num; /* this command should send to witch slot?
int slot_num; /* this command should send to which slot?
* -1:the keys in this command cross different slots*/
struct cmd **frag_seq; /* sequence of fragment command, map from keys to fragments*/

Expand Down
18 changes: 8 additions & 10 deletions hircluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,7 @@ static void cluster_nodes_swap_ctx(dict *nodes_f, dict *nodes_t)
static int
cluster_slot_start_cmp(const void *t1, const void *t2)
{
const cluster_slot **s1 = t1, **s2 = t2;

return (*s1)->start > (*s2)->start?1:-1;
return ((cluster_slot*)t1)->start > ((cluster_slot*)t2)->start ? 1 : -1;
}

static int
Expand Down Expand Up @@ -2377,7 +2375,7 @@ static cluster_node *node_get_by_table(redisClusterContext *cc, uint32_t slot_nu

}

static cluster_node *node_get_witch_connected(redisClusterContext *cc)
static cluster_node *node_get_which_connected(redisClusterContext *cc)
{
dictIterator *di;
dictEntry *de;
Expand Down Expand Up @@ -2507,7 +2505,7 @@ static char * cluster_config_get(redisClusterContext *cc,
return NULL;
}

node = node_get_witch_connected(cc);
node = node_get_which_connected(cc);
if(node == NULL)
{
__redisClusterSetError(cc,
Expand Down Expand Up @@ -2801,7 +2799,7 @@ static void *redis_cluster_command_execute(redisClusterContext *cc,
}
else if(c->err)
{
node = node_get_witch_connected(cc);
node = node_get_which_connected(cc);
if(node == NULL)
{
__redisClusterSetError(cc, REDIS_ERR_OTHER, "no reachable node in cluster");
Expand Down Expand Up @@ -3766,7 +3764,7 @@ int redisClusterAppendCommandArgv(redisClusterContext *cc,
return ret;
}

static int redisCLusterSendAll(redisClusterContext *cc)
static int redisClusterSendAll(redisClusterContext *cc)
{
dictIterator *di;
dictEntry *de;
Expand Down Expand Up @@ -3901,7 +3899,7 @@ int redisClusterGetReply(redisClusterContext *cc, void **reply) {
return REDIS_ERR;
}

void redisCLusterReset(redisClusterContext *cc)
void redisClusterReset(redisClusterContext *cc)
{
redisContext *c = NULL;
int status;
Expand All @@ -3912,7 +3910,7 @@ void redisCLusterReset(redisClusterContext *cc)
return;
}

redisCLusterSendAll(cc);
redisClusterSendAll(cc);

do{
status = redisClusterGetReply(cc, &reply);
Expand Down Expand Up @@ -4224,7 +4222,7 @@ static void redisClusterAsyncCallback(redisAsyncContext *ac, void *r, void *priv
if(reply == NULL)
{
//Note:
//I can't decide witch is the best way to deal with connect
//I can't decide which is the best way to deal with connect
//problem for hiredis cluster async api.
//But now the way is : when enough null reply for a node,
//we will update the route after the cluster node timeout.
Expand Down
2 changes: 1 addition & 1 deletion hircluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int redisClustervAppendCommand(redisClusterContext *cc, const char *format, va_l
int redisClusterAppendCommand(redisClusterContext *cc, const char *format, ...);
int redisClusterAppendCommandArgv(redisClusterContext *cc, int argc, const char **argv, const size_t *argvlen);
int redisClusterGetReply(redisClusterContext *cc, void **reply);
void redisCLusterReset(redisClusterContext *cc);
void redisClusterReset(redisClusterContext *cc);

int cluster_update_route(redisClusterContext *cc);
int test_cluster_update_route(redisClusterContext *cc);
Expand Down