Fix failure to trim querybuf (and memory tests that fail because of it)

This commit is contained in:
John Sully 2019-02-22 22:09:25 -05:00
parent 906308d728
commit cfabd4f666

View File

@ -1926,6 +1926,7 @@ int processMultibulkBuffer(client *c) {
* pending query buffer, already representing a full command, to process. */
void processInputBuffer(client *c) {
AssertCorrectThread(c);
bool fFreed = false;
/* Keep processing while there is something in the input buffer */
while(c->qb_pos < sdslen(c->querybuf)) {
@ -1990,13 +1991,16 @@ void processInputBuffer(client *c) {
/* freeMemoryIfNeeded may flush slave output buffers. This may
* result into a slave, that may be the active client, to be
* freed. */
if (server.current_client == NULL) break;
if (server.current_client == NULL) {
fFreed = true;
break;
}
server.current_client = NULL;
}
}
/* Trim to pos */
if (server.current_client != NULL && c->qb_pos) {
if (!fFreed && c->qb_pos) {
sdsrange(c->querybuf,c->qb_pos,-1);
c->qb_pos = 0;
}