diff options
author | Yossi Gottlieb <yossigo@gmail.com> | 2020-10-05 17:03:17 +0300 |
---|---|---|
committer | Yossi Gottlieb <yossigo@gmail.com> | 2020-10-11 16:04:14 +0300 |
commit | 9b7f8ba84b9de1ec846badd45e4004e3cd23f178 (patch) | |
tree | f83d80d28ce292b2f6914e117d195705cb141208 /src/tracking.c | |
parent | dab5ec9b8d5c6f7a99a557d65cc95816b981835b (diff) | |
download | redis-9b7f8ba84b9de1ec846badd45e4004e3cd23f178.tar.gz |
Introduce getKeysResult for getKeysFromCommand.
Avoid using a static buffer for short key index responses, and make it
caller's responsibility to stack-allocate a result type. Responses that
don't fit are still allocated on the heap.
Diffstat (limited to 'src/tracking.c')
-rw-r--r-- | src/tracking.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/tracking.c b/src/tracking.c index 3737f6859..913577eab 100644 --- a/src/tracking.c +++ b/src/tracking.c @@ -171,9 +171,14 @@ void trackingRememberKeys(client *c) { uint64_t caching_given = c->flags & CLIENT_TRACKING_CACHING; if ((optin && !caching_given) || (optout && caching_given)) return; - int numkeys; - int *keys = getKeysFromCommand(c->cmd,c->argv,c->argc,&numkeys); - if (keys == NULL) return; + getKeysResult result = GETKEYS_RESULT_INIT; + int numkeys = getKeysFromCommand(c->cmd,c->argv,c->argc,&result); + if (!numkeys) { + getKeysFreeResult(&result); + return; + } + + int *keys = result.keys; for(int j = 0; j < numkeys; j++) { int idx = keys[j]; @@ -188,7 +193,7 @@ void trackingRememberKeys(client *c) { if (raxTryInsert(ids,(unsigned char*)&c->id,sizeof(c->id),NULL,NULL)) TrackingTableTotalItems++; } - getKeysFreeResult(keys); + getKeysFreeResult(&result); } /* Given a key name, this function sends an invalidation message in the |