1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-13 01:00:23 +02:00

Harden IO filters against zero input and optimize zero output case.

Add production checks to ensure no filter gets a zero-size input buffer.

Also, optimize the case where a filter returns no output.  There's no sense in running downstream filters if they have no new input.
This commit is contained in:
David Steele
2019-04-18 21:24:10 -04:00
parent 2d73de1d36
commit 7390952d8e
5 changed files with 31 additions and 10 deletions

View File

@ -122,6 +122,7 @@ typedef struct IoTestFilterMultiply
{
MemContext *memContext;
unsigned int flushTotal;
bool writeZero;
char flushChar;
Buffer *multiplyBuffer;
unsigned int multiplier;
@ -143,9 +144,17 @@ ioTestFilterMultiplyProcess(IoTestFilterMultiply *this, const Buffer *input, Buf
if (input == NULL)
{
char flushZ[] = {this->flushChar, 0};
bufCat(output, bufNewC(1, flushZ));
this->flushTotal--;
// Write nothing into the output buffer to make sure the filter processing will skip the remaining filters
if (!this->writeZero)
{
this->writeZero = true;
}
else
{
char flushZ[] = {this->flushChar, 0};
bufCat(output, bufNewC(1, flushZ));
this->flushTotal--;
}
}
else
{