Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
3ce8d5b0
Commit
3ce8d5b0
authored
Dec 31, 2010
by
Pieter Noordhuis
Browse files
Change reply processing code to prepare for pub/sub
parent
2d53a6a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
async.c
View file @
3ce8d5b0
...
@@ -247,12 +247,20 @@ void redisProcessCallbacks(redisAsyncContext *ac) {
...
@@ -247,12 +247,20 @@ void redisProcessCallbacks(redisAsyncContext *ac) {
break
;
break
;
}
}
/* Shift callback and execute it */
/* Even if the context is subscribed, pending regular callbacks will
assert
(
__redisShiftCallback
(
&
ac
->
replies
,
&
cb
)
==
REDIS_OK
);
* get a reply before pub/sub messages arrive. */
if
(
__redisShiftCallback
(
&
ac
->
replies
,
&
cb
)
!=
REDIS_OK
)
{
/* No more regular callbacks, the context *must* be subscribed. */
assert
(
c
->
flags
&
REDIS_SUBSCRIBED
);
/* TODO: find the right callback for pub/sub message. */
}
if
(
cb
.
fn
!=
NULL
)
{
if
(
cb
.
fn
!=
NULL
)
{
c
->
flags
|=
REDIS_IN_CALLBACK
;
c
->
flags
|=
REDIS_IN_CALLBACK
;
cb
.
fn
(
ac
,
reply
,
cb
.
privdata
);
cb
.
fn
(
ac
,
reply
,
cb
.
privdata
);
c
->
flags
&=
~
REDIS_IN_CALLBACK
;
c
->
flags
&=
~
REDIS_IN_CALLBACK
;
c
->
fn
->
freeObject
(
reply
);
/* Proceed with free'ing when redisAsyncFree() was called. */
/* Proceed with free'ing when redisAsyncFree() was called. */
if
(
c
->
flags
&
REDIS_FREEING
)
{
if
(
c
->
flags
&
REDIS_FREEING
)
{
...
@@ -260,6 +268,10 @@ void redisProcessCallbacks(redisAsyncContext *ac) {
...
@@ -260,6 +268,10 @@ void redisProcessCallbacks(redisAsyncContext *ac) {
return
;
return
;
}
}
}
else
{
}
else
{
/* No callback for this reply. This can either be a NULL callback,
* or there were no callbacks to begin with. Either way, don't
* abort with an error, but simply ignore it because the client
* doesn't know what the server will spit out over the wire. */
c
->
fn
->
freeObject
(
reply
);
c
->
fn
->
freeObject
(
reply
);
}
}
}
}
...
...
hiredis.h
View file @
3ce8d5b0
...
@@ -71,6 +71,9 @@
...
@@ -71,6 +71,9 @@
/* Flag that is set when an async callback is executed. */
/* Flag that is set when an async callback is executed. */
#define REDIS_IN_CALLBACK 0x10
#define REDIS_IN_CALLBACK 0x10
/* Flag that is set when the async context has one or more subscriptions. */
#define REDIS_SUBSCRIBED 0x20
#define REDIS_REPLY_STRING 1
#define REDIS_REPLY_STRING 1
#define REDIS_REPLY_ARRAY 2
#define REDIS_REPLY_ARRAY 2
#define REDIS_REPLY_INTEGER 3
#define REDIS_REPLY_INTEGER 3
...
...
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