summaryrefslogtreecommitdiff
path: root/src/networking.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-06-27 18:51:06 +0200
committerantirez <antirez@gmail.com>2018-06-27 18:51:06 +0200
commit2214043b5c84c69279077343846657c17c0214ac (patch)
tree2371a7f6c0beef9e4d824ef21271a7278dea2721 /src/networking.c
parent71295ee305345fba9a73766b6fc084b2c15bc303 (diff)
downloadredis-2214043b5c84c69279077343846657c17c0214ac.tar.gz
CLIENT UNBLOCK: support unblocking by error.
Diffstat (limited to 'src/networking.c')
-rw-r--r--src/networking.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/networking.c b/src/networking.c
index fe8a78ec5..cacb214f1 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -1688,14 +1688,33 @@ NULL
/* If this client has to be closed, flag it as CLOSE_AFTER_REPLY
* only after we queued the reply to its output buffers. */
if (close_this_client) c->flags |= CLIENT_CLOSE_AFTER_REPLY;
- } else if (!strcasecmp(c->argv[1]->ptr,"unblock") && c->argc == 3) {
- /* CLIENT UNBLOCK <id> */
+ } else if (!strcasecmp(c->argv[1]->ptr,"unblock") && (c->argc == 3 ||
+ c->argc == 4))
+ {
+ /* CLIENT UNBLOCK <id> [timeout|error] */
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)
!= C_OK) return;
struct client *target = lookupClientByID(id);
if (target && target->flags & CLIENT_BLOCKED) {
- replyToBlockedClientTimedOut(target);
+ if (unblock_error)
+ addReplyError(target,
+ "-UNBLOCKED client unblocked via CLIENT UNBLOCK");
+ else
+ replyToBlockedClientTimedOut(target);
unblockClient(target);
addReply(c,shared.cone);
} else {