You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-17 01:12:23 +02:00
Migrate remote command to C.
Prior to this the Perl remote was used to satisfy C requests. This worked fine but since the remote needed to be migrated to C anyway there was no reason to wait. Add the ProtocolServer object and tweak ProtocolClient to work with it. It was also necessary to add a mechanism to get option values from the remote so that encryption settings could be read and used in the storage object. Update the remote storage objects to comply with the protocol changes and add the storage protocol handler. Ideally this commit would have been broken up into smaller chunks but there are cross-dependencies in the protocol layer and it didn't seem worth the extra effort.
This commit is contained in:
@ -120,7 +120,7 @@ protocolClientNew(const String *name, const String *service, IoRead *read, IoWri
|
||||
/***********************************************************************************************************************************
|
||||
Read the command output
|
||||
***********************************************************************************************************************************/
|
||||
const VariantList *
|
||||
const Variant *
|
||||
protocolClientReadOutput(ProtocolClient *this, bool outputRequired)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
@ -130,7 +130,7 @@ protocolClientReadOutput(ProtocolClient *this, bool outputRequired)
|
||||
|
||||
ASSERT(this != NULL);
|
||||
|
||||
const VariantList *result = NULL;
|
||||
const Variant *result = NULL;
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
@ -151,19 +151,15 @@ protocolClientReadOutput(ProtocolClient *this, bool outputRequired)
|
||||
}
|
||||
|
||||
// Get output
|
||||
const Variant *output = kvGet(responseKv, varNewStr(PROTOCOL_OUTPUT_STR));
|
||||
|
||||
ASSERT(output != NULL);
|
||||
ASSERT(varType(output) == varTypeVariantList);
|
||||
result = kvGet(responseKv, varNewStr(PROTOCOL_OUTPUT_STR));
|
||||
|
||||
if (outputRequired)
|
||||
{
|
||||
// Just move the entire response kv since the output is the largest part if it
|
||||
kvMove(responseKv, MEM_CONTEXT_OLD());
|
||||
result = varVarLst(output);
|
||||
}
|
||||
// Else if no output is required then there should not be any
|
||||
else if (varLstSize(varVarLst(output)) != 0)
|
||||
else if (result != NULL)
|
||||
THROW(AssertError, "no output required by command");
|
||||
|
||||
// Reset the keep alive time
|
||||
@ -171,7 +167,7 @@ protocolClientReadOutput(ProtocolClient *this, bool outputRequired)
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_LOG_RETURN_CONST(VARIANT_LIST, result);
|
||||
FUNCTION_LOG_RETURN_CONST(VARIANT, result);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -201,7 +197,7 @@ protocolClientWriteCommand(ProtocolClient *this, const KeyValue *command)
|
||||
/***********************************************************************************************************************************
|
||||
Execute a protocol command and get the output
|
||||
***********************************************************************************************************************************/
|
||||
const VariantList *
|
||||
const Variant *
|
||||
protocolClientExecute(ProtocolClient *this, const KeyValue *command, bool outputRequired)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
@ -215,7 +211,7 @@ protocolClientExecute(ProtocolClient *this, const KeyValue *command, bool output
|
||||
|
||||
protocolClientWriteCommand(this, command);
|
||||
|
||||
FUNCTION_LOG_RETURN_CONST(VARIANT_LIST, protocolClientReadOutput(this, outputRequired));
|
||||
FUNCTION_LOG_RETURN_CONST(VARIANT, protocolClientReadOutput(this, outputRequired));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
Reference in New Issue
Block a user