Commit bc3ec0f3 authored by Pieter Noordhuis's avatar Pieter Noordhuis
Browse files

Rename HIREDIS_BLOCK to REDIS_BLOCK

parent a7d76181
...@@ -557,7 +557,7 @@ static sds redisFormatCommand(const char *format, va_list ap) { ...@@ -557,7 +557,7 @@ static sds redisFormatCommand(const char *format, va_list ap) {
static int redisContextConnect(redisContext *c, const char *ip, int port) { static int redisContextConnect(redisContext *c, const char *ip, int port) {
char err[ANET_ERR_LEN]; char err[ANET_ERR_LEN];
if (c->flags & HIREDIS_BLOCK) { if (c->flags & REDIS_BLOCK) {
c->fd = anetTcpConnect(err,(char*)ip,port); c->fd = anetTcpConnect(err,(char*)ip,port);
} else { } else {
c->fd = anetTcpNonBlockConnect(err,(char*)ip,port); c->fd = anetTcpNonBlockConnect(err,(char*)ip,port);
...@@ -591,14 +591,14 @@ static redisContext *redisContextInit(redisReplyFunctions *fn) { ...@@ -591,14 +591,14 @@ static redisContext *redisContextInit(redisReplyFunctions *fn) {
* When no set of reply functions is given, the default set will be used. */ * When no set of reply functions is given, the default set will be used. */
redisContext *redisConnect(const char *ip, int port, redisReplyFunctions *fn) { redisContext *redisConnect(const char *ip, int port, redisReplyFunctions *fn) {
redisContext *c = redisContextInit(fn); redisContext *c = redisContextInit(fn);
c->flags |= HIREDIS_BLOCK; c->flags |= REDIS_BLOCK;
redisContextConnect(c,ip,port); redisContextConnect(c,ip,port);
return c; return c;
} }
redisContext *redisConnectNonBlock(const char *ip, int port, redisReplyFunctions *fn) { redisContext *redisConnectNonBlock(const char *ip, int port, redisReplyFunctions *fn) {
redisContext *c = redisContextInit(fn); redisContext *c = redisContextInit(fn);
c->flags &= ~HIREDIS_BLOCK; c->flags &= ~REDIS_BLOCK;
redisContextConnect(c,ip,port); redisContextConnect(c,ip,port);
return c; return c;
} }
...@@ -696,7 +696,7 @@ int redisBufferWrite(redisContext *c, int *done) { ...@@ -696,7 +696,7 @@ int redisBufferWrite(redisContext *c, int *done) {
static int redisCommandWriteBlock(redisContext *c, void **reply, char *str, size_t len) { static int redisCommandWriteBlock(redisContext *c, void **reply, char *str, size_t len) {
int wdone = 0; int wdone = 0;
void *aux = NULL; void *aux = NULL;
assert(c->flags & HIREDIS_BLOCK); assert(c->flags & REDIS_BLOCK);
c->obuf = sdscatlen(c->obuf,str,len); c->obuf = sdscatlen(c->obuf,str,len);
/* Write until done. */ /* Write until done. */
...@@ -721,7 +721,7 @@ static int redisCommandWriteBlock(redisContext *c, void **reply, char *str, size ...@@ -721,7 +721,7 @@ static int redisCommandWriteBlock(redisContext *c, void **reply, char *str, size
} }
static int redisCommandWriteNonBlock(redisContext *c, redisCallback *cb, char *str, size_t len) { static int redisCommandWriteNonBlock(redisContext *c, redisCallback *cb, char *str, size_t len) {
assert(!(c->flags & HIREDIS_BLOCK)); assert(!(c->flags & REDIS_BLOCK));
c->obuf = sdscatlen(c->obuf,str,len); c->obuf = sdscatlen(c->obuf,str,len);
/* Make sure there is space for the callback. */ /* Make sure there is space for the callback. */
...@@ -758,7 +758,7 @@ void *redisCommand(redisContext *c, const char *format, ...) { ...@@ -758,7 +758,7 @@ void *redisCommand(redisContext *c, const char *format, ...) {
cmd = redisFormatCommand(format,ap); cmd = redisFormatCommand(format,ap);
va_end(ap); va_end(ap);
if (c->flags & HIREDIS_BLOCK) { if (c->flags & REDIS_BLOCK) {
if (redisCommandWriteBlock(c,&reply,cmd,sdslen(cmd)) == REDIS_OK) { if (redisCommandWriteBlock(c,&reply,cmd,sdslen(cmd)) == REDIS_OK) {
return reply; return reply;
} }
...@@ -782,7 +782,7 @@ void *redisCommandWithCallback(redisContext *c, redisCallbackFn *fn, void *privd ...@@ -782,7 +782,7 @@ void *redisCommandWithCallback(redisContext *c, redisCallbackFn *fn, void *privd
redisCallback cb = { fn, privdata }; redisCallback cb = { fn, privdata };
/* This function may only be used in a non-blocking context. */ /* This function may only be used in a non-blocking context. */
if (c->flags & HIREDIS_BLOCK) return NULL; if (c->flags & REDIS_BLOCK) return NULL;
va_start(ap,format); va_start(ap,format);
cmd = redisFormatCommand(format,ap); cmd = redisFormatCommand(format,ap);
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
/* Connection type can be blocking or non-blocking and is set in the /* Connection type can be blocking or non-blocking and is set in the
* least significant bit of the flags field in redisContext. */ * least significant bit of the flags field in redisContext. */
#define HIREDIS_BLOCK 0x1 #define REDIS_BLOCK 0x1
#define REDIS_ERROR -1 #define REDIS_ERROR -1
#define REDIS_REPLY_ERROR 0 #define REDIS_REPLY_ERROR 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment