mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
CLIENT UNBLOCK: support unblocking by error.
This commit is contained in:
parent
71295ee305
commit
2214043b5c
@ -1688,13 +1688,32 @@ NULL
|
|||||||
/* If this client has to be closed, flag it as CLOSE_AFTER_REPLY
|
/* If this client has to be closed, flag it as CLOSE_AFTER_REPLY
|
||||||
* only after we queued the reply to its output buffers. */
|
* only after we queued the reply to its output buffers. */
|
||||||
if (close_this_client) c->flags |= CLIENT_CLOSE_AFTER_REPLY;
|
if (close_this_client) c->flags |= CLIENT_CLOSE_AFTER_REPLY;
|
||||||
} else if (!strcasecmp(c->argv[1]->ptr,"unblock") && c->argc == 3) {
|
} else if (!strcasecmp(c->argv[1]->ptr,"unblock") && (c->argc == 3 ||
|
||||||
/* CLIENT UNBLOCK <id> */
|
c->argc == 4))
|
||||||
|
{
|
||||||
|
/* CLIENT UNBLOCK <id> [timeout|error] */
|
||||||
long long id;
|
long long id;
|
||||||
|
int unblock_error = 0;
|
||||||
|
|
||||||
|
if (c->argc == 4) {
|
||||||
|
if (!strcasecmp(c->argv[3]->ptr,"timeout")) {
|
||||||
|
unblock_error = 0;
|
||||||
|
} else if (!strcasecmp(c->argv[3]->ptr,"error")) {
|
||||||
|
unblock_error = 1;
|
||||||
|
} else {
|
||||||
|
addReplyError(c,
|
||||||
|
"CLIENT UNBLOCK reason should be TIMEOUT or ERROR");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (getLongLongFromObjectOrReply(c,c->argv[2],&id,NULL)
|
if (getLongLongFromObjectOrReply(c,c->argv[2],&id,NULL)
|
||||||
!= C_OK) return;
|
!= C_OK) return;
|
||||||
struct client *target = lookupClientByID(id);
|
struct client *target = lookupClientByID(id);
|
||||||
if (target && target->flags & CLIENT_BLOCKED) {
|
if (target && target->flags & CLIENT_BLOCKED) {
|
||||||
|
if (unblock_error)
|
||||||
|
addReplyError(target,
|
||||||
|
"-UNBLOCKED client unblocked via CLIENT UNBLOCK");
|
||||||
|
else
|
||||||
replyToBlockedClientTimedOut(target);
|
replyToBlockedClientTimedOut(target);
|
||||||
unblockClient(target);
|
unblockClient(target);
|
||||||
addReply(c,shared.cone);
|
addReply(c,shared.cone);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user