You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-01 00:25:06 +02:00
Add MEM_CONTEXT_PRIOR() block and update current call sites.
This macro block encapsulates the common pattern of switching to the prior (formerly called old) mem context to return results from a function. Also rename MEM_CONTEXT_OLD() to memContextPrior(). This violates our convention of macros being in all caps but memContextPrior() will become a function very soon so this will reduce churn.
This commit is contained in:
11
libc/LibC.h
11
libc/LibC.h
@ -65,12 +65,9 @@ Error handling macros that throw a Perl error when a C error is caught
|
|||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Core context handling macros, only intended to be called from other macros
|
Core context handling macros, only intended to be called from other macros
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
#define MEM_CONTEXT_XS_OLD() \
|
|
||||||
MEM_CONTEXT_XS_memContextOld
|
|
||||||
|
|
||||||
#define MEM_CONTEXT_XS_CORE_BEGIN(memContext) \
|
#define MEM_CONTEXT_XS_CORE_BEGIN(memContext) \
|
||||||
/* Switch to the new memory context */ \
|
/* Switch to the new memory context */ \
|
||||||
MemContext *MEM_CONTEXT_XS_OLD() = memContextSwitch(memContext); \
|
MemContext *MEM_CONTEXT_memContextPrior = memContextSwitch(memContext); \
|
||||||
\
|
\
|
||||||
/* Store any errors to be croaked to Perl at the end */ \
|
/* Store any errors to be croaked to Perl at the end */ \
|
||||||
bool MEM_CONTEXT_XS_croak = false; \
|
bool MEM_CONTEXT_XS_croak = false; \
|
||||||
@ -87,7 +84,7 @@ Core context handling macros, only intended to be called from other macros
|
|||||||
/* Free the context on error */ \
|
/* Free the context on error */ \
|
||||||
FINALLY() \
|
FINALLY() \
|
||||||
{ \
|
{ \
|
||||||
memContextSwitch(MEM_CONTEXT_XS_OLD()); \
|
memContextSwitch(memContextPrior()); \
|
||||||
} \
|
} \
|
||||||
TRY_END();
|
TRY_END();
|
||||||
|
|
||||||
@ -164,8 +161,8 @@ Simplifies switching to a temp memory context in functions and includes error ha
|
|||||||
/* Free the context on error */ \
|
/* Free the context on error */ \
|
||||||
FINALLY() \
|
FINALLY() \
|
||||||
{ \
|
{ \
|
||||||
memContextSwitch(MEM_CONTEXT_XS_OLD()); \
|
memContextSwitch(memContextPrior()); \
|
||||||
memContextFree(MEM_CONTEXT_XS_TEMP()); \
|
memContextFree(MEM_CONTEXT_XS_TEMP()); \
|
||||||
} \
|
} \
|
||||||
TRY_END(); \
|
TRY_END(); \
|
||||||
\
|
\
|
||||||
|
@ -110,9 +110,11 @@ perlOptionJson(void)
|
|||||||
kvPut(configKv, VARSTRZ(cfgOptionName(optionId)), optionVar);
|
kvPut(configKv, VARSTRZ(cfgOptionName(optionId)), optionVar);
|
||||||
}
|
}
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = jsonFromKv(configKv);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = jsonFromKv(configKv);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -19,9 +19,11 @@ INPUT:
|
|||||||
CODE:
|
CODE:
|
||||||
CHECK(strEqZ(class, PACKAGE_NAME_LIBC "::PgClient"));
|
CHECK(strEqZ(class, PACKAGE_NAME_LIBC "::PgClient"));
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_XS_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
RETVAL = pgClientNew(host, port, database, NULL, queryTimeout);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_XS_TEMP());
|
RETVAL = pgClientNew(host, port, database, NULL, queryTimeout);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
CLEANUP:
|
CLEANUP:
|
||||||
|
@ -19,10 +19,12 @@ CODE:
|
|||||||
|
|
||||||
if (strEqZ(type, "<LOCAL>"))
|
if (strEqZ(type, "<LOCAL>"))
|
||||||
{
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_XS_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
RETVAL = storagePosixNew(
|
{
|
||||||
path == NULL ? STRDEF("/") : path, STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
|
RETVAL = storagePosixNew(
|
||||||
memContextSwitch(MEM_CONTEXT_XS_TEMP());
|
path == NULL ? STRDEF("/") : path, STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
else if (strEqZ(type, "<REPO>"))
|
else if (strEqZ(type, "<REPO>"))
|
||||||
{
|
{
|
||||||
@ -33,9 +35,11 @@ CODE:
|
|||||||
{
|
{
|
||||||
CHECK(path == NULL);
|
CHECK(path == NULL);
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_XS_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
RETVAL = storagePosixNew(cfgOptionStr(cfgOptPgPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_XS_TEMP());
|
RETVAL = storagePosixNew(cfgOptionStr(cfgOptPgPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
THROW_FMT(AssertError, "unexpected storage type '%s'", strPtr(type));
|
THROW_FMT(AssertError, "unexpected storage type '%s'", strPtr(type));
|
||||||
|
@ -18,7 +18,7 @@ INPUT:
|
|||||||
CODE:
|
CODE:
|
||||||
CHECK(strEqZ(class, PACKAGE_NAME_LIBC "::StorageRead"));
|
CHECK(strEqZ(class, PACKAGE_NAME_LIBC "::StorageRead"));
|
||||||
|
|
||||||
RETVAL = storageReadMove(storageNewReadP(storage, file, .ignoreMissing = ignoreMissing), MEM_CONTEXT_XS_OLD());
|
RETVAL = storageReadMove(storageNewReadP(storage, file, .ignoreMissing = ignoreMissing), memContextPrior());
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
CLEANUP:
|
CLEANUP:
|
||||||
|
@ -28,7 +28,7 @@ CODE:
|
|||||||
storage, file, .modeFile = mode, .user = user, .group = group, .timeModified = (time_t)timeModified,
|
storage, file, .modeFile = mode, .user = user, .group = group, .timeModified = (time_t)timeModified,
|
||||||
.noCreatePath = storageFeature(storage, storageFeaturePath) ? !pathCreate : false, .noSyncPath = !atomic,
|
.noCreatePath = storageFeature(storage, storageFeaturePath) ? !pathCreate : false, .noSyncPath = !atomic,
|
||||||
.noAtomic = !atomic),
|
.noAtomic = !atomic),
|
||||||
MEM_CONTEXT_XS_OLD());
|
memContextPrior());
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
CLEANUP:
|
CLEANUP:
|
||||||
|
@ -361,10 +361,12 @@ walSegmentFind(const Storage *storage, const String *archiveId, const String *wa
|
|||||||
strPtr(walSegment), strPtr(strLstJoin(strLstSort(list, sortOrderAsc), ", ")));
|
strPtr(walSegment), strPtr(strLstJoin(strLstSort(list, sortOrderAsc), ", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy file name of WAL segment found into the calling context
|
// Copy file name of WAL segment found into the prior context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(strLstGet(list, 0));
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(strLstGet(list, 0));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (result == NULL && wait != NULL && waitMore(wait));
|
while (result == NULL && wait != NULL && waitMore(wait));
|
||||||
@ -469,7 +471,7 @@ walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, unsigned i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strLstMove(result, MEM_CONTEXT_OLD());
|
strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -97,10 +97,12 @@ archiveGetCheck(const String *archiveFile, CipherType cipherType, const String *
|
|||||||
|
|
||||||
if (archiveFileActual != NULL)
|
if (archiveFileActual != NULL)
|
||||||
{
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result.archiveFileActual = strNewFmt("%s/%s", strPtr(archiveId), strPtr(archiveFileActual));
|
{
|
||||||
result.cipherPass = strDup(infoArchiveCipherPass(info));
|
result.archiveFileActual = strNewFmt("%s/%s", strPtr(archiveId), strPtr(archiveFileActual));
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result.cipherPass = strDup(infoArchiveCipherPass(info));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
@ -88,12 +88,14 @@ archivePushFile(
|
|||||||
|
|
||||||
if (strEq(walSegmentChecksum, walSegmentRepoChecksum))
|
if (strEq(walSegmentChecksum, walSegmentRepoChecksum))
|
||||||
{
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strNewFmt(
|
{
|
||||||
"WAL file '%s' already exists in the archive with the same checksum"
|
result = strNewFmt(
|
||||||
"\nHINT: this is valid in some recovery scenarios but may also indicate a problem.",
|
"WAL file '%s' already exists in the archive with the same checksum"
|
||||||
strPtr(archiveFile));
|
"\nHINT: this is valid in some recovery scenarios but may also indicate a problem.",
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
strPtr(archiveFile));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
THROW_FMT(ArchiveDuplicateError, "WAL file '%s' already exists in the archive", strPtr(archiveFile));
|
THROW_FMT(ArchiveDuplicateError, "WAL file '%s' already exists in the archive", strPtr(archiveFile));
|
||||||
|
@ -107,7 +107,7 @@ archivePushReadyList(const String *walPath)
|
|||||||
strSubN(strLstGet(readyListRaw, readyIdx), 0, strSize(strLstGet(readyListRaw, readyIdx)) - STATUS_EXT_READY_SIZE));
|
strSubN(strLstGet(readyListRaw, readyIdx), 0, strSize(strLstGet(readyListRaw, readyIdx)) - STATUS_EXT_READY_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
strLstMove(result, MEM_CONTEXT_OLD());
|
strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ archivePushProcessList(const String *walPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return all ready files that are not in the ok list
|
// Return all ready files that are not in the ok list
|
||||||
result = strLstMove(strLstMergeAnti(readyList, okList), MEM_CONTEXT_OLD());
|
result = strLstMove(strLstMergeAnti(readyList, okList), memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -233,13 +233,15 @@ archivePushCheck(CipherType cipherType, const String *cipherPass)
|
|||||||
archiveInfo.systemId);
|
archiveInfo.systemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result.pgVersion = controlInfo.version;
|
{
|
||||||
result.pgSystemId = controlInfo.systemId;
|
result.pgVersion = controlInfo.version;
|
||||||
result.pgWalSegmentSize = controlInfo.walSegmentSize;
|
result.pgSystemId = controlInfo.systemId;
|
||||||
result.archiveId = strDup(archiveId);
|
result.pgWalSegmentSize = controlInfo.walSegmentSize;
|
||||||
result.archiveCipherPass = strDup(infoArchiveCipherPass(info));
|
result.archiveId = strDup(archiveId);
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result.archiveCipherPass = strDup(infoArchiveCipherPass(info));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -161,9 +161,11 @@ backupLabelCreate(BackupType type, const String *backupLabelPrior, time_t timest
|
|||||||
sleepMSec(MSEC_PER_SEC - (timeMSec() % MSEC_PER_SEC));
|
sleepMSec(MSEC_PER_SEC - (timeMSec() % MSEC_PER_SEC));
|
||||||
}
|
}
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(result);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(result);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -443,7 +445,7 @@ backupBuildIncrPrior(const InfoBackup *infoBackup)
|
|||||||
cfgOptionSet(cfgOptChecksumPage, cfgSourceParam, VARBOOL(checksumPagePrior));
|
cfgOptionSet(cfgOptChecksumPage, cfgSourceParam, VARBOOL(checksumPagePrior));
|
||||||
}
|
}
|
||||||
|
|
||||||
manifestMove(result, MEM_CONTEXT_OLD());
|
manifestMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -732,7 +734,7 @@ backupResumeFind(const Manifest *manifest, const String *cipherPassBackup)
|
|||||||
// If the backup is usable then return the manifest
|
// If the backup is usable then return the manifest
|
||||||
if (usable)
|
if (usable)
|
||||||
{
|
{
|
||||||
result = manifestMove(manifestResume, MEM_CONTEXT_OLD());
|
result = manifestMove(manifestResume, memContextPrior());
|
||||||
}
|
}
|
||||||
// Else warn and remove the unusable backup
|
// Else warn and remove the unusable backup
|
||||||
else
|
else
|
||||||
@ -865,12 +867,14 @@ backupStart(BackupData *backupData)
|
|||||||
DbBackupStartResult dbBackupStartResult = dbBackupStart(
|
DbBackupStartResult dbBackupStartResult = dbBackupStart(
|
||||||
backupData->dbPrimary, cfgOptionBool(cfgOptStartFast), cfgOptionBool(cfgOptStopAuto));
|
backupData->dbPrimary, cfgOptionBool(cfgOptStartFast), cfgOptionBool(cfgOptStopAuto));
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result.lsn = strDup(dbBackupStartResult.lsn);
|
{
|
||||||
result.walSegmentName = strDup(dbBackupStartResult.walSegmentName);
|
result.lsn = strDup(dbBackupStartResult.lsn);
|
||||||
result.dbList = dbList(backupData->dbPrimary);
|
result.walSegmentName = strDup(dbBackupStartResult.walSegmentName);
|
||||||
result.tablespaceList = dbTablespaceList(backupData->dbPrimary);
|
result.dbList = dbList(backupData->dbPrimary);
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result.tablespaceList = dbTablespaceList(backupData->dbPrimary);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
|
|
||||||
LOG_INFO_FMT("backup start archive = %s, lsn = %s", strPtr(result.walSegmentName), strPtr(result.lsn));
|
LOG_INFO_FMT("backup start archive = %s, lsn = %s", strPtr(result.walSegmentName), strPtr(result.lsn));
|
||||||
|
|
||||||
@ -1011,11 +1015,13 @@ backupStop(BackupData *backupData, Manifest *manifest)
|
|||||||
|
|
||||||
DbBackupStopResult dbBackupStopResult = dbBackupStop(backupData->dbPrimary);
|
DbBackupStopResult dbBackupStopResult = dbBackupStop(backupData->dbPrimary);
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result.timestamp = backupTime(backupData, false);
|
{
|
||||||
result.lsn = strDup(dbBackupStopResult.lsn);
|
result.timestamp = backupTime(backupData, false);
|
||||||
result.walSegmentName = strDup(dbBackupStopResult.walSegmentName);
|
result.lsn = strDup(dbBackupStopResult.lsn);
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result.walSegmentName = strDup(dbBackupStopResult.walSegmentName);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
|
|
||||||
LOG_INFO_FMT("backup stop archive = %s, lsn = %s", strPtr(result.walSegmentName), strPtr(result.lsn));
|
LOG_INFO_FMT("backup stop archive = %s, lsn = %s", strPtr(result.walSegmentName), strPtr(result.lsn));
|
||||||
|
|
||||||
@ -1378,8 +1384,8 @@ backupProcessQueue(Manifest *manifest, List **queueList)
|
|||||||
for (unsigned int targetIdx = 0; targetIdx < strLstSize(targetList); targetIdx++)
|
for (unsigned int targetIdx = 0; targetIdx < strLstSize(targetList); targetIdx++)
|
||||||
lstSort(*(List **)lstGet(*queueList, targetIdx), sortOrderDesc);
|
lstSort(*(List **)lstGet(*queueList, targetIdx), sortOrderDesc);
|
||||||
|
|
||||||
// Move process queues to calling context
|
// Move process queues to prior context
|
||||||
lstMove(*queueList, MEM_CONTEXT_OLD());
|
lstMove(*queueList, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -1475,7 +1481,7 @@ static ProtocolParallelJob *backupJobCallback(void *data, unsigned int clientIdx
|
|||||||
lstRemoveIdx(queue, 0);
|
lstRemoveIdx(queue, 0);
|
||||||
|
|
||||||
// Assign job to result
|
// Assign job to result
|
||||||
result = protocolParallelJobMove(protocolParallelJobNew(VARSTR(file->name), command), MEM_CONTEXT_OLD());
|
result = protocolParallelJobMove(protocolParallelJobNew(VARSTR(file->name), command), memContextPrior());
|
||||||
|
|
||||||
// Break out of the loop early since we found a job
|
// Break out of the loop early since we found a job
|
||||||
break;
|
break;
|
||||||
|
@ -107,11 +107,13 @@ backupFile(
|
|||||||
// If it matches and is a reference to a previous backup then no need to copy the file
|
// If it matches and is a reference to a previous backup then no need to copy the file
|
||||||
if (repoFileHasReference)
|
if (repoFileHasReference)
|
||||||
{
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result.backupCopyResult = backupCopyResultNoOp;
|
{
|
||||||
result.copySize = pgTestSize;
|
result.backupCopyResult = backupCopyResultNoOp;
|
||||||
result.copyChecksum = strDup(pgTestChecksum);
|
result.copySize = pgTestSize;
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result.copyChecksum = strDup(pgTestChecksum);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,11 +164,13 @@ backupFile(
|
|||||||
// No need to recopy if checksum/size match
|
// No need to recopy if checksum/size match
|
||||||
if (pgFileSize == pgTestSize && strEq(pgFileChecksum, pgTestChecksum))
|
if (pgFileSize == pgTestSize && strEq(pgFileChecksum, pgTestChecksum))
|
||||||
{
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result.backupCopyResult = backupCopyResultChecksum;
|
{
|
||||||
result.copySize = pgTestSize;
|
result.backupCopyResult = backupCopyResultChecksum;
|
||||||
result.copyChecksum = strDup(pgTestChecksum);
|
result.copySize = pgTestSize;
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result.copyChecksum = strDup(pgTestChecksum);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
// Else recopy when repo file is not as expected
|
// Else recopy when repo file is not as expected
|
||||||
else
|
else
|
||||||
@ -221,24 +225,24 @@ backupFile(
|
|||||||
// Open the source and destination and copy the file
|
// Open the source and destination and copy the file
|
||||||
if (storageCopy(read, write))
|
if (storageCopy(read, write))
|
||||||
{
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
|
|
||||||
// Get sizes and checksum
|
|
||||||
result.copySize = varUInt64Force(
|
|
||||||
ioFilterGroupResult(ioReadFilterGroup(storageReadIo(read)), SIZE_FILTER_TYPE_STR));
|
|
||||||
result.copyChecksum = strDup(
|
|
||||||
varStr(ioFilterGroupResult(ioReadFilterGroup(storageReadIo(read)), CRYPTO_HASH_FILTER_TYPE_STR)));
|
|
||||||
result.repoSize =
|
|
||||||
varUInt64Force(ioFilterGroupResult(ioWriteFilterGroup(storageWriteIo(write)), SIZE_FILTER_TYPE_STR));
|
|
||||||
|
|
||||||
// Get results of page checksum validation
|
|
||||||
if (pgFileChecksumPage)
|
|
||||||
{
|
{
|
||||||
result.pageChecksumResult = kvDup(
|
// Get sizes and checksum
|
||||||
varKv(ioFilterGroupResult(ioReadFilterGroup(storageReadIo(read)), PAGE_CHECKSUM_FILTER_TYPE_STR)));
|
result.copySize = varUInt64Force(
|
||||||
}
|
ioFilterGroupResult(ioReadFilterGroup(storageReadIo(read)), SIZE_FILTER_TYPE_STR));
|
||||||
|
result.copyChecksum = strDup(
|
||||||
|
varStr(ioFilterGroupResult(ioReadFilterGroup(storageReadIo(read)), CRYPTO_HASH_FILTER_TYPE_STR)));
|
||||||
|
result.repoSize =
|
||||||
|
varUInt64Force(ioFilterGroupResult(ioWriteFilterGroup(storageWriteIo(write)), SIZE_FILTER_TYPE_STR));
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
// Get results of page checksum validation
|
||||||
|
if (pgFileChecksumPage)
|
||||||
|
{
|
||||||
|
result.pageChecksumResult = kvDup(
|
||||||
|
varKv(ioFilterGroupResult(ioReadFilterGroup(storageReadIo(read)), PAGE_CHECKSUM_FILTER_TYPE_STR)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
// Else if source file is missing and the read setup indicated ignore a missing file, the database removed it so skip it
|
// Else if source file is missing and the read setup indicated ignore a missing file, the database removed it so skip it
|
||||||
else
|
else
|
||||||
|
@ -802,9 +802,11 @@ infoRender(void)
|
|||||||
else
|
else
|
||||||
resultStr = jsonFromVar(varNewVarLst(infoList));
|
resultStr = jsonFromVar(varNewVarLst(infoList));
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(resultStr);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(resultStr);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -151,9 +151,11 @@ restoreBackupSet(InfoBackup *infoBackup)
|
|||||||
THROW_FMT(BackupSetInvalidError, "backup set %s is not valid", strPtr(backupSet));
|
THROW_FMT(BackupSetInvalidError, "backup set %s is not valid", strPtr(backupSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(backupSet);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(backupSet);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -493,16 +495,16 @@ restoreManifestOwner(Manifest *manifest)
|
|||||||
if (groupNull)
|
if (groupNull)
|
||||||
LOG_WARN_FMT("unknown group in backup manifest mapped to '%s'", strPtr(pathInfo.group));
|
LOG_WARN_FMT("unknown group in backup manifest mapped to '%s'", strPtr(pathInfo.group));
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
|
{
|
||||||
|
const String *user = strDup(pathInfo.user);
|
||||||
|
const String *group = strDup(pathInfo.group);
|
||||||
|
|
||||||
const String *user = strDup(pathInfo.user);
|
RESTORE_MANIFEST_OWNER_NULL_UPDATE(File, user, group)
|
||||||
const String *group = strDup(pathInfo.group);
|
RESTORE_MANIFEST_OWNER_NULL_UPDATE(Link, user, group)
|
||||||
|
RESTORE_MANIFEST_OWNER_NULL_UPDATE(Path, user, group)
|
||||||
RESTORE_MANIFEST_OWNER_NULL_UPDATE(File, user, group)
|
}
|
||||||
RESTORE_MANIFEST_OWNER_NULL_UPDATE(Link, user, group)
|
MEM_CONTEXT_PRIOR_END();
|
||||||
RESTORE_MANIFEST_OWNER_NULL_UPDATE(Path, user, group)
|
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Else set owners to NULL. This means we won't make any attempt to update ownership and will just leave it as written by
|
// Else set owners to NULL. This means we won't make any attempt to update ownership and will just leave it as written by
|
||||||
@ -1147,9 +1149,11 @@ restoreSelectiveExpression(Manifest *manifest)
|
|||||||
// Else return the expression
|
// Else return the expression
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(expression);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(expression);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
@ -1285,8 +1289,8 @@ restoreRecoveryOption(unsigned int pgVersion)
|
|||||||
if (cfgOptionTest(cfgOptTargetTimeline))
|
if (cfgOptionTest(cfgOptTargetTimeline))
|
||||||
kvPut(result, VARSTRZ(RECOVERY_TARGET_TIMELINE), VARSTR(cfgOptionStr(cfgOptTargetTimeline)));
|
kvPut(result, VARSTRZ(RECOVERY_TARGET_TIMELINE), VARSTR(cfgOptionStr(cfgOptTargetTimeline)));
|
||||||
|
|
||||||
// Move to calling context
|
// Move to prior context
|
||||||
kvMove(result, MEM_CONTEXT_OLD());
|
kvMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -1318,10 +1322,12 @@ restoreRecoveryConf(unsigned int pgVersion, const String *restoreLabel)
|
|||||||
strCatFmt(result, "%s = '%s'\n", strPtr(varStr(optionKey)), strPtr(varStr(kvGet(optionKv, optionKey))));
|
strCatFmt(result, "%s = '%s'\n", strPtr(varStr(optionKey)), strPtr(varStr(kvGet(optionKv, optionKey))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move to calling context
|
// Move to prior context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(result);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(result);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -1626,8 +1632,8 @@ restoreProcessQueue(Manifest *manifest, List **queueList)
|
|||||||
for (unsigned int targetIdx = 0; targetIdx < strLstSize(targetList); targetIdx++)
|
for (unsigned int targetIdx = 0; targetIdx < strLstSize(targetList); targetIdx++)
|
||||||
lstSort(*(List **)lstGet(*queueList, targetIdx), sortOrderDesc);
|
lstSort(*(List **)lstGet(*queueList, targetIdx), sortOrderDesc);
|
||||||
|
|
||||||
// Move process queues to calling context
|
// Move process queues to prior context
|
||||||
lstMove(*queueList, MEM_CONTEXT_OLD());
|
lstMove(*queueList, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -1840,7 +1846,7 @@ static ProtocolParallelJob *restoreJobCallback(void *data, unsigned int clientId
|
|||||||
lstRemoveIdx(queue, 0);
|
lstRemoveIdx(queue, 0);
|
||||||
|
|
||||||
// Assign job to result
|
// Assign job to result
|
||||||
result = protocolParallelJobMove(protocolParallelJobNew(VARSTR(file->name), command), MEM_CONTEXT_OLD());
|
result = protocolParallelJobMove(protocolParallelJobNew(VARSTR(file->name), command), memContextPrior());
|
||||||
|
|
||||||
// Break out of the loop early since we found a job
|
// Break out of the loop early since we found a job
|
||||||
break;
|
break;
|
||||||
|
@ -212,9 +212,11 @@ cryptoHashOne(const String *type, const Buffer *message)
|
|||||||
|
|
||||||
const Buffer *buffer = cryptoHash((CryptoHash *)ioFilterDriver(hash));
|
const Buffer *buffer = cryptoHash((CryptoHash *)ioFilterDriver(hash));
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = bufDup(buffer);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = bufDup(buffer);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ iniSectionKeyList(const Ini *this, const String *section)
|
|||||||
else
|
else
|
||||||
result = strLstNew();
|
result = strLstNew();
|
||||||
|
|
||||||
strLstMove(result, MEM_CONTEXT_OLD());
|
strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ iniSectionList(const Ini *this)
|
|||||||
// Get the sections from the keyList
|
// Get the sections from the keyList
|
||||||
result = strLstNewVarLst(kvKeyList(this->store));
|
result = strLstNewVarLst(kvKeyList(this->store));
|
||||||
|
|
||||||
strLstMove(result, MEM_CONTEXT_OLD());
|
strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -389,9 +389,11 @@ iniLoad(
|
|||||||
THROW_FMT(FormatError, "ini section should end with ] at line %u: %s", lineIdx + 1, linePtr);
|
THROW_FMT(FormatError, "ini section should end with ] at line %u: %s", lineIdx + 1, linePtr);
|
||||||
|
|
||||||
// Assign section
|
// Assign section
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
section = strNewN(linePtr + 1, strSize(line) - 2);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
section = strNewN(linePtr + 1, strSize(line) - 2);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
// Else it should be a key/value
|
// Else it should be a key/value
|
||||||
else
|
else
|
||||||
|
@ -452,7 +452,7 @@ httpClientRequest(
|
|||||||
RETHROW();
|
RETHROW();
|
||||||
|
|
||||||
// Move the result buffer (if any) to the parent context
|
// Move the result buffer (if any) to the parent context
|
||||||
bufMove(result, MEM_CONTEXT_OLD());
|
bufMove(result, memContextPrior());
|
||||||
|
|
||||||
httpClientStatLocal.request++;
|
httpClientStatLocal.request++;
|
||||||
}
|
}
|
||||||
|
@ -67,9 +67,9 @@ ioReadBuf(IoRead *read)
|
|||||||
}
|
}
|
||||||
while (!ioReadEof(read));
|
while (!ioReadEof(read));
|
||||||
|
|
||||||
// Resize the buffer and move to calling context
|
// Resize the buffer and move to prior context
|
||||||
bufResize(result, bufUsed(result));
|
bufResize(result, bufUsed(result));
|
||||||
bufMove(result, MEM_CONTEXT_OLD());
|
bufMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ Space is reserved for this many allocations when a context is created. When mor
|
|||||||
Memory context management functions
|
Memory context management functions
|
||||||
|
|
||||||
MemContext *context = memContextNew();
|
MemContext *context = memContextNew();
|
||||||
MemContext *contextOld = memContextSwitch(context);
|
MemContext *contextPrior = memContextSwitch(context);
|
||||||
|
|
||||||
TRY_BEGIN()
|
TRY_BEGIN()
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ CATCH_ANY()
|
|||||||
}
|
}
|
||||||
FINALLY
|
FINALLY
|
||||||
{
|
{
|
||||||
memContextSwitch(context);
|
memContextSwitch(contextPrior);
|
||||||
}
|
}
|
||||||
TRY_END();
|
TRY_END();
|
||||||
|
|
||||||
@ -78,39 +78,67 @@ void *memGrowRaw(const void *buffer, size_t size);
|
|||||||
void memFree(void *buffer);
|
void memFree(void *buffer);
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Ensure that the old memory context is restored after the block executes (even on error)
|
Ensure that the prior memory context is restored after the block executes (even on error)
|
||||||
|
|
||||||
MEM_CONTEXT_BEGIN(memContext)
|
MEM_CONTEXT_BEGIN(memContext)
|
||||||
{
|
{
|
||||||
<The mem context specified is now the current context>
|
<The mem context specified is now the current context>
|
||||||
<Old context can be accessed with the MEM_CONTEXT_OLD() macro>
|
<Prior context can be accessed with the memContextPrior() macro>
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_END();
|
MEM_CONTEXT_END();
|
||||||
|
|
||||||
<Old memory context is restored>
|
<Prior memory context is restored>
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
#define MEM_CONTEXT_BEGIN(memContext) \
|
#define MEM_CONTEXT_BEGIN(memContext) \
|
||||||
{ \
|
{ \
|
||||||
/* Switch to the new memory context */ \
|
/* Switch to the new memory context */ \
|
||||||
MemContext *MEM_CONTEXT_memContextOld = memContextSwitch(memContext); \
|
MemContext *MEM_CONTEXT_memContextPrior = memContextSwitch(memContext); \
|
||||||
\
|
\
|
||||||
/* Try the statement block */ \
|
/* Try the statement block */ \
|
||||||
TRY_BEGIN()
|
TRY_BEGIN()
|
||||||
|
|
||||||
#define MEM_CONTEXT_OLD() \
|
#define memContextPrior() \
|
||||||
MEM_CONTEXT_memContextOld
|
MEM_CONTEXT_memContextPrior
|
||||||
|
|
||||||
#define MEM_CONTEXT_END() \
|
#define MEM_CONTEXT_END() \
|
||||||
/* Switch back to the old context */ \
|
/* Switch back to the prior context */ \
|
||||||
FINALLY() \
|
FINALLY() \
|
||||||
{ \
|
{ \
|
||||||
memContextSwitch(MEM_CONTEXT_OLD()); \
|
memContextSwitch(memContextPrior()); \
|
||||||
} \
|
} \
|
||||||
TRY_END(); \
|
TRY_END(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Create a new context and make sure it is freed on error and old context is restored in all cases
|
Switch to prior context and ensure that the previous prior memory context is restored after the block executes (even on error)
|
||||||
|
|
||||||
|
MEM_CONTEXT_PRIOR_BEGIN(memContext)
|
||||||
|
{
|
||||||
|
<The mem context specified is now the prior context>
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
|
|
||||||
|
<Previous prior memory context is restored>
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
#define MEM_CONTEXT_PRIOR_BEGIN(memContext) \
|
||||||
|
{ \
|
||||||
|
/* Switch to the new memory context */ \
|
||||||
|
MemContext *MEM_CONTEXT_memContextRestore = memContextSwitch(memContextPrior()); \
|
||||||
|
\
|
||||||
|
/* Try the statement block */ \
|
||||||
|
TRY_BEGIN()
|
||||||
|
|
||||||
|
#define MEM_CONTEXT_PRIOR_END() \
|
||||||
|
/* Switch back to the prior context */ \
|
||||||
|
FINALLY() \
|
||||||
|
{ \
|
||||||
|
memContextSwitch(MEM_CONTEXT_memContextRestore); \
|
||||||
|
} \
|
||||||
|
TRY_END(); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Create a new context and make sure it is freed on error and prior context is restored in all cases
|
||||||
|
|
||||||
MEM_CONTEXT_NEW_BEGIN(memContextName)
|
MEM_CONTEXT_NEW_BEGIN(memContextName)
|
||||||
{
|
{
|
||||||
@ -119,12 +147,12 @@ MEM_CONTEXT_NEW_BEGIN(memContextName)
|
|||||||
ObjectType *object = memNew(sizeof(ObjectType));
|
ObjectType *object = memNew(sizeof(ObjectType));
|
||||||
object->memContext = MEM_CONTEXT_NEW();
|
object->memContext = MEM_CONTEXT_NEW();
|
||||||
|
|
||||||
<Old context can be accessed with the MEM_CONTEXT_OLD() macro>
|
<Prior context can be accessed with the memContextPrior() macro>
|
||||||
<On error the newly created context will be freed and the error rethrown>
|
<On error the newly created context will be freed and the error rethrown>
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_NEW_END();
|
MEM_CONTEXT_NEW_END();
|
||||||
|
|
||||||
<Old memory context is restored>
|
<Prior memory context is restored>
|
||||||
|
|
||||||
Note that memory context names are expected to live for the lifetime of the context -- no copy is made.
|
Note that memory context names are expected to live for the lifetime of the context -- no copy is made.
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
@ -140,7 +168,7 @@ Note that memory context names are expected to live for the lifetime of the cont
|
|||||||
#define MEM_CONTEXT_NEW_END() \
|
#define MEM_CONTEXT_NEW_END() \
|
||||||
CATCH_ANY() \
|
CATCH_ANY() \
|
||||||
{ \
|
{ \
|
||||||
memContextSwitch(MEM_CONTEXT_OLD()); \
|
memContextSwitch(memContextPrior()); \
|
||||||
memContextFree(MEM_CONTEXT_NEW()); \
|
memContextFree(MEM_CONTEXT_NEW()); \
|
||||||
RETHROW(); \
|
RETHROW(); \
|
||||||
} \
|
} \
|
||||||
@ -154,11 +182,11 @@ MEM_CONTEXT_TEMP_BEGIN()
|
|||||||
{
|
{
|
||||||
<A temp memory context is now the current context>
|
<A temp memory context is now the current context>
|
||||||
<Temp context can be accessed with the MEM_CONTEXT_TEMP() macro>
|
<Temp context can be accessed with the MEM_CONTEXT_TEMP() macro>
|
||||||
<Old context can be accessed with the MEM_CONTEXT_OLD() macro>
|
<Prior context can be accessed with the memContextPrior() macro>
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
<Old memory context is restored>
|
<Prior memory context is restored>
|
||||||
<Temp memory context is freed>
|
<Temp memory context is freed>
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
#define MEM_CONTEXT_TEMP() \
|
#define MEM_CONTEXT_TEMP() \
|
||||||
@ -184,7 +212,7 @@ MEM_CONTEXT_TEMP_END();
|
|||||||
\
|
\
|
||||||
if (MEM_CONTEXT_TEMP_loopTotal >= resetTotal) \
|
if (MEM_CONTEXT_TEMP_loopTotal >= resetTotal) \
|
||||||
{ \
|
{ \
|
||||||
memContextSwitch(MEM_CONTEXT_OLD()); \
|
memContextSwitch(memContextPrior()); \
|
||||||
memContextFree(MEM_CONTEXT_TEMP()); \
|
memContextFree(MEM_CONTEXT_TEMP()); \
|
||||||
MEM_CONTEXT_TEMP() = memContextNew("temporary"); \
|
MEM_CONTEXT_TEMP() = memContextNew("temporary"); \
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP()); \
|
memContextSwitch(MEM_CONTEXT_TEMP()); \
|
||||||
@ -194,10 +222,10 @@ MEM_CONTEXT_TEMP_END();
|
|||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
#define MEM_CONTEXT_TEMP_END() \
|
#define MEM_CONTEXT_TEMP_END() \
|
||||||
/* Switch back to the old context and free temp context */ \
|
/* Switch back to the prior context and free temp context */ \
|
||||||
FINALLY() \
|
FINALLY() \
|
||||||
{ \
|
{ \
|
||||||
memContextSwitch(MEM_CONTEXT_OLD()); \
|
memContextSwitch(memContextPrior()); \
|
||||||
memContextFree(MEM_CONTEXT_TEMP()); \
|
memContextFree(MEM_CONTEXT_TEMP()); \
|
||||||
} \
|
} \
|
||||||
TRY_END(); \
|
TRY_END(); \
|
||||||
|
@ -118,14 +118,14 @@ jsonToNumberInternal(const char *json, unsigned int *jsonPos)
|
|||||||
String *resultStr = strNewN(json + beginPos, *jsonPos - beginPos);
|
String *resultStr = strNewN(json + beginPos, *jsonPos - beginPos);
|
||||||
|
|
||||||
// Convert the string to a integer variant
|
// Convert the string to a integer variant
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
|
{
|
||||||
if (intSigned)
|
if (intSigned)
|
||||||
result = varNewInt64(cvtZToInt64(strPtr(resultStr)));
|
result = varNewInt64(cvtZToInt64(strPtr(resultStr)));
|
||||||
else
|
else
|
||||||
result = varNewUInt64(cvtZToUInt64(strPtr(resultStr)));
|
result = varNewUInt64(cvtZToUInt64(strPtr(resultStr)));
|
||||||
|
}
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -442,9 +442,11 @@ jsonToVarLstInternal(const char *json, unsigned int *jsonPos)
|
|||||||
jsonConsumeWhiteSpace(json, jsonPos);
|
jsonConsumeWhiteSpace(json, jsonPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
varLstAdd(result, jsonToVarInternal(json, jsonPos));
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
varLstAdd(result, jsonToVarInternal(json, jsonPos));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
|
|
||||||
jsonConsumeWhiteSpace(json, jsonPos);
|
jsonConsumeWhiteSpace(json, jsonPos);
|
||||||
}
|
}
|
||||||
@ -863,10 +865,12 @@ jsonFromKv(const KeyValue *kv)
|
|||||||
{
|
{
|
||||||
String *jsonStr = jsonFromKvInternal(kv);
|
String *jsonStr = jsonFromKvInternal(kv);
|
||||||
|
|
||||||
// Duplicate the string into the calling context
|
// Duplicate the string into the prior context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(jsonStr);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(jsonStr);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -981,10 +985,12 @@ jsonFromVar(const Variant *var)
|
|||||||
else
|
else
|
||||||
THROW(JsonFormatError, "variant type is invalid");
|
THROW(JsonFormatError, "variant type is invalid");
|
||||||
|
|
||||||
// Duplicate the string into the calling context
|
// Duplicate the string into the prior context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(jsonStr);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(jsonStr);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -669,14 +669,14 @@ strPathAbsolute(const String *this, const String *base)
|
|||||||
strLstRemoveIdx(pathList, 0);
|
strLstRemoveIdx(pathList, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
|
{
|
||||||
if (strLstSize(baseList) == 1)
|
if (strLstSize(baseList) == 1)
|
||||||
result = strDup(FSLASH_STR);
|
result = strDup(FSLASH_STR);
|
||||||
else
|
else
|
||||||
result = strLstJoin(baseList, "/");
|
result = strLstJoin(baseList, "/");
|
||||||
|
}
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,12 @@ old context and then back. Below is a simplified example:
|
|||||||
MEM_CONTEXT_TEMP_BEGIN() <--- begins a new temporary context
|
MEM_CONTEXT_TEMP_BEGIN() <--- begins a new temporary context
|
||||||
{
|
{
|
||||||
String *resultStr = strNewN("myNewStr"); <--- creates a string in the temporary memory context
|
String *resultStr = strNewN("myNewStr"); <--- creates a string in the temporary memory context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD()); <--- switch to the old context so the duplication of the string is in that context
|
|
||||||
result = strDup(resultStr); <--- recreates a copy of the string in the old context where "result" was created.
|
MEM_CONTEXT_PRIOR_BEGIN() <--- switch to the old context so the duplication of the string is in that context
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP()); <--- switch back to the temporary context
|
{
|
||||||
|
result = strDup(resultStr); <--- recreates a copy of the string in the old context where "result" was created
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END(); <--- switch back to the temporary context
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END(); <-- frees everything created inside this temporary memory context - i.e resultStr
|
MEM_CONTEXT_TEMP_END(); <-- frees everything created inside this temporary memory context - i.e resultStr
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
|
@ -538,7 +538,7 @@ strLstMergeAnti(const StringList *this, const StringList *anti)
|
|||||||
strLstAdd(result, listItem);
|
strLstAdd(result, listItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
strLstMove(result, MEM_CONTEXT_OLD());
|
strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -9,9 +9,12 @@ old context and then back. Below is a simplified example:
|
|||||||
MEM_CONTEXT_TEMP_BEGIN() <--- begins a new temporary context
|
MEM_CONTEXT_TEMP_BEGIN() <--- begins a new temporary context
|
||||||
{
|
{
|
||||||
String *resultStr = strNewN("myNewStr"); <--- creates a string in the temporary memory context
|
String *resultStr = strNewN("myNewStr"); <--- creates a string in the temporary memory context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD()); <--- switch to old context so creation of the variant from the string is in old context
|
|
||||||
result = varNewUInt64(cvtZToUInt64(strPtr(resultStr))); <--- recreates variant from the string in the old context.
|
MEM_CONTEXT_PRIOR_BEGIN() <--- switch to old context so creation of the variant from the string is in old context
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP()); <--- switch back to the temporary context
|
{
|
||||||
|
result = varNewUInt64(cvtZToUInt64(strPtr(resultStr))); <--- recreates variant from the string in the old context.
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END(); <--- switch back to the temporary context
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END(); <-- frees everything created inside this temporary memory context - i.e resultStr
|
MEM_CONTEXT_TEMP_END(); <-- frees everything created inside this temporary memory context - i.e resultStr
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
|
@ -686,9 +686,11 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the host
|
// Set the host
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(strLstGet(hostPart, 0));
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(strLstGet(hostPart, 0));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
|
|
||||||
// Set the port and error if it is not a positive integer
|
// Set the port and error if it is not a positive integer
|
||||||
TRY_BEGIN()
|
TRY_BEGIN()
|
||||||
@ -708,9 +710,11 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port)
|
|||||||
// Else there is no port and just copy the host
|
// Else there is no port and just copy the host
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(host);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(host);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
@ -128,8 +128,8 @@ cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const Key
|
|||||||
// Add the command
|
// Add the command
|
||||||
strLstAdd(result, cfgCommandRoleNameParam(commandId, commandRoleId, COLON_STR));
|
strLstAdd(result, cfgCommandRoleNameParam(commandId, commandRoleId, COLON_STR));
|
||||||
|
|
||||||
// Move list to the calling context
|
// Move list to the prior context
|
||||||
strLstMove(result, MEM_CONTEXT_OLD());
|
strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -71,9 +71,11 @@ configProtocolOption(ProtocolClient *client, const VariantList *paramList)
|
|||||||
for (unsigned int paramIdx = 0; paramIdx < varLstSize(paramList); paramIdx++)
|
for (unsigned int paramIdx = 0; paramIdx < varLstSize(paramList); paramIdx++)
|
||||||
protocolCommandParamAdd(command, varLstGet(paramList, paramIdx));
|
protocolCommandParamAdd(command, varLstGet(paramList, paramIdx));
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = varVarLst(protocolClientExecute(client, command, true));
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = varVarLst(protocolClientExecute(client, command, true));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
42
src/db/db.c
42
src/db/db.c
@ -328,10 +328,12 @@ dbBackupStart(Db *this, bool startFast, bool stopAuto)
|
|||||||
VariantList *row = dbQueryRow(this, dbBackupStartQuery(dbPgVersion(this), startFast));
|
VariantList *row = dbQueryRow(this, dbBackupStartQuery(dbPgVersion(this), startFast));
|
||||||
|
|
||||||
// Return results
|
// Return results
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result.lsn = strDup(varStr(varLstGet(row, 0)));
|
{
|
||||||
result.walSegmentName = strDup(varStr(varLstGet(row, 1)));
|
result.lsn = strDup(varStr(varLstGet(row, 0)));
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result.walSegmentName = strDup(varStr(varLstGet(row, 1)));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -411,20 +413,20 @@ dbBackupStop(Db *this)
|
|||||||
dbPgVersion(this) >= PG_VERSION_96 ? strSize(strTrim(strDup(varStr(varLstGet(row, 3))))) == 0 : false;
|
dbPgVersion(this) >= PG_VERSION_96 ? strSize(strTrim(strDup(varStr(varLstGet(row, 3))))) == 0 : false;
|
||||||
|
|
||||||
// Return results
|
// Return results
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
|
|
||||||
result.lsn = strDup(varStr(varLstGet(row, 0)));
|
|
||||||
result.walSegmentName = strDup(varStr(varLstGet(row, 1)));
|
|
||||||
|
|
||||||
if (dbPgVersion(this) >= PG_VERSION_96)
|
|
||||||
{
|
{
|
||||||
result.backupLabel = strDup(varStr(varLstGet(row, 2)));
|
result.lsn = strDup(varStr(varLstGet(row, 0)));
|
||||||
|
result.walSegmentName = strDup(varStr(varLstGet(row, 1)));
|
||||||
|
|
||||||
if (!tablespaceMapEmpty)
|
if (dbPgVersion(this) >= PG_VERSION_96)
|
||||||
result.tablespaceMap = strDup(varStr(varLstGet(row, 3)));
|
{
|
||||||
|
result.backupLabel = strDup(varStr(varLstGet(row, 2)));
|
||||||
|
|
||||||
|
if (!tablespaceMapEmpty)
|
||||||
|
result.tablespaceMap = strDup(varStr(varLstGet(row, 3)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -628,10 +630,12 @@ dbWalSwitch(Db *this)
|
|||||||
const String *walFileName = varStr(
|
const String *walFileName = varStr(
|
||||||
dbQueryColumn(this, strNewFmt("select pg_catalog.pg_%sfile_name(pg_catalog.pg_switch_%s())::text", walName, walName)));
|
dbQueryColumn(this, strNewFmt("select pg_catalog.pg_%sfile_name(pg_catalog.pg_switch_%s())::text", walName, walName)));
|
||||||
|
|
||||||
// Copy WAL segment name to the calling context
|
// Copy WAL segment name to the prior context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strDup(walFileName);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strDup(walFileName);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ dbGetId(unsigned int pgId)
|
|||||||
else
|
else
|
||||||
result = dbNew(NULL, protocolRemoteGet(protocolStorageTypePg, pgId), applicationName);
|
result = dbNew(NULL, protocolRemoteGet(protocolStorageTypePg, pgId), applicationName);
|
||||||
|
|
||||||
dbMove(result, MEM_CONTEXT_OLD());
|
dbMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -135,8 +135,8 @@ dbGet(bool primaryOnly, bool primaryRequired, bool standbyRequired)
|
|||||||
if (result.standbyId == 0 && standbyRequired)
|
if (result.standbyId == 0 && standbyRequired)
|
||||||
THROW(DbConnectError, "unable to find standby cluster - cannot proceed");
|
THROW(DbConnectError, "unable to find standby cluster - cannot proceed");
|
||||||
|
|
||||||
dbMove(result.primary, MEM_CONTEXT_OLD());
|
dbMove(result.primary, memContextPrior());
|
||||||
dbMove(result.standby, MEM_CONTEXT_OLD());
|
dbMove(result.standby, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -49,12 +49,14 @@ dbProtocol(const String *command, const VariantList *paramList, ProtocolServer *
|
|||||||
{
|
{
|
||||||
if (strEq(command, PROTOCOL_COMMAND_DB_OPEN_STR))
|
if (strEq(command, PROTOCOL_COMMAND_DB_OPEN_STR))
|
||||||
{
|
{
|
||||||
// If the db list does not exist then create it in the calling context (which should be persistent)
|
// If the db list does not exist then create it in the prior context (which should be persistent)
|
||||||
if (dbProtocolLocal.pgClientList == NULL)
|
if (dbProtocolLocal.pgClientList == NULL)
|
||||||
{
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
dbProtocolLocal.pgClientList = lstNew(sizeof(PgClient *));
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
dbProtocolLocal.pgClientList = lstNew(sizeof(PgClient *));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add db to the list
|
// Add db to the list
|
||||||
|
@ -2788,9 +2788,11 @@ manifestTargetPath(const Manifest *this, const ManifestTarget *target)
|
|||||||
|
|
||||||
strCat(pgPath, strPtr(target->path));
|
strCat(pgPath, strPtr(target->path));
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strPathAbsolute(pgPath, manifestTargetBase(this)->path);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strPathAbsolute(pgPath, manifestTargetBase(this)->path);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ pgClientQuery(PgClient *this, const String *query)
|
|||||||
}
|
}
|
||||||
TRY_END();
|
TRY_END();
|
||||||
|
|
||||||
varLstMove(result, MEM_CONTEXT_OLD());
|
varLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -565,9 +565,11 @@ pgTablespaceId(unsigned int pgVersion)
|
|||||||
{
|
{
|
||||||
String *pgVersionStr = pgVersionToStr(pgVersion);
|
String *pgVersionStr = pgVersionToStr(pgVersion);
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strNewFmt("PG_%s_%u", strPtr(pgVersionStr), pgCatalogVersion(pgVersion));
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strNewFmt("PG_%s_%u", strPtr(pgVersionStr), pgCatalogVersion(pgVersion));
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
}
|
}
|
||||||
@ -675,7 +677,7 @@ pgLsnRangeToWalSegmentList(
|
|||||||
strLstAdd(result, strNewFmt("%08X%08X%08X", timeline, startMajor, startMinor));
|
strLstAdd(result, strNewFmt("%08X%08X%08X", timeline, startMajor, startMinor));
|
||||||
}
|
}
|
||||||
|
|
||||||
strLstMove(result, MEM_CONTEXT_OLD());
|
strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ protocolClientReadOutput(ProtocolClient *this, bool outputRequired)
|
|||||||
if (outputRequired)
|
if (outputRequired)
|
||||||
{
|
{
|
||||||
// Just move the entire response kv since the output is the largest part if it
|
// Just move the entire response kv since the output is the largest part if it
|
||||||
kvMove(responseKv, MEM_CONTEXT_OLD());
|
kvMove(responseKv, memContextPrior());
|
||||||
}
|
}
|
||||||
// Else if no output is required then there should not be any
|
// Else if no output is required then there should not be any
|
||||||
else if (result != NULL)
|
else if (result != NULL)
|
||||||
@ -322,9 +322,11 @@ protocolClientReadLine(ProtocolClient *this)
|
|||||||
else if (strPtr(result)[0] != '.')
|
else if (strPtr(result)[0] != '.')
|
||||||
THROW_FMT(FormatError, "invalid prefix in '%s'", strPtr(result));
|
THROW_FMT(FormatError, "invalid prefix in '%s'", strPtr(result));
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = strSub(result, 1);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = strSub(result, 1);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -104,9 +104,11 @@ protocolCommandJson(const ProtocolCommand *this)
|
|||||||
if (this->parameterList != NULL)
|
if (this->parameterList != NULL)
|
||||||
kvPut(command, VARSTR(PROTOCOL_KEY_PARAMETER_STR), this->parameterList);
|
kvPut(command, VARSTR(PROTOCOL_KEY_PARAMETER_STR), this->parameterList);
|
||||||
|
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result = jsonFromKv(command);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result = jsonFromKv(command);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int hostId,
|
|||||||
// Disable output to stdout since it is used by the protocol
|
// Disable output to stdout since it is used by the protocol
|
||||||
kvPut(optionReplace, VARSTR(CFGOPT_LOG_LEVEL_CONSOLE_STR), VARSTRDEF("off"));
|
kvPut(optionReplace, VARSTR(CFGOPT_LOG_LEVEL_CONSOLE_STR), VARSTRDEF("off"));
|
||||||
|
|
||||||
result = strLstMove(cfgExecParam(cfgCommand(), cfgCmdRoleLocal, optionReplace, true, false), MEM_CONTEXT_OLD());
|
result = strLstMove(cfgExecParam(cfgCommand(), cfgCmdRoleLocal, optionReplace, true, false), memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ storagePosixList(THIS_VOID, const String *path, StorageInterfaceListParam param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move finished list up to the old context
|
// Move finished list up to the old context
|
||||||
strLstMove(result, MEM_CONTEXT_OLD());
|
strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
}
|
}
|
||||||
|
@ -142,13 +142,15 @@ storageRemoteInfo(THIS_VOID, const String *file, StorageInterfaceInfoParam param
|
|||||||
// Acknowledge command completed
|
// Acknowledge command completed
|
||||||
protocolClientReadOutput(this->client, false);
|
protocolClientReadOutput(this->client, false);
|
||||||
|
|
||||||
// Duplicate strings into the calling context
|
// Duplicate strings into the prior context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result.name = strDup(result.name);
|
{
|
||||||
result.linkDestination = strDup(result.linkDestination);
|
result.name = strDup(result.name);
|
||||||
result.user = strDup(result.user);
|
result.linkDestination = strDup(result.linkDestination);
|
||||||
result.group = strDup(result.group);
|
result.user = strDup(result.user);
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result.group = strDup(result.group);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
@ -231,7 +233,7 @@ storageRemoteList(THIS_VOID, const String *path, StorageInterfaceListParam param
|
|||||||
protocolCommandParamAdd(command, VARSTR(path));
|
protocolCommandParamAdd(command, VARSTR(path));
|
||||||
protocolCommandParamAdd(command, VARSTR(param.expression));
|
protocolCommandParamAdd(command, VARSTR(param.expression));
|
||||||
|
|
||||||
result = strLstMove(strLstNewVarLst(varVarLst(protocolClientExecute(this->client, command, true))), MEM_CONTEXT_OLD());
|
result = strLstMove(strLstNewVarLst(varVarLst(protocolClientExecute(this->client, command, true))), memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -504,9 +506,11 @@ storageRemoteNew(
|
|||||||
protocolClientReadOutput(driver->client, false);
|
protocolClientReadOutput(driver->client, false);
|
||||||
|
|
||||||
// Dup path into parent context
|
// Dup path into parent context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
path = strDup(path);
|
{
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
path = strDup(path);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -382,11 +382,11 @@ storageS3Request(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// On success move the buffer to the calling context
|
// On success move the buffer to the prior context
|
||||||
result.httpClient = httpClient;
|
result.httpClient = httpClient;
|
||||||
result.responseHeader = httpHeaderMove(
|
result.responseHeader = httpHeaderMove(
|
||||||
httpHeaderDup(httpClientResponseHeader(httpClient), NULL), MEM_CONTEXT_OLD());
|
httpHeaderDup(httpClientResponseHeader(httpClient), NULL), memContextPrior());
|
||||||
result.response = bufMove(response, MEM_CONTEXT_OLD());
|
result.response = bufMove(response, memContextPrior());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -514,9 +514,11 @@ storageS3ListInternal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the continuation token and store it in the outer temp context
|
// Get the continuation token and store it in the outer temp context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
|
{
|
||||||
continuationToken = xmlNodeContent(xmlNodeChild(xmlRoot, S3_XML_TAG_NEXT_CONTINUATION_TOKEN_STR, false));
|
continuationToken = xmlNodeContent(xmlNodeChild(xmlRoot, S3_XML_TAG_NEXT_CONTINUATION_TOKEN_STR, false));
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
}
|
}
|
||||||
@ -712,7 +714,7 @@ storageS3List(THIS_VOID, const String *path, StorageInterfaceListParam param)
|
|||||||
result = strLstNew();
|
result = strLstNew();
|
||||||
|
|
||||||
storageS3ListInternal(this, path, param.expression, false, storageS3ListCallback, result);
|
storageS3ListInternal(this, path, param.expression, false, storageS3ListCallback, result);
|
||||||
strLstMove(result, MEM_CONTEXT_OLD());
|
strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ storageGet(StorageRead *file, StorageGetParam param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move buffer to parent context on success
|
// Move buffer to parent context on success
|
||||||
bufMove(result, MEM_CONTEXT_OLD());
|
bufMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -267,12 +267,14 @@ storageInfo(const Storage *this, const String *fileExp, StorageInfoParam param)
|
|||||||
if (!result.exists && !param.ignoreMissing)
|
if (!result.exists && !param.ignoreMissing)
|
||||||
THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_INFO_MISSING, strPtr(file));
|
THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_INFO_MISSING, strPtr(file));
|
||||||
|
|
||||||
// Dup the strings into the calling context
|
// Dup the strings into the prior context
|
||||||
memContextSwitch(MEM_CONTEXT_OLD());
|
MEM_CONTEXT_PRIOR_BEGIN()
|
||||||
result.linkDestination = strDup(result.linkDestination);
|
{
|
||||||
result.user = strDup(result.user);
|
result.linkDestination = strDup(result.linkDestination);
|
||||||
result.group = strDup(result.group);
|
result.user = strDup(result.user);
|
||||||
memContextSwitch(MEM_CONTEXT_TEMP());
|
result.group = strDup(result.group);
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_PRIOR_END();
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -531,7 +533,7 @@ storageList(const Storage *this, const String *pathExp, StorageListParam param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move list up to the old context
|
// Move list up to the old context
|
||||||
result = strLstMove(result, MEM_CONTEXT_OLD());
|
result = strLstMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -602,7 +604,7 @@ storageNewRead(const Storage *this, const String *fileExp, StorageNewReadParam p
|
|||||||
result = storageReadMove(
|
result = storageReadMove(
|
||||||
storageInterfaceNewReadP(
|
storageInterfaceNewReadP(
|
||||||
this->driver, storagePathP(this, fileExp), param.ignoreMissing, .compressible = param.compressible),
|
this->driver, storagePathP(this, fileExp), param.ignoreMissing, .compressible = param.compressible),
|
||||||
MEM_CONTEXT_OLD());
|
memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -643,7 +645,7 @@ storageNewWrite(const Storage *this, const String *fileExp, StorageNewWriteParam
|
|||||||
.modePath = param.modePath != 0 ? param.modePath : this->modePath, .user = param.user, .group = param.group,
|
.modePath = param.modePath != 0 ? param.modePath : this->modePath, .user = param.user, .group = param.group,
|
||||||
.timeModified = param.timeModified, .createPath = !param.noCreatePath, .syncFile = !param.noSyncFile,
|
.timeModified = param.timeModified, .createPath = !param.noCreatePath, .syncFile = !param.noSyncFile,
|
||||||
.syncPath = !param.noSyncPath, .atomic = !param.noAtomic, .compressible = param.compressible),
|
.syncPath = !param.noSyncPath, .atomic = !param.noAtomic, .compressible = param.compressible),
|
||||||
MEM_CONTEXT_OLD());
|
memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ harnessInfoChecksum(const String *info)
|
|||||||
bufCat(result, BUFSTR(jsonFromVar(ioFilterResult(data.checksum))));
|
bufCat(result, BUFSTR(jsonFromVar(ioFilterResult(data.checksum))));
|
||||||
bufCat(result, BUFSTRDEF("\n"));
|
bufCat(result, BUFSTRDEF("\n"));
|
||||||
|
|
||||||
bufMove(result, MEM_CONTEXT_OLD());
|
bufMove(result, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -134,8 +134,8 @@ testRun(void)
|
|||||||
TEST_RESULT_VOID(iniSet(ini, strNew("section1"), strNew("key1"), strNew("11")), "set section, key");
|
TEST_RESULT_VOID(iniSet(ini, strNew("section1"), strNew("key1"), strNew("11")), "set section, key");
|
||||||
TEST_RESULT_VOID(iniSet(ini, strNew("section1"), strNew("key2"), strNew("1.234")), "set section, key");
|
TEST_RESULT_VOID(iniSet(ini, strNew("section1"), strNew("key2"), strNew("1.234")), "set section, key");
|
||||||
|
|
||||||
TEST_RESULT_VOID(iniMove(ini, MEM_CONTEXT_OLD()), "move ini");
|
TEST_RESULT_VOID(iniMove(ini, memContextPrior()), "move ini");
|
||||||
TEST_RESULT_VOID(iniMove(NULL, MEM_CONTEXT_OLD()), "move null ini");
|
TEST_RESULT_VOID(iniMove(NULL, memContextPrior()), "move null ini");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -330,8 +330,8 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
TEST_ASSIGN(header, httpHeaderNew(NULL), "new header");
|
TEST_ASSIGN(header, httpHeaderNew(NULL), "new header");
|
||||||
|
|
||||||
TEST_RESULT_PTR(httpHeaderMove(header, MEM_CONTEXT_OLD()), header, "move to new context");
|
TEST_RESULT_PTR(httpHeaderMove(header, memContextPrior()), header, "move to new context");
|
||||||
TEST_RESULT_PTR(httpHeaderMove(NULL, MEM_CONTEXT_OLD()), NULL, "move null to new context");
|
TEST_RESULT_PTR(httpHeaderMove(NULL, memContextPrior()), NULL, "move null to new context");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -384,8 +384,8 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
TEST_ASSIGN(query, httpQueryNew(), "new query");
|
TEST_ASSIGN(query, httpQueryNew(), "new query");
|
||||||
|
|
||||||
TEST_RESULT_PTR(httpQueryMove(query, MEM_CONTEXT_OLD()), query, "move to new context");
|
TEST_RESULT_PTR(httpQueryMove(query, memContextPrior()), query, "move to new context");
|
||||||
TEST_RESULT_PTR(httpQueryMove(NULL, MEM_CONTEXT_OLD()), NULL, "move null to new context");
|
TEST_RESULT_PTR(httpQueryMove(NULL, memContextPrior()), NULL, "move null to new context");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -383,12 +383,12 @@ testRun(void)
|
|||||||
|
|
||||||
// Null out the mem context in the parent so the move will fail
|
// Null out the mem context in the parent so the move will fail
|
||||||
memContextCurrent()->contextChildList[1] = NULL;
|
memContextCurrent()->contextChildList[1] = NULL;
|
||||||
TEST_ERROR(memContextMove(memContext, MEM_CONTEXT_OLD()), AssertError, "unable to find mem context in old parent");
|
TEST_ERROR(memContextMove(memContext, memContextPrior()), AssertError, "unable to find mem context in old parent");
|
||||||
|
|
||||||
// Set it back so the move will succeed
|
// Set it back so the move will succeed
|
||||||
memContextCurrent()->contextChildList[1] = memContext;
|
memContextCurrent()->contextChildList[1] = memContext;
|
||||||
TEST_RESULT_VOID(memContextMove(memContext, MEM_CONTEXT_OLD()), "move context");
|
TEST_RESULT_VOID(memContextMove(memContext, memContextPrior()), "move context");
|
||||||
TEST_RESULT_VOID(memContextMove(memContext, MEM_CONTEXT_OLD()), "move context again");
|
TEST_RESULT_VOID(memContextMove(memContext, memContextPrior()), "move context again");
|
||||||
|
|
||||||
// Move another context
|
// Move another context
|
||||||
MEM_CONTEXT_NEW_BEGIN("inner2")
|
MEM_CONTEXT_NEW_BEGIN("inner2")
|
||||||
@ -398,7 +398,7 @@ testRun(void)
|
|||||||
}
|
}
|
||||||
MEM_CONTEXT_NEW_END();
|
MEM_CONTEXT_NEW_END();
|
||||||
|
|
||||||
TEST_RESULT_VOID(memContextMove(memContext2, MEM_CONTEXT_OLD()), "move context");
|
TEST_RESULT_VOID(memContextMove(memContext2, memContextPrior()), "move context");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ testRun(void)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
TEST_ASSIGN(testObject, testObjectNew(), "new test object");
|
TEST_ASSIGN(testObject, testObjectNew(), "new test object");
|
||||||
TEST_RESULT_VOID(testObjectMove(testObject, MEM_CONTEXT_OLD()), "move object to parent context");
|
TEST_RESULT_VOID(testObjectMove(testObject, memContextPrior()), "move object to parent context");
|
||||||
TEST_RESULT_VOID(testObjectMove(NULL, MEM_CONTEXT_OLD()), "move null object");
|
TEST_RESULT_VOID(testObjectMove(NULL, memContextPrior()), "move null object");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ testRun(void)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
TEST_ASSIGN(buffer, bufNew(256), "new buffer");
|
TEST_ASSIGN(buffer, bufNew(256), "new buffer");
|
||||||
bufMove(buffer, MEM_CONTEXT_OLD());
|
bufMove(buffer, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ testRun(void)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
TEST_ASSIGN(store, kvNew(), "new store");
|
TEST_ASSIGN(store, kvNew(), "new store");
|
||||||
TEST_RESULT_PTR(kvMove(NULL, MEM_CONTEXT_OLD()), NULL, "move null to old context");
|
TEST_RESULT_PTR(kvMove(NULL, memContextPrior()), NULL, "move null to old context");
|
||||||
TEST_RESULT_PTR(kvMove(store, MEM_CONTEXT_OLD()), store, "move kv to old context");
|
TEST_RESULT_PTR(kvMove(store, memContextPrior()), store, "move kv to old context");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ testRun(void)
|
|||||||
for (int listIdx = 1; listIdx <= LIST_INITIAL_SIZE; listIdx++)
|
for (int listIdx = 1; listIdx <= LIST_INITIAL_SIZE; listIdx++)
|
||||||
TEST_RESULT_VOID(lstAdd(list, &listIdx), "add item %d", listIdx);
|
TEST_RESULT_VOID(lstAdd(list, &listIdx), "add item %d", listIdx);
|
||||||
|
|
||||||
lstMove(list, MEM_CONTEXT_OLD());
|
lstMove(list, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ testRun(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strLstMove(list, MEM_CONTEXT_OLD());
|
strLstMove(list, memContextPrior());
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -411,8 +411,8 @@ testRun(void)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
TEST_ASSIGN(list, varLstNew(), "new list");
|
TEST_ASSIGN(list, varLstNew(), "new list");
|
||||||
TEST_RESULT_PTR(varLstMove(NULL, MEM_CONTEXT_OLD()), NULL, "move null to old context");
|
TEST_RESULT_PTR(varLstMove(NULL, memContextPrior()), NULL, "move null to old context");
|
||||||
TEST_RESULT_PTR(varLstMove(list, MEM_CONTEXT_OLD()), list, "move var list to old context");
|
TEST_RESULT_PTR(varLstMove(list, memContextPrior()), list, "move var list to old context");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -1580,7 +1580,7 @@ testRun(void)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
TEST_ASSIGN(manifest, manifestNewLoad(ioBufferReadNew(contentLoad)), "load manifest");
|
TEST_ASSIGN(manifest, manifestNewLoad(ioBufferReadNew(contentLoad)), "load manifest");
|
||||||
TEST_RESULT_VOID(manifestMove(manifest, MEM_CONTEXT_OLD()), "move manifest");
|
TEST_RESULT_VOID(manifestMove(manifest, memContextPrior()), "move manifest");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ testRun(void)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
TEST_ASSIGN(client, pgClientNew(NULL, 5433, strNew("postg '\\res"), NULL, 3000), "new client");
|
TEST_ASSIGN(client, pgClientNew(NULL, 5433, strNew("postg '\\res"), NULL, 3000), "new client");
|
||||||
TEST_RESULT_VOID(pgClientMove(client, MEM_CONTEXT_OLD()), "move client");
|
TEST_RESULT_VOID(pgClientMove(client, memContextPrior()), "move client");
|
||||||
TEST_RESULT_VOID(pgClientMove(NULL, MEM_CONTEXT_OLD()), "move null client");
|
TEST_RESULT_VOID(pgClientMove(NULL, memContextPrior()), "move null client");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -334,8 +334,8 @@ testRun(void)
|
|||||||
TEST_RESULT_PTR(protocolCommandParamAdd(command, varNewStr(strNew("param1"))), command, "add param");
|
TEST_RESULT_PTR(protocolCommandParamAdd(command, varNewStr(strNew("param1"))), command, "add param");
|
||||||
TEST_RESULT_PTR(protocolCommandParamAdd(command, varNewStr(strNew("param2"))), command, "add param");
|
TEST_RESULT_PTR(protocolCommandParamAdd(command, varNewStr(strNew("param2"))), command, "add param");
|
||||||
|
|
||||||
TEST_RESULT_PTR(protocolCommandMove(command, MEM_CONTEXT_OLD()), command, "move protocol command");
|
TEST_RESULT_PTR(protocolCommandMove(command, memContextPrior()), command, "move protocol command");
|
||||||
TEST_RESULT_PTR(protocolCommandMove(NULL, MEM_CONTEXT_OLD()), NULL, "move null protocol command");
|
TEST_RESULT_PTR(protocolCommandMove(NULL, memContextPrior()), NULL, "move null protocol command");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -465,9 +465,9 @@ testRun(void)
|
|||||||
TEST_ASSIGN(
|
TEST_ASSIGN(
|
||||||
client,
|
client,
|
||||||
protocolClientMove(
|
protocolClientMove(
|
||||||
protocolClientNew(strNew("test client"), strNew("test"), read, write), MEM_CONTEXT_OLD()),
|
protocolClientNew(strNew("test client"), strNew("test"), read, write), memContextPrior()),
|
||||||
"create client");
|
"create client");
|
||||||
TEST_RESULT_VOID(protocolClientMove(NULL, MEM_CONTEXT_OLD()), "move null client");
|
TEST_RESULT_VOID(protocolClientMove(NULL, memContextPrior()), "move null client");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -604,9 +604,9 @@ testRun(void)
|
|||||||
TEST_ASSIGN(
|
TEST_ASSIGN(
|
||||||
server,
|
server,
|
||||||
protocolServerMove(
|
protocolServerMove(
|
||||||
protocolServerNew(strNew("test server"), strNew("test"), read, write), MEM_CONTEXT_OLD()),
|
protocolServerNew(strNew("test server"), strNew("test"), read, write), memContextPrior()),
|
||||||
"create server");
|
"create server");
|
||||||
TEST_RESULT_VOID(protocolServerMove(NULL, MEM_CONTEXT_OLD()), "move null server");
|
TEST_RESULT_VOID(protocolServerMove(NULL, memContextPrior()), "move null server");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -632,8 +632,8 @@ testRun(void)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
TEST_ASSIGN(job, protocolParallelJobNew(varNewStr(strNew("test")), protocolCommandNew(strNew("command"))), "new job");
|
TEST_ASSIGN(job, protocolParallelJobNew(varNewStr(strNew("test")), protocolCommandNew(strNew("command"))), "new job");
|
||||||
TEST_RESULT_PTR(protocolParallelJobMove(job, MEM_CONTEXT_OLD()), job, "move job");
|
TEST_RESULT_PTR(protocolParallelJobMove(job, memContextPrior()), job, "move job");
|
||||||
TEST_RESULT_PTR(protocolParallelJobMove(NULL, MEM_CONTEXT_OLD()), NULL, "move null job");
|
TEST_RESULT_PTR(protocolParallelJobMove(NULL, memContextPrior()), NULL, "move null job");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
@ -864,7 +864,7 @@ testRun(void)
|
|||||||
|
|
||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
TEST_ASSIGN(file, storageReadMove(storageNewReadP(storageTest, fileName), MEM_CONTEXT_OLD()), "new read file");
|
TEST_ASSIGN(file, storageReadMove(storageNewReadP(storageTest, fileName), memContextPrior()), "new read file");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
@ -994,7 +994,7 @@ testRun(void)
|
|||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
TEST_ASSIGN(file, storageWriteMove(storageNewWriteP(storageTest, fileName), MEM_CONTEXT_OLD()), "new write file");
|
TEST_ASSIGN(file, storageWriteMove(storageNewWriteP(storageTest, fileName), memContextPrior()), "new write file");
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user