diff options
author | Oran Agra <oran@redislabs.com> | 2023-05-15 13:08:15 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-15 13:08:15 +0300 |
commit | a51eb05b1895babb17c37c36b963e2bcbd5496d5 (patch) | |
tree | 7be24b09e0a5621a03e9f9ffe9ef27fcb44d8345 /src/slowlog.c | |
parent | e26a769d9627ebecb8607375580970a740348956 (diff) | |
parent | 986dbf716e0cb904c80bb444635cea3242859cc1 (diff) | |
download | redis-7.2.tar.gz |
Diffstat (limited to 'src/slowlog.c')
-rw-r--r-- | src/slowlog.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/slowlog.c b/src/slowlog.c index 320f334a8..4c31917bb 100644 --- a/src/slowlog.c +++ b/src/slowlog.c @@ -162,9 +162,8 @@ NULL } else if ((c->argc == 2 || c->argc == 3) && !strcasecmp(c->argv[1]->ptr,"get")) { - long count = 10, sent = 0; + long count = 10; listIter li; - void *totentries; listNode *ln; slowlogEntry *se; @@ -181,11 +180,15 @@ NULL } } - listRewind(server.slowlog,&li); - totentries = addReplyDeferredLen(c); - while(count-- && (ln = listNext(&li))) { + if (count > (long)listLength(server.slowlog)) { + count = listLength(server.slowlog); + } + addReplyArrayLen(c, count); + listRewind(server.slowlog, &li); + while (count--) { int j; + ln = listNext(&li); se = ln->value; addReplyArrayLen(c,6); addReplyLongLong(c,se->id); @@ -196,9 +199,7 @@ NULL addReplyBulk(c,se->argv[j]); addReplyBulkCBuffer(c,se->peerid,sdslen(se->peerid)); addReplyBulkCBuffer(c,se->cname,sdslen(se->cname)); - sent++; } - setDeferredArrayLen(c,totentries,sent); } else { addReplySubcommandSyntaxError(c); } |