pgbackrest.git / summary / log / commit / refs

commit    f05fbc54a8f00a56937439fb88eafe8e239781e8
Author:   David Steele <david@pgmasters.net>
Date:     Fri Jun 14 12:04:28 2019 +0000

    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.


src/common/io/filter/group.c | 2 +- test/src/module/common/ioTest.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/common/io/filter/group.c b/src/common/io/filter/group.c index aaadaf112..36f48db82 100644 --- a/src/common/io/filter/group.c +++ b/src/common/io/filter/group.c @@ -69,7 +69,7 @@ ioFilterGroupNew(void) { this = memNew(sizeof(IoFilterGroup)); this->memContext = memContextCurrent(); - this->done = true; + this->done = false; this->filterList = lstNew(sizeof(IoFilterData)); } MEM_CONTEXT_NEW_END(); diff --git a/test/src/module/common/ioTest.c b/test/src/module/common/ioTest.c index 58b7c6cdb..bba1d0595 100644 --- a/test/src/module/common/ioTest.c +++ b/test/src/module/common/ioTest.c @@ -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); [parent: 9ba95e993ba3]