You've already forked pgbackrest
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:
@ -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
|
||||
{
|
||||
|
Reference in New Issue
Block a user