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
b6fb548f
Commit
b6fb548f
authored
Feb 02, 2022
by
Björn Svensson
Browse files
Ignore pubsub replies without a channel/pattern
parent
f8de9a4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
async.c
View file @
b6fb548f
...
@@ -431,8 +431,10 @@ static int __redisGetSubscribeCallback(redisAsyncContext *ac, redisReply *reply,
...
@@ -431,8 +431,10 @@ static int __redisGetSubscribeCallback(redisAsyncContext *ac, redisReply *reply,
else
else
callbacks
=
ac
->
sub
.
channels
;
callbacks
=
ac
->
sub
.
channels
;
/* Ignore replies without a channel/pattern string */
if
(
reply
->
element
[
1
]
->
type
!=
REDIS_REPLY_STRING
)
return
REDIS_OK
;
/* Locate the right callback */
/* Locate the right callback */
assert
(
reply
->
element
[
1
]
->
type
==
REDIS_REPLY_STRING
);
sname
=
sdsnewlen
(
reply
->
element
[
1
]
->
str
,
reply
->
element
[
1
]
->
len
);
sname
=
sdsnewlen
(
reply
->
element
[
1
]
->
str
,
reply
->
element
[
1
]
->
len
);
if
(
sname
==
NULL
)
if
(
sname
==
NULL
)
goto
oom
;
goto
oom
;
...
...
test.c
View file @
b6fb548f
...
@@ -1733,6 +1733,10 @@ void subscribe_channel_a_cb(redisAsyncContext *ac, void *r, void *privdata) {
...
@@ -1733,6 +1733,10 @@ void subscribe_channel_a_cb(redisAsyncContext *ac, void *r, void *privdata) {
redisAsyncCommand
(
ac
,
unexpected_cb
,
redisAsyncCommand
(
ac
,
unexpected_cb
,
(
void
*
)
"unsubscribe should not call unexpected_cb()"
,
(
void
*
)
"unsubscribe should not call unexpected_cb()"
,
"unsubscribe B X A"
);
"unsubscribe B X A"
);
/* Unsubscribe to patterns, none which we subscribe to */
redisAsyncCommand
(
ac
,
unexpected_cb
,
(
void
*
)
"punsubscribe should not call unexpected_cb()"
,
"punsubscribe"
);
/* Send a regular command after unsubscribing, then disconnect */
/* Send a regular command after unsubscribing, then disconnect */
state
->
disconnect
=
1
;
state
->
disconnect
=
1
;
redisAsyncCommand
(
ac
,
integer_cb
,
state
,
"LPUSH mylist foo"
);
redisAsyncCommand
(
ac
,
integer_cb
,
state
,
"LPUSH mylist foo"
);
...
@@ -1769,6 +1773,8 @@ void subscribe_channel_b_cb(redisAsyncContext *ac, void *r, void *privdata) {
...
@@ -1769,6 +1773,8 @@ void subscribe_channel_b_cb(redisAsyncContext *ac, void *r, void *privdata) {
* - subscribe to channel A and B
* - subscribe to channel A and B
* - a published message on A triggers an unsubscribe of channel B, X and A
* - a published message on A triggers an unsubscribe of channel B, X and A
* where channel X is not subscribed to.
* where channel X is not subscribed to.
* - the published message also triggers an unsubscribe to patterns. Since no
* pattern is subscribed to the responded pattern element type is NIL.
* - a command sent after unsubscribe triggers a disconnect */
* - a command sent after unsubscribe triggers a disconnect */
static
void
test_pubsub_multiple_channels
(
struct
config
config
)
{
static
void
test_pubsub_multiple_channels
(
struct
config
config
)
{
test
(
"Subscribe to multiple channels: "
);
test
(
"Subscribe to multiple channels: "
);
...
...
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