Rename HIREDIS_BLOCK to REDIS_BLOCK

This commit is contained in:
Pieter Noordhuis 2010-09-25 15:11:59 +02:00
parent a7d7618141
commit bc3ec0f35a
2 changed files with 8 additions and 8 deletions

View File

@ -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) {
* 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) {
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
} }
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, ...) {
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
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);

View File

@ -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