You've already forked pgbackrest
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:
@ -350,6 +350,25 @@ ioFilterGroupClose(IoFilterGroup *this)
|
||||
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?
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -34,6 +34,8 @@ void ioFilterGroupOpen(IoFilterGroup *this);
|
||||
void ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input, Buffer *output);
|
||||
void ioFilterGroupClose(IoFilterGroup *this);
|
||||
|
||||
IoFilterGroup *ioFilterGroupMove(IoFilterGroup *this, MemContext *parentNew);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -363,7 +363,7 @@ Get/set filters
|
||||
|
||||
Filters must be set before open and cannot be reset.
|
||||
***********************************************************************************************************************************/
|
||||
const IoFilterGroup *
|
||||
IoFilterGroup *
|
||||
ioReadFilterGroup(const IoRead *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
@ -389,7 +389,7 @@ ioReadFilterGroupSet(IoRead *this, IoFilterGroup *filterGroup)
|
||||
ASSERT(!this->opened && !this->closed);
|
||||
ASSERT(!ioReadBlock(this));
|
||||
|
||||
this->filterGroup = filterGroup;
|
||||
this->filterGroup = ioFilterGroupMove(filterGroup, this->memContext);
|
||||
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ Getters/Setters
|
||||
***********************************************************************************************************************************/
|
||||
bool ioReadBlock(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);
|
||||
int ioReadHandle(const IoRead *this);
|
||||
|
||||
|
@ -269,7 +269,7 @@ Get/set filters
|
||||
|
||||
Filters must be set before open and cannot be reset.
|
||||
***********************************************************************************************************************************/
|
||||
const IoFilterGroup *
|
||||
IoFilterGroup *
|
||||
ioWriteFilterGroup(const IoWrite *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
@ -277,7 +277,6 @@ ioWriteFilterGroup(const IoWrite *this)
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(this != NULL);
|
||||
ASSERT(this->opened && this->closed);
|
||||
|
||||
FUNCTION_TEST_RETURN(this->filterGroup);
|
||||
}
|
||||
@ -300,7 +299,7 @@ ioWriteFilterGroupSet(IoWrite *this, IoFilterGroup *filterGroup)
|
||||
this->filterGroupSet = true;
|
||||
#endif
|
||||
|
||||
this->filterGroup = filterGroup;
|
||||
this->filterGroup = ioFilterGroupMove(filterGroup, this->memContext);
|
||||
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ void ioWriteClose(IoWrite *this);
|
||||
/***********************************************************************************************************************************
|
||||
Getters/Setters
|
||||
***********************************************************************************************************************************/
|
||||
const IoFilterGroup *ioWriteFilterGroup(const IoWrite *this);
|
||||
IoFilterGroup *ioWriteFilterGroup(const IoWrite *this);
|
||||
void ioWriteFilterGroupSet(IoWrite *this, IoFilterGroup *filterGroup);
|
||||
int ioWriteHandle(const IoWrite *this);
|
||||
|
||||
|
@ -286,6 +286,7 @@ testRun(void)
|
||||
|
||||
TEST_ASSIGN(bufferRead, ioBufferReadNew(bufferOriginal), "create buffer read object");
|
||||
IoFilterGroup *filterGroup = NULL;
|
||||
TEST_RESULT_VOID(ioFilterGroupMove(filterGroup, memContextTop()), "move null filter group is a noop");
|
||||
TEST_ASSIGN(filterGroup, ioFilterGroupNew(), " create new filter group");
|
||||
IoFilter *sizeFilter = ioSizeNew();
|
||||
TEST_RESULT_PTR(ioFilterGroupAdd(filterGroup, sizeFilter), filterGroup, " add filter to filter group");
|
||||
|
Reference in New Issue
Block a user