diff options
author | hwware <wen.hui.ware@gmail.com> | 2020-03-29 23:20:54 -0400 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2020-04-07 16:52:04 +0200 |
commit | b35407fa7c5e43ce184c89abb50134e816292907 (patch) | |
tree | 47ff25d3dad2487e3a094b21094fb4dec2983a2e | |
parent | 4395889c9e13b0f0909372780fd1d6ecad7fb61a (diff) | |
download | redis-b35407fa7c5e43ce184c89abb50134e816292907.tar.gz |
add check for not switching between optin optout mode directly
-rw-r--r-- | src/networking.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c index f8808f08f..85c640e34 100644 --- a/src/networking.c +++ b/src/networking.c @@ -2326,7 +2326,7 @@ NULL return; } - if ((options & CLIENT_TRACKING_OPTIN) && (options & CLIENT_TRACKING_OPTOUT)) + if (options & CLIENT_TRACKING_OPTIN && options & CLIENT_TRACKING_OPTOUT) { addReplyError(c, "You can't specify both OPTIN mode and OPTOUT mode"); @@ -2334,6 +2334,17 @@ NULL return; } + if ((options & CLIENT_TRACKING_OPTIN && c->flags & CLIENT_TRACKING_OPTOUT) || + (options & CLIENT_TRACKING_OPTOUT && c->flags & CLIENT_TRACKING_OPTIN)) + { + addReplyError(c, + "You can't switch OPTIN/OPTOUT mode before disabling " + "tracking for this client, and then re-enabling it with " + "a different mode."); + zfree(prefix); + return; + } + enableTracking(c,redir,options,prefix,numprefix); } else if (!strcasecmp(c->argv[2]->ptr,"off")) { disableTracking(c); |