You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
Add MEM_CONTEXT_OBJ_*() macros.
These provide a standard way to switch to an object mem context. Update the two different patterns that were used before to the new macros.
This commit is contained in:
@ -299,7 +299,7 @@ cipherBlockProcess(THIS_VOID, const Buffer *source, Buffer *destination)
|
||||
if (destinationSize > bufRemains(destination))
|
||||
{
|
||||
// Allocate the buffer if needed
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
if (this->buffer == NULL)
|
||||
{
|
||||
@ -309,7 +309,7 @@ cipherBlockProcess(THIS_VOID, const Buffer *source, Buffer *destination)
|
||||
else
|
||||
bufResize(this->buffer, destinationSize);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
outputActual = this->buffer;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ cryptoHash(CryptoHash *this)
|
||||
|
||||
if (this->hash == NULL)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
// Standard OpenSSL implementation
|
||||
if (this->hashContext != NULL)
|
||||
@ -133,7 +133,7 @@ cryptoHash(CryptoHash *this)
|
||||
|
||||
bufUsedSet(this->hash, bufSize(this->hash));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
|
||||
FUNCTION_LOG_RETURN(BUFFER, this->hash);
|
||||
|
@ -206,7 +206,7 @@ iniParse(Ini *this, const String *content)
|
||||
|
||||
ASSERT(this != NULL);
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
kvFree(this->store);
|
||||
this->store = kvNew();
|
||||
@ -267,7 +267,7 @@ iniParse(Ini *this, const String *content)
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ ioFilterGroupOpen(IoFilterGroup *this)
|
||||
|
||||
ASSERT(this != NULL);
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
// If the last filter is not an output filter then add a filter to buffer/copy data. Input filters won't copy to an output
|
||||
// buffer so we need some way to get the data to the output buffer.
|
||||
@ -217,7 +217,7 @@ ioFilterGroupOpen(IoFilterGroup *this)
|
||||
}
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
// Filter group is open
|
||||
#ifdef DEBUG
|
||||
|
@ -268,11 +268,11 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
|
||||
this->pub.code = cvtZToUInt(strZ(strSubN(status, 0, (size_t)spacePos)));
|
||||
|
||||
// Read reason phrase. A missing reason phrase will be represented as an empty string.
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->pub.reason = strSub(status, (size_t)spacePos + 1);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
// Read headers
|
||||
do
|
||||
@ -339,12 +339,12 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
|
||||
|
||||
// Create an io object, even if there is no content. This makes the logic for readers easier -- they can just check eof
|
||||
// rather than also checking if the io object exists.
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->pub.contentRead = ioReadNewP(this, .eof = httpResponseEof, .read = httpResponseRead);
|
||||
ioReadOpen(httpResponseIoRead(this));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
// If there is no content then we are done with the client
|
||||
if (!this->contentExists)
|
||||
@ -354,11 +354,11 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
|
||||
// Else cache content when requested or on error
|
||||
else if (contentCache || !httpResponseCodeOk(this))
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
httpResponseContent(this);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
@ -247,11 +247,11 @@ bufResize(Buffer *this, size_t size)
|
||||
// When setting size down to 0 the buffer should always be allocated
|
||||
ASSERT(bufPtrConst(this) != NULL);
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
memFree(bufPtr(this));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
this->pub.buffer = NULL;
|
||||
this->pub.sizeAlloc = 0;
|
||||
@ -259,14 +259,14 @@ bufResize(Buffer *this, size_t size)
|
||||
// Else allocate or resize
|
||||
else
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
if (bufPtrConst(this) == NULL)
|
||||
this->pub.buffer = memNew(size);
|
||||
else
|
||||
this->pub.buffer = memResize(bufPtr(this), size);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
this->pub.sizeAlloc = size;
|
||||
}
|
||||
|
@ -277,11 +277,11 @@ jsonReadPush(JsonRead *const this, const JsonType type, const bool key)
|
||||
// Create the container stack
|
||||
else
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->stack = lstNewP(sizeof(JsonReadStack));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1350,11 +1350,11 @@ jsonWritePush(JsonWrite *const this, const JsonType type, const String *const ke
|
||||
// Create the container stack
|
||||
else
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->stack = lstNewP(sizeof(JsonWriteStack));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,11 +177,11 @@ kvPut(KeyValue *this, const Variant *key, const Variant *value)
|
||||
ASSERT(this != NULL);
|
||||
ASSERT(key != NULL);
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
kvPutInternal(this, key, varDup(value));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(KEY_VALUE, this);
|
||||
}
|
||||
@ -199,7 +199,7 @@ kvAdd(KeyValue *this, const Variant *key, const Variant *value)
|
||||
ASSERT(this != NULL);
|
||||
ASSERT(key != NULL);
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
// Find the key
|
||||
unsigned int listIdx = kvGetIdx(this, key);
|
||||
@ -227,7 +227,7 @@ kvAdd(KeyValue *this, const Variant *key, const Variant *value)
|
||||
varLstAdd(varVarLst(pair->value), varDup(value));
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(KEY_VALUE, this);
|
||||
}
|
||||
@ -246,12 +246,12 @@ kvPutKv(KeyValue *this, const Variant *key)
|
||||
|
||||
KeyValue *result = NULL;
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
result = kvNew();
|
||||
kvPutInternal(this, key, varNewKv(result));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(KEY_VALUE, result);
|
||||
}
|
||||
|
@ -79,6 +79,12 @@ thisNotNull(const void *const this)
|
||||
return this;
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Switch to the object memory context and ensure that the prior memory context is restored after the block executes (even on error)
|
||||
***********************************************************************************************************************************/
|
||||
#define MEM_CONTEXT_OBJ_BEGIN(this) MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
#define MEM_CONTEXT_OBJ_END() MEM_CONTEXT_END()
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
|
||||
|
@ -363,13 +363,13 @@ pckReadNewIo(IoRead *read)
|
||||
|
||||
PackRead *this = pckReadNewInternal();
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->read = read;
|
||||
this->buffer = bufNew(ioBufferSize());
|
||||
this->bufferPtr = bufPtr(this->buffer);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(PACK_READ, this);
|
||||
}
|
||||
@ -1316,11 +1316,11 @@ pckWriteNew(const PckWriteNewParam param)
|
||||
|
||||
PackWrite *this = pckWriteNewInternal();
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->buffer = bufNew(param.size == 0 ? PACK_EXTRA_MIN : param.size);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(PACK_WRITE, this);
|
||||
}
|
||||
@ -1336,12 +1336,12 @@ pckWriteNewIo(IoWrite *write)
|
||||
|
||||
PackWrite *this = pckWriteNewInternal();
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->write = write;
|
||||
this->buffer = bufNew(ioBufferSize());
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(PACK_WRITE, this);
|
||||
}
|
||||
|
@ -91,11 +91,11 @@ protocolCommandParam(ProtocolCommand *this)
|
||||
|
||||
if (this->pack == NULL)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->pack = protocolPackNew();
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
|
||||
FUNCTION_TEST_RETURN(PACK_WRITE, this->pack);
|
||||
|
@ -105,11 +105,11 @@ protocolParallelProcess(ProtocolParallel *this)
|
||||
// If called for the first time, initialize processing
|
||||
if (this->state == protocolParallelJobStatePending)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->clientJobList = memNewPtrArray(lstSize(this->clientList));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
this->state = protocolParallelJobStateRunning;
|
||||
}
|
||||
|
@ -61,12 +61,12 @@ protocolParallelJobErrorSet(ProtocolParallelJob *this, int code, const String *m
|
||||
ASSERT(code != 0);
|
||||
ASSERT(message != NULL);
|
||||
|
||||
MEM_CONTEXT_BEGIN(objMemContext(this))
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->pub.code = code;
|
||||
this->pub.message = strDup(message);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ storageReadAzureOpen(THIS_VOID)
|
||||
bool result = false;
|
||||
|
||||
// Request the file
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->httpResponse = storageAzureRequestP(
|
||||
this->storage, HTTP_VERB_GET_STR, .path = this->interface.name,
|
||||
.header = httpHeaderPutRange(httpHeaderNew(NULL), this->interface.offset, this->interface.limit),
|
||||
.allowMissing = true, .contentIo = true);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
if (httpResponseCodeOk(this->httpResponse))
|
||||
{
|
||||
|
@ -71,11 +71,11 @@ storageWriteAzureOpen(THIS_VOID)
|
||||
ASSERT(this->blockBuffer == NULL);
|
||||
|
||||
// Allocate the block buffer
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->blockBuffer = bufNew(this->blockSize);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
@ -123,11 +123,11 @@ storageWriteAzureBlockAsync(StorageWriteAzure *this)
|
||||
// Create the block id list
|
||||
if (this->blockIdList == NULL)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->blockIdList = strLstNew();
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
|
||||
// Generate block id. Combine the block number with the provided file id to create a (hopefully) unique block id that won't
|
||||
@ -141,12 +141,12 @@ storageWriteAzureBlockAsync(StorageWriteAzure *this)
|
||||
httpQueryAdd(query, AZURE_QUERY_COMP_STR, AZURE_QUERY_VALUE_BLOCK_STR);
|
||||
httpQueryAdd(query, AZURE_QUERY_BLOCK_ID_STR, blockId);
|
||||
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->request = storageAzureRequestAsyncP(
|
||||
this->storage, HTTP_VERB_PUT_STR, .path = this->interface.name, .query = query, .content = this->blockBuffer);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
strLstAdd(this->blockIdList, blockId);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ storageReadGcsOpen(THIS_VOID)
|
||||
bool result = false;
|
||||
|
||||
// Request the file
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->httpResponse = storageGcsRequestP(
|
||||
this->storage, HTTP_VERB_GET_STR, .object = this->interface.name,
|
||||
@ -61,7 +61,7 @@ storageReadGcsOpen(THIS_VOID)
|
||||
.allowMissing = true, .contentIo = true,
|
||||
.query = httpQueryAdd(httpQueryNewP(), GCS_QUERY_ALT_STR, GCS_QUERY_MEDIA_STR));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
if (httpResponseCodeOk(this->httpResponse))
|
||||
{
|
||||
|
@ -334,7 +334,7 @@ storageGcsAuth(StorageGcs *this, HttpHeader *httpHeader)
|
||||
StorageGcsAuthTokenResult tokenResult = this->keyType == storageGcsKeyTypeAuto ?
|
||||
storageGcsAuthAuto(this, timeBegin) : storageGcsAuthService(this, timeBegin);
|
||||
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
strFree(this->token);
|
||||
this->token = strNewFmt("%s %s", strZ(tokenResult.tokenType), strZ(tokenResult.token));
|
||||
@ -343,7 +343,7 @@ storageGcsAuth(StorageGcs *this, HttpHeader *httpHeader)
|
||||
this->tokenTimeExpire =
|
||||
tokenResult.timeExpire - ((time_t)(httpClientTimeout(this->httpClient) / MSEC_PER_SEC * 2));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,12 +60,12 @@ storageWriteGcsOpen(THIS_VOID)
|
||||
ASSERT(this->chunkBuffer == NULL);
|
||||
|
||||
// Allocate the chunk buffer
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->chunkBuffer = bufNew(this->chunkSize);
|
||||
this->md5hash = cryptoHashNew(HASH_TYPE_MD5_STR);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
@ -172,12 +172,12 @@ storageWriteGcsBlockAsync(StorageWriteGcs *this, bool done)
|
||||
{
|
||||
HttpResponse *response = storageGcsRequestP(this->storage, HTTP_VERB_POST_STR, .upload = true, .query = query);
|
||||
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->uploadId = strDup(httpHeaderGet(httpResponseHeader(response), GCS_HEADER_UPLOAD_ID_STR));
|
||||
CHECK(FormatError, this->uploadId != NULL, "upload id missing");
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
|
||||
// Add data to md5 hash
|
||||
@ -198,13 +198,13 @@ storageWriteGcsBlockAsync(StorageWriteGcs *this, bool done)
|
||||
if (done)
|
||||
httpQueryAdd(query, GCS_QUERY_FIELDS_STR, GCS_QUERY_FIELDS_VALUE_STR);
|
||||
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->request = storageGcsRequestAsyncP(
|
||||
this->storage, HTTP_VERB_PUT_STR, .upload = true, .noAuth = true, .header = header, .query = query,
|
||||
.content = this->chunkBuffer);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
this->uploadTotal += bufUsed(this->chunkBuffer);
|
||||
}
|
||||
|
@ -140,12 +140,12 @@ storageReadRemote(THIS_VOID, Buffer *buffer, bool block)
|
||||
// If binary then read the next block
|
||||
if (pckReadType(read) == pckTypeBin)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->block = pckReadBinP(read);
|
||||
this->remaining = bufUsed(this->block);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
// Else read is complete and get the filter list
|
||||
else
|
||||
|
@ -50,14 +50,14 @@ storageReadS3Open(THIS_VOID)
|
||||
bool result = false;
|
||||
|
||||
// Request the file
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->httpResponse = storageS3RequestP(
|
||||
this->storage, HTTP_VERB_GET_STR, this->interface.name,
|
||||
.header = httpHeaderPutRange(httpHeaderNew(NULL), this->interface.offset, this->interface.limit),
|
||||
.allowMissing = true, .contentIo = true);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
if (httpResponseCodeOk(this->httpResponse))
|
||||
{
|
||||
|
@ -215,12 +215,12 @@ storageS3Auth(
|
||||
const Buffer *serviceKey = cryptoHmacOne(HASH_TYPE_SHA256_STR, regionKey, S3_BUF);
|
||||
|
||||
// Switch to the object context so signing key and date are not lost
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->signingKey = cryptoHmacOne(HASH_TYPE_SHA256_STR, serviceKey, AWS4_REQUEST_BUF);
|
||||
this->signingKeyDate = strDup(date);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
|
||||
// Generate authorization header
|
||||
@ -320,11 +320,11 @@ storageS3AuthAuto(StorageS3 *const this, HttpHeader *const header)
|
||||
httpRequestError(request, response);
|
||||
|
||||
// Get role from the text response
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->credRole = strNewBuf(httpResponseContent(response));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
|
||||
// Retrieve the temp credentials
|
||||
@ -348,7 +348,7 @@ storageS3AuthAuto(StorageS3 *const this, HttpHeader *const header)
|
||||
// Get credentials from the JSON response
|
||||
KeyValue *credential = varKv(jsonToVar(strNewBuf(httpResponseContent(response))));
|
||||
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
// Check the code field for errors
|
||||
const Variant *code = kvGetDefault(credential, S3_JSON_TAG_CODE_VAR, VARSTRDEF("code field is missing"));
|
||||
@ -367,7 +367,7 @@ storageS3AuthAuto(StorageS3 *const this, HttpHeader *const header)
|
||||
this->secretAccessKey = strDup(varStr(kvGet(credential, S3_JSON_TAG_SECRET_ACCESS_KEY_VAR)));
|
||||
this->securityToken = strDup(varStr(kvGet(credential, S3_JSON_TAG_TOKEN_VAR)));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
// Update expiration time
|
||||
CHECK(FormatError, kvGet(credential, S3_JSON_TAG_EXPIRATION_VAR) != NULL, "expiration missing");
|
||||
@ -417,13 +417,13 @@ storageS3AuthWebId(StorageS3 *const this, const HttpHeader *const header)
|
||||
const XmlNode *const secretAccessKeyNode = xmlNodeChild(xmlCred, STRDEF("SecretAccessKey"), true);
|
||||
const XmlNode *const securityTokenNode = xmlNodeChild(xmlCred, STRDEF("SessionToken"), true);
|
||||
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->accessKey = xmlNodeContent(accessKeyNode);
|
||||
this->secretAccessKey = xmlNodeContent(secretAccessKeyNode);
|
||||
this->securityToken = xmlNodeContent(securityTokenNode);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
// Update expiration time
|
||||
this->credExpirationTime = storageS3CvtTime(xmlNodeContent(xmlNodeChild(xmlCred, STRDEF("Expiration"), true)));
|
||||
|
@ -65,11 +65,11 @@ storageWriteS3Open(THIS_VOID)
|
||||
ASSERT(this->partBuffer == NULL);
|
||||
|
||||
// Allocate the part buffer
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->partBuffer = bufNew(this->partSize);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
@ -128,12 +128,12 @@ storageWriteS3PartAsync(StorageWriteS3 *this)
|
||||
.query = httpQueryAdd(httpQueryNewP(), S3_QUERY_UPLOADS_STR, EMPTY_STR), .sseKms = true))));
|
||||
|
||||
// Store the upload id
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->uploadId = xmlNodeContent(xmlNodeChild(xmlRoot, S3_XML_TAG_UPLOAD_ID_STR, true));
|
||||
this->uploadPartList = strLstNew();
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
|
||||
// Upload the part async
|
||||
@ -141,12 +141,12 @@ storageWriteS3PartAsync(StorageWriteS3 *this)
|
||||
httpQueryAdd(query, S3_QUERY_UPLOAD_ID_STR, this->uploadId);
|
||||
httpQueryAdd(query, S3_QUERY_PART_NUMBER_STR, strNewFmt("%u", strLstSize(this->uploadPartList) + 1));
|
||||
|
||||
MEM_CONTEXT_BEGIN(THIS_MEM_CONTEXT())
|
||||
MEM_CONTEXT_OBJ_BEGIN(this)
|
||||
{
|
||||
this->request = storageS3RequestAsyncP(
|
||||
this->storage, HTTP_VERB_PUT_STR, this->interface.name, .query = query, .content = this->partBuffer);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
MEM_CONTEXT_OBJ_END();
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
|
Reference in New Issue
Block a user