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
redis
Commits
34599691
Commit
34599691
authored
Oct 07, 2016
by
antirez
Browse files
Modules: fixes to the blocking commands API: examples now works.
parent
f156038d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
34599691
...
@@ -3115,7 +3115,7 @@ RedisModuleBlockedClient *RM_BlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc
...
@@ -3115,7 +3115,7 @@ RedisModuleBlockedClient *RM_BlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc
bc
->
timeout_callback
=
timeout_callback
;
bc
->
timeout_callback
=
timeout_callback
;
bc
->
free_privdata
=
free_privdata
;
bc
->
free_privdata
=
free_privdata
;
bc
->
privdata
=
NULL
;
bc
->
privdata
=
NULL
;
c
->
bpop
.
timeout
=
timeout_ms
;
c
->
bpop
.
timeout
=
timeout_ms
?
(
mstime
()
+
timeout_ms
)
:
0
;
blockClient
(
c
,
BLOCKED_MODULE
);
blockClient
(
c
,
BLOCKED_MODULE
);
return
bc
;
return
bc
;
...
@@ -3157,7 +3157,11 @@ void moduleHandleBlockedClients(void) {
...
@@ -3157,7 +3157,11 @@ void moduleHandleBlockedClients(void) {
ln
=
listFirst
(
moduleUnblockedClients
);
ln
=
listFirst
(
moduleUnblockedClients
);
bc
=
ln
->
value
;
bc
=
ln
->
value
;
client
*
c
=
bc
->
client
;
client
*
c
=
bc
->
client
;
listDelNode
(
server
.
unblocked_clients
,
ln
);
listDelNode
(
moduleUnblockedClients
,
ln
);
pthread_mutex_unlock
(
&
moduleUnblockedClientsMutex
);
/* Release the lock during the loop, as long as we don't
* touch the shared list. */
if
(
c
!=
NULL
)
{
if
(
c
!=
NULL
)
{
RedisModuleCtx
ctx
=
REDISMODULE_CTX_INIT
;
RedisModuleCtx
ctx
=
REDISMODULE_CTX_INIT
;
...
@@ -3172,6 +3176,10 @@ void moduleHandleBlockedClients(void) {
...
@@ -3172,6 +3176,10 @@ void moduleHandleBlockedClients(void) {
if
(
bc
->
privdata
&&
bc
->
free_privdata
)
if
(
bc
->
privdata
&&
bc
->
free_privdata
)
bc
->
free_privdata
(
bc
->
privdata
);
bc
->
free_privdata
(
bc
->
privdata
);
zfree
(
bc
);
zfree
(
bc
);
if
(
c
!=
NULL
)
unblockClient
(
bc
->
client
);
/* Lock again before to iterate the loop. */
pthread_mutex_lock
(
&
moduleUnblockedClientsMutex
);
}
}
pthread_mutex_unlock
(
&
moduleUnblockedClientsMutex
);
pthread_mutex_unlock
(
&
moduleUnblockedClientsMutex
);
}
}
...
...
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