summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-02-10 13:42:18 +0100
committerantirez <antirez@gmail.com>2020-02-10 13:42:18 +0100
commitf53cc00c09a4e7c612b3781021246cbbeb533d7b (patch)
tree8f9b8f2f1d62fc32a7893150c0d445ba56b344bf
parent85e4777d5c4411b499a845565729910bb09d64ac (diff)
downloadredis-f53cc00c09a4e7c612b3781021246cbbeb533d7b.tar.gz
Tracking: always reply with an array of keys.
-rw-r--r--src/pubsub.c8
-rw-r--r--src/tracking.c5
2 files changed, 10 insertions, 3 deletions
diff --git a/src/pubsub.c b/src/pubsub.c
index 994dd9734..5cb4298e0 100644
--- a/src/pubsub.c
+++ b/src/pubsub.c
@@ -35,7 +35,11 @@ int clientSubscriptionsCount(client *c);
* Pubsub client replies API
*----------------------------------------------------------------------------*/
-/* Send a pubsub message of type "message" to the client. */
+/* Send a pubsub message of type "message" to the client.
+ * Normally 'msg' is a Redis object containing the string to send as
+ * message. However if the caller sets 'msg' as NULL, it will be able
+ * to send a special message (for instance an Array type) by using the
+ * addReply*() API family. */
void addReplyPubsubMessage(client *c, robj *channel, robj *msg) {
if (c->resp == 2)
addReply(c,shared.mbulkhdr[3]);
@@ -43,7 +47,7 @@ void addReplyPubsubMessage(client *c, robj *channel, robj *msg) {
addReplyPushLen(c,3);
addReply(c,shared.messagebulk);
addReplyBulk(c,channel);
- addReplyBulk(c,msg);
+ if (msg) addReplyBulk(c,msg);
}
/* Send a pubsub message of type "pmessage" to the client. The difference
diff --git a/src/tracking.c b/src/tracking.c
index 9c1c9620c..3122563ac 100644
--- a/src/tracking.c
+++ b/src/tracking.c
@@ -132,13 +132,16 @@ void sendTrackingMessage(client *c, char *keyname, size_t keylen) {
if (c->resp > 2) {
addReplyPushLen(c,2);
addReplyBulkCBuffer(c,"invalidate",10);
+ addReplyArrayLen(c,1);
addReplyBulkCBuffer(c,keyname,keylen);
} else if (using_redirection && c->flags & CLIENT_PUBSUB) {
/* We use a static object to speedup things, however we assume
* that addReplyPubsubMessage() will not take a reference. */
robj keyobj;
initStaticStringObject(keyobj,keyname);
- addReplyPubsubMessage(c,TrackingChannelName,&keyobj);
+ addReplyPubsubMessage(c,TrackingChannelName,NULL);
+ addReplyArrayLen(c,1);
+ addReplyBulk(c,&keyobj);
serverAssert(keyobj.refcount == 1);
}
}