mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-03 14:52:21 +02:00
Add protocolRemoteFree() to shutdown a specific remote.
Sometimes it is useful to shutdown remotes that are no longer needed instead of waiting for them to be shutdown at program exit.
This commit is contained in:
parent
5175d52e94
commit
8766326da8
@ -412,6 +412,33 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostId)
|
|||||||
FUNCTION_LOG_RETURN(PROTOCOL_CLIENT, protocolHelperClient->client);
|
FUNCTION_LOG_RETURN(PROTOCOL_CLIENT, protocolHelperClient->client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**********************************************************************************************************************************/
|
||||||
|
void
|
||||||
|
protocolRemoteFree(unsigned int hostId)
|
||||||
|
{
|
||||||
|
FUNCTION_LOG_BEGIN(logLevelDebug);
|
||||||
|
FUNCTION_LOG_PARAM(UINT, hostId);
|
||||||
|
FUNCTION_LOG_END();
|
||||||
|
|
||||||
|
ASSERT(hostId > 0);
|
||||||
|
|
||||||
|
if (protocolHelper.clientRemote != NULL)
|
||||||
|
{
|
||||||
|
ProtocolHelperClient *protocolHelperClient = &protocolHelper.clientRemote[hostId - 1];
|
||||||
|
|
||||||
|
if (protocolHelperClient->client != NULL)
|
||||||
|
{
|
||||||
|
protocolClientFree(protocolHelperClient->client);
|
||||||
|
execFree(protocolHelperClient->exec);
|
||||||
|
|
||||||
|
protocolHelperClient->client = NULL;
|
||||||
|
protocolHelperClient->exec = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FUNCTION_LOG_RETURN_VOID();
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Send keepalives to all remotes
|
Send keepalives to all remotes
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
@ -482,19 +509,8 @@ protocolFree(void)
|
|||||||
if (protocolHelper.memContext != NULL)
|
if (protocolHelper.memContext != NULL)
|
||||||
{
|
{
|
||||||
// Free remotes
|
// Free remotes
|
||||||
for (unsigned int clientIdx = 0; clientIdx < protocolHelper.clientRemoteSize; clientIdx++)
|
for (unsigned int clientIdx = 0; clientIdx < protocolHelper.clientRemoteSize; clientIdx++)
|
||||||
{
|
protocolRemoteFree(clientIdx + 1);
|
||||||
ProtocolHelperClient *protocolHelperClient = &protocolHelper.clientRemote[clientIdx];
|
|
||||||
|
|
||||||
if (protocolHelperClient->client != NULL)
|
|
||||||
{
|
|
||||||
protocolClientFree(protocolHelperClient->client);
|
|
||||||
execFree(protocolHelperClient->exec);
|
|
||||||
|
|
||||||
protocolHelperClient->client = NULL;
|
|
||||||
protocolHelperClient->exec = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Free locals
|
// Free locals
|
||||||
for (unsigned int clientIdx = 0; clientIdx < protocolHelper.clientLocalSize; clientIdx++)
|
for (unsigned int clientIdx = 0; clientIdx < protocolHelper.clientLocalSize; clientIdx++)
|
||||||
|
@ -30,6 +30,9 @@ void protocolKeepAlive(void);
|
|||||||
ProtocolClient *protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int hostId, unsigned int protocolId);
|
ProtocolClient *protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int hostId, unsigned int protocolId);
|
||||||
ProtocolClient *protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostId);
|
ProtocolClient *protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostId);
|
||||||
|
|
||||||
|
// Free (shutdown) a remote
|
||||||
|
void protocolRemoteFree(unsigned int hostId);
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Getters
|
Getters
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
|
@ -845,6 +845,10 @@ testRun(void)
|
|||||||
// *****************************************************************************************************************************
|
// *****************************************************************************************************************************
|
||||||
if (testBegin("protocolGet()"))
|
if (testBegin("protocolGet()"))
|
||||||
{
|
{
|
||||||
|
// Call remote free before any remotes exist
|
||||||
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
|
TEST_RESULT_VOID(protocolRemoteFree(1), "free remote (non exist)");
|
||||||
|
|
||||||
// Call keep alive before any remotes exist
|
// Call keep alive before any remotes exist
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_RESULT_VOID(protocolKeepAlive(), "keep alive");
|
TEST_RESULT_VOID(protocolKeepAlive(), "keep alive");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user