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
ef995acc
Commit
ef995acc
authored
Nov 01, 2010
by
Pieter Noordhuis
Browse files
Strip non-blocking callbacks from hiredis.c
parent
93230305
Changes
2
Show whitespace changes
Inline
Side-by-side
hiredis.c
View file @
ef995acc
...
...
@@ -643,8 +643,6 @@ static redisContext *redisContextInit() {
}
void
redisDisconnect
(
redisContext
*
c
)
{
if
(
c
->
cbDisconnect
.
fn
!=
NULL
)
c
->
cbDisconnect
.
fn
(
c
,
c
->
cbDisconnect
.
privdata
);
close
(
c
->
fd
);
c
->
flags
&=
~
REDIS_CONNECTED
;
}
...
...
@@ -653,10 +651,6 @@ void redisFree(redisContext *c) {
/* Disconnect before free'ing if not yet disconnected. */
if
(
c
->
flags
&
REDIS_CONNECTED
)
redisDisconnect
(
c
);
/* Fire free callback and clear all allocations. */
if
(
c
->
cbFree
.
fn
!=
NULL
)
c
->
cbFree
.
fn
(
c
,
c
->
cbFree
.
privdata
);
if
(
c
->
error
!=
NULL
)
sdsfree
(
c
->
error
);
if
(
c
->
obuf
!=
NULL
)
...
...
@@ -701,25 +695,6 @@ static void __redisCreateReplyReader(redisContext *c) {
c
->
reader
=
redisReplyReaderCreate
(
c
->
fn
);
}
/* Register callback that is triggered when redisDisconnect is called. */
void
redisSetDisconnectCallback
(
redisContext
*
c
,
redisContextCallbackFn
*
fn
,
void
*
privdata
)
{
c
->
cbDisconnect
.
fn
=
fn
;
c
->
cbDisconnect
.
privdata
=
privdata
;
}
/* Register callback that is triggered when a command is put in the output
* buffer when the context is non-blocking. */
void
redisSetCommandCallback
(
redisContext
*
c
,
redisContextCallbackFn
*
fn
,
void
*
privdata
)
{
c
->
cbCommand
.
fn
=
fn
;
c
->
cbCommand
.
privdata
=
privdata
;
}
/* Register callback that is triggered when the context is free'd. */
void
redisSetFreeCallback
(
redisContext
*
c
,
redisContextCallbackFn
*
fn
,
void
*
privdata
)
{
c
->
cbFree
.
fn
=
fn
;
c
->
cbFree
.
privdata
=
privdata
;
}
/* Use this function to handle a read event on the descriptor. It will try
* and read some bytes from the socket and feed them to the reply parser.
*
...
...
@@ -834,10 +809,6 @@ int redisGetReply(redisContext *c, void **reply) {
*/
void
__redisAppendCommand
(
redisContext
*
c
,
char
*
cmd
,
size_t
len
)
{
c
->
obuf
=
sdscatlen
(
c
->
obuf
,
cmd
,
len
);
/* Fire write callback */
if
(
c
->
cbCommand
.
fn
!=
NULL
)
c
->
cbCommand
.
fn
(
c
,
c
->
cbCommand
.
privdata
);
}
void
redisvAppendCommand
(
redisContext
*
c
,
const
char
*
format
,
va_list
ap
)
{
...
...
hiredis.h
View file @
ef995acc
...
...
@@ -84,15 +84,6 @@ typedef struct redisReplyObjectFunctions {
struct
redisContext
;
/* need forward declaration of redisContext */
/* Callbacks triggered on non-reply events. */
typedef
void
(
redisContextCallbackFn
)(
struct
redisContext
*
,
void
*
);
/* Callback containers */
typedef
struct
redisContextCallback
{
redisContextCallbackFn
*
fn
;
void
*
privdata
;
}
redisContextCallback
;
/* Context for a connection to Redis */
typedef
struct
redisContext
{
int
fd
;
...
...
@@ -103,11 +94,6 @@ typedef struct redisContext {
/* Function set for reply buildup and reply reader */
redisReplyObjectFunctions
*
fn
;
void
*
reader
;
/* Non-reply callbacks */
redisContextCallback
cbDisconnect
;
redisContextCallback
cbCommand
;
redisContextCallback
cbFree
;
}
redisContext
;
void
freeReplyObject
(
void
*
reply
);
...
...
@@ -137,20 +123,6 @@ int redisBufferWrite(redisContext *c, int *done);
* context, it will return unconsumed replies until there are no more. */
int
redisGetReply
(
redisContext
*
c
,
void
**
reply
);
/* The disconnect callback is called *immediately* when redisDisconnect()
* is called. It is called only once for every redisContext (since hiredis
* currently does not support reconnecting an existing context). */
void
redisSetDisconnectCallback
(
redisContext
*
c
,
redisContextCallbackFn
*
fn
,
void
*
privdata
);
/* The command callback is called every time redisCommand() is called in a
* non-blocking context. It is called *after* the formatted command has been
* appended to the write buffer. */
void
redisSetCommandCallback
(
redisContext
*
c
,
redisContextCallbackFn
*
fn
,
void
*
privdata
);
/* The free callback is called *before* all allocations are free'd. Use it to
* release resources that depend/use the redisContext that is being free'd. */
void
redisSetFreeCallback
(
redisContext
*
c
,
redisContextCallbackFn
*
fn
,
void
*
privdata
);
/* Write a command to the output buffer. Use these functions in blocking mode
* to get a pipeline of commands. */
void
redisvAppendCommand
(
redisContext
*
c
,
const
char
*
format
,
va_list
ap
);
...
...
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