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
47c3ecef
Unverified
Commit
47c3ecef
authored
Apr 23, 2022
by
Michael Grunder
Committed by
GitHub
Apr 23, 2022
Browse files
Merge pull request #1062 from yossigo/fix-push-notification-order
Handle push notifications before or after reply.
parents
e23d91c9
b455b338
Changes
1
Hide whitespace changes
Inline
Side-by-side
test.c
View file @
47c3ecef
...
@@ -914,6 +914,11 @@ static void test_resp3_push_handler(redisContext *c) {
...
@@ -914,6 +914,11 @@ static void test_resp3_push_handler(redisContext *c) {
old
=
redisSetPushCallback
(
c
,
push_handler
);
old
=
redisSetPushCallback
(
c
,
push_handler
);
test
(
"We can set a custom RESP3 PUSH handler: "
);
test
(
"We can set a custom RESP3 PUSH handler: "
);
reply
=
redisCommand
(
c
,
"SET key:0 val:0"
);
reply
=
redisCommand
(
c
,
"SET key:0 val:0"
);
/* We need another command because depending on the version of Redis, the
* notification may be delivered after the command's reply. */
test_cond
(
reply
!=
NULL
);
freeReplyObject
(
reply
);
reply
=
redisCommand
(
c
,
"PING"
);
test_cond
(
reply
!=
NULL
&&
reply
->
type
==
REDIS_REPLY_STATUS
&&
pc
.
str
==
1
);
test_cond
(
reply
!=
NULL
&&
reply
->
type
==
REDIS_REPLY_STATUS
&&
pc
.
str
==
1
);
freeReplyObject
(
reply
);
freeReplyObject
(
reply
);
...
@@ -929,6 +934,12 @@ static void test_resp3_push_handler(redisContext *c) {
...
@@ -929,6 +934,12 @@ static void test_resp3_push_handler(redisContext *c) {
assert
((
reply
=
redisCommand
(
c
,
"GET key:0"
))
!=
NULL
);
assert
((
reply
=
redisCommand
(
c
,
"GET key:0"
))
!=
NULL
);
freeReplyObject
(
reply
);
freeReplyObject
(
reply
);
assert
((
reply
=
redisCommand
(
c
,
"SET key:0 invalid"
))
!=
NULL
);
assert
((
reply
=
redisCommand
(
c
,
"SET key:0 invalid"
))
!=
NULL
);
/* Depending on Redis version, we may receive either push notification or
* status reply. Both cases are valid. */
if
(
reply
->
type
==
REDIS_REPLY_STATUS
)
{
freeReplyObject
(
reply
);
reply
=
redisCommand
(
c
,
"PING"
);
}
test_cond
(
reply
->
type
==
REDIS_REPLY_PUSH
);
test_cond
(
reply
->
type
==
REDIS_REPLY_PUSH
);
freeReplyObject
(
reply
);
freeReplyObject
(
reply
);
...
...
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