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

Make working with filter groups less restrictive.

Filter groups could not be manipulated once they had been assigned to an IO object.  Now they can be freely manipulated up to the time the IO object is opened.

Also, move the filter group into the IO object's context so they don't need to be tracked separately.
This commit is contained in:
David Steele
2019-06-04 12:56:04 -04:00
parent 92e04ea9f4
commit 4b91259de8
7 changed files with 28 additions and 7 deletions

View File

@ -350,6 +350,25 @@ ioFilterGroupClose(IoFilterGroup *this)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/***********************************************************************************************************************************
Move the object to a new context
***********************************************************************************************************************************/
IoFilterGroup *
ioFilterGroupMove(IoFilterGroup *this, MemContext *parentNew)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(IO_FILTER_GROUP, this);
FUNCTION_TEST_PARAM(MEM_CONTEXT, parentNew);
FUNCTION_TEST_END();
ASSERT(parentNew != NULL);
if (this != NULL)
memContextMove(this->memContext, parentNew);
FUNCTION_TEST_RETURN(this);
}
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Is the filter group done processing? Is the filter group done processing?
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -34,6 +34,8 @@ void ioFilterGroupOpen(IoFilterGroup *this);
void ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input, Buffer *output); void ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input, Buffer *output);
void ioFilterGroupClose(IoFilterGroup *this); void ioFilterGroupClose(IoFilterGroup *this);
IoFilterGroup *ioFilterGroupMove(IoFilterGroup *this, MemContext *parentNew);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Getters Getters
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -363,7 +363,7 @@ Get/set filters
Filters must be set before open and cannot be reset. Filters must be set before open and cannot be reset.
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
const IoFilterGroup * IoFilterGroup *
ioReadFilterGroup(const IoRead *this) ioReadFilterGroup(const IoRead *this)
{ {
FUNCTION_TEST_BEGIN(); FUNCTION_TEST_BEGIN();
@ -389,7 +389,7 @@ ioReadFilterGroupSet(IoRead *this, IoFilterGroup *filterGroup)
ASSERT(!this->opened && !this->closed); ASSERT(!this->opened && !this->closed);
ASSERT(!ioReadBlock(this)); ASSERT(!ioReadBlock(this));
this->filterGroup = filterGroup; this->filterGroup = ioFilterGroupMove(filterGroup, this->memContext);
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }

View File

@ -33,7 +33,7 @@ Getters/Setters
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
bool ioReadBlock(const IoRead *this); bool ioReadBlock(const IoRead *this);
bool ioReadEof(const IoRead *this); bool ioReadEof(const IoRead *this);
const IoFilterGroup *ioReadFilterGroup(const IoRead *this); IoFilterGroup *ioReadFilterGroup(const IoRead *this);
void ioReadFilterGroupSet(IoRead *this, IoFilterGroup *filterGroup); void ioReadFilterGroupSet(IoRead *this, IoFilterGroup *filterGroup);
int ioReadHandle(const IoRead *this); int ioReadHandle(const IoRead *this);

View File

@ -269,7 +269,7 @@ Get/set filters
Filters must be set before open and cannot be reset. Filters must be set before open and cannot be reset.
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
const IoFilterGroup * IoFilterGroup *
ioWriteFilterGroup(const IoWrite *this) ioWriteFilterGroup(const IoWrite *this)
{ {
FUNCTION_TEST_BEGIN(); FUNCTION_TEST_BEGIN();
@ -277,7 +277,6 @@ ioWriteFilterGroup(const IoWrite *this)
FUNCTION_TEST_END(); FUNCTION_TEST_END();
ASSERT(this != NULL); ASSERT(this != NULL);
ASSERT(this->opened && this->closed);
FUNCTION_TEST_RETURN(this->filterGroup); FUNCTION_TEST_RETURN(this->filterGroup);
} }
@ -300,7 +299,7 @@ ioWriteFilterGroupSet(IoWrite *this, IoFilterGroup *filterGroup)
this->filterGroupSet = true; this->filterGroupSet = true;
#endif #endif
this->filterGroup = filterGroup; this->filterGroup = ioFilterGroupMove(filterGroup, this->memContext);
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }

View File

@ -33,7 +33,7 @@ void ioWriteClose(IoWrite *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Getters/Setters Getters/Setters
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
const IoFilterGroup *ioWriteFilterGroup(const IoWrite *this); IoFilterGroup *ioWriteFilterGroup(const IoWrite *this);
void ioWriteFilterGroupSet(IoWrite *this, IoFilterGroup *filterGroup); void ioWriteFilterGroupSet(IoWrite *this, IoFilterGroup *filterGroup);
int ioWriteHandle(const IoWrite *this); int ioWriteHandle(const IoWrite *this);

View File

@ -286,6 +286,7 @@ testRun(void)
TEST_ASSIGN(bufferRead, ioBufferReadNew(bufferOriginal), "create buffer read object"); TEST_ASSIGN(bufferRead, ioBufferReadNew(bufferOriginal), "create buffer read object");
IoFilterGroup *filterGroup = NULL; IoFilterGroup *filterGroup = NULL;
TEST_RESULT_VOID(ioFilterGroupMove(filterGroup, memContextTop()), "move null filter group is a noop");
TEST_ASSIGN(filterGroup, ioFilterGroupNew(), " create new filter group"); TEST_ASSIGN(filterGroup, ioFilterGroupNew(), " create new filter group");
IoFilter *sizeFilter = ioSizeNew(); IoFilter *sizeFilter = ioSizeNew();
TEST_RESULT_PTR(ioFilterGroupAdd(filterGroup, sizeFilter), filterGroup, " add filter to filter group"); TEST_RESULT_PTR(ioFilterGroupAdd(filterGroup, sizeFilter), filterGroup, " add filter to filter group");