You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-11 00:50:20 +02:00
Automatically create IoRead/IoWrite interfaces in HRN_FORK*() macros.
This removes a lot of boiler plate where every instance needs to create these interfaces. Also add HRN_FORK_*_NOTIFY*() macros to standardize synchronizing between the parent and child processes. In both cases update the tests with the new macros.
This commit is contained in:
@ -735,19 +735,17 @@ testRun(void)
|
||||
{
|
||||
HRN_FORK_CHILD_BEGIN()
|
||||
{
|
||||
IoRead *read = ioFdReadNewOpen(STRDEF("child read"), HRN_FORK_CHILD_READ_FD(), 2000);
|
||||
IoWrite *write = ioFdWriteNewOpen(STRDEF("child write"), HRN_FORK_CHILD_WRITE_FD(), 2000);
|
||||
|
||||
TEST_RESULT_VOID(
|
||||
lockAcquire(
|
||||
cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), STRDEF("999-dededede"), cfgLockType(), 30000,
|
||||
true),
|
||||
"acquire lock");
|
||||
|
||||
// Let the parent know the lock has been acquired and wait for the parent to allow lock release
|
||||
ioWriteStrLine(write, strNew());
|
||||
ioWriteFlush(write);
|
||||
ioReadLine(read);
|
||||
// Notify parent that lock has been acquired
|
||||
HRN_FORK_CHILD_NOTIFY_PUT();
|
||||
|
||||
// Wait for parent to allow release lock
|
||||
HRN_FORK_CHILD_NOTIFY_GET();
|
||||
|
||||
lockRelease(true);
|
||||
}
|
||||
@ -755,19 +753,15 @@ testRun(void)
|
||||
|
||||
HRN_FORK_PARENT_BEGIN()
|
||||
{
|
||||
IoRead *read = ioFdReadNewOpen(STRDEF("parent read"), HRN_FORK_PARENT_READ_FD(0), 2000);
|
||||
IoWrite *write = ioFdWriteNewOpen(STRDEF("parent write"), HRN_FORK_PARENT_WRITE_FD(0), 2000);
|
||||
|
||||
// Wait for the child to acquire the lock
|
||||
ioReadLine(read);
|
||||
// Wait for child to acquire lock
|
||||
HRN_FORK_PARENT_NOTIFY_GET(0);
|
||||
|
||||
TEST_ERROR(
|
||||
cmdArchiveGet(), ArchiveTimeoutError,
|
||||
"unable to get WAL file '000000010000000100000001' from the archive asynchronously after 1 second(s)");
|
||||
|
||||
// Notify the child to release the lock
|
||||
ioWriteLine(write, bufNew(0));
|
||||
ioWriteFlush(write);
|
||||
// Notify child to release lock
|
||||
HRN_FORK_PARENT_NOTIFY_PUT(0);
|
||||
}
|
||||
HRN_FORK_PARENT_END();
|
||||
}
|
||||
|
Reference in New Issue
Block a user