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

Fix filters not processing when there is no input.

Some filters (e.g. encryption and compression) produce output even if there is no input.  Since the filter group was marked as "done" initially, processing would not run when there was zero input and that resulted in zero output.

All filters start not done so start the filter group the same way.
This commit is contained in:
David Steele
2019-06-14 08:04:28 -04:00
parent 9ba95e993b
commit f05fbc54a8
2 changed files with 16 additions and 1 deletions

View File

@ -338,6 +338,21 @@ testRun(void)
TEST_RESULT_VOID(ioFilterFree(bufferFilter), " free buffer filter");
TEST_RESULT_VOID(ioFilterGroupFree(filterGroup), " free filter group object");
// Read a zero-size buffer to ensure filters are still processed even when there is no input. Some filters (e.g. encryption
// and compression) will produce output even if there is no input.
// -------------------------------------------------------------------------------------------------------------------------
ioBufferSizeSet(1024);
buffer = bufNew(1024);
bufferOriginal = bufNew(0);
TEST_ASSIGN(bufferRead, ioBufferReadNew(bufferOriginal), "create buffer read object");
TEST_RESULT_VOID(
ioReadFilterGroupSet(bufferRead, ioFilterGroupAdd(ioFilterGroupNew(), ioTestFilterMultiplyNew("double", 2, 5, 'Y'))),
" add filter that produces output with no input");
TEST_RESULT_BOOL(ioReadOpen(bufferRead), true, " open read");
TEST_RESULT_UINT(ioRead(bufferRead, buffer), 5, " read 5 chars");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "YYYYY", " check buffer");
// Mixed line and buffer read
// -------------------------------------------------------------------------------------------------------------------------
ioBufferSizeSet(5);