Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
bc3ec0f3
Commit
bc3ec0f3
authored
Sep 25, 2010
by
Pieter Noordhuis
Browse files
Rename HIREDIS_BLOCK to REDIS_BLOCK
parent
a7d76181
Changes
2
Hide whitespace changes
Inline
Side-by-side
hiredis.c
View file @
bc3ec0f3
...
@@ -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
&
HI
REDIS_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
|=
HI
REDIS_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
&=
~
HI
REDIS_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
&
HI
REDIS_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
&
HI
REDIS_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
&
HI
REDIS_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
&
HI
REDIS_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
);
...
...
hiredis.h
View file @
bc3ec0f3
...
@@ -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
HI
REDIS_BLOCK 0x1
#define REDIS_BLOCK 0x1
#define REDIS_ERROR -1
#define REDIS_ERROR -1
#define REDIS_REPLY_ERROR 0
#define REDIS_REPLY_ERROR 0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment