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
438ffcae
Commit
438ffcae
authored
Jun 03, 2020
by
antirez
Browse files
Threaded core commands: key unlocking WIP 2.
parent
f302c75f
Changes
2
Show whitespace changes
Inline
Side-by-side
src/blocked.c
View file @
438ffcae
...
@@ -171,7 +171,7 @@ void unblockClient(client *c) {
...
@@ -171,7 +171,7 @@ void unblockClient(client *c) {
/* Re-execute the command if it was not executed at all since the
/* Re-execute the command if it was not executed at all since the
* client was blocked because of key locks. */
* client was blocked because of key locks. */
if
(
btype
==
BLOCKED_LOCK
)
processCommand
(
c
);
if
(
btype
==
BLOCKED_LOCK
)
processCommand
AndResetClient
(
c
);
}
}
/* This function gets called when a blocked client timed out in order to
/* This function gets called when a blocked client timed out in order to
...
...
src/db.c
View file @
438ffcae
...
@@ -1858,11 +1858,15 @@ void unlockKey(client *c, robj *key, uint64_t owner_id) {
...
@@ -1858,11 +1858,15 @@ void unlockKey(client *c, robj *key, uint64_t owner_id) {
listNode
*
ln
=
listSearchKey
(
lk
->
owners
,
&
lkc
);
listNode
*
ln
=
listSearchKey
(
lk
->
owners
,
&
lkc
);
if
(
ln
==
NULL
)
return
;
if
(
ln
==
NULL
)
return
;
/*
Unlock the key
, and if this key dropped to a locked
count of
/*
Remove the lock for thsi owner
, and if this key dropped to a locked
* zero, we need to resume the clients in the waiting list. */
*
count of
zero, we need to resume the clients in the waiting list. */
listDelNode
(
lk
->
owners
,
ln
);
listDelNode
(
lk
->
owners
,
ln
);
if
(
listLength
(
lk
->
owners
)
!=
0
)
return
;
if
(
listLength
(
lk
->
owners
)
!=
0
)
return
;
/* There are no longer owners for this lock: unlock the key
* before resuming the clients. */
dictDelete
(
c
->
db
->
locked_keys
,
key
);
listIter
li
;
listIter
li
;
listRewind
(
lk
->
waiting
,
&
li
);
listRewind
(
lk
->
waiting
,
&
li
);
while
((
ln
=
listNext
(
&
li
)))
{
while
((
ln
=
listNext
(
&
li
)))
{
...
@@ -1872,7 +1876,6 @@ void unlockKey(client *c, robj *key, uint64_t owner_id) {
...
@@ -1872,7 +1876,6 @@ void unlockKey(client *c, robj *key, uint64_t owner_id) {
blocked
->
flags
&
CLIENT_BLOCKED
&&
blocked
->
flags
&
CLIENT_BLOCKED
&&
blocked
->
btype
==
BLOCKED_LOCK
)
blocked
->
btype
==
BLOCKED_LOCK
)
{
{
printf
(
"UNBLOCK %llu
\n
"
,
blocked
->
id
);
/* XXX: Check if the client is yet locked in some other key
/* XXX: Check if the client is yet locked in some other key
* before unblocking it? Right now we just unblock it, and
* before unblocking it? Right now we just unblock it, and
* it will get blocked again if there are yet keys that are
* it will get blocked again if there are yet keys that are
...
@@ -1882,10 +1885,7 @@ void unlockKey(client *c, robj *key, uint64_t owner_id) {
...
@@ -1882,10 +1885,7 @@ void unlockKey(client *c, robj *key, uint64_t owner_id) {
listDelNode
(
lk
->
waiting
,
ln
);
listDelNode
(
lk
->
waiting
,
ln
);
}
}
/* At this point the key is no longer locked by any owner, nor
/* Frre the lock state. */
* it has any client in the waiting list. Remove it from the
* dictionary. */
dictDelete
(
c
->
db
->
locked_keys
,
key
);
listRelease
(
lk
->
owners
);
listRelease
(
lk
->
owners
);
listRelease
(
lk
->
waiting
);
listRelease
(
lk
->
waiting
);
zfree
(
lk
);
zfree
(
lk
);
...
...
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