pgbackrest.git / summary / log / commit / refs
commit 7db8cedd68477dd511bb8bdf8b94b2d2925470dd
Author: David Steele <david@pgmasters.net>
Date: Wed Mar 27 20:59:28 2019 +0000
Add protocolKeepAlive() to send noops to all remotes.
While the local processes are doing their jobs the remote connection from the main process may timeout.
Send occasional noops to ensure that doesn't happen.
doc/xml/release.xml | 4 ++++
src/protocol/helper.c | 20 ++++++++++++++++++++
src/protocol/helper.h | 1 +
test/src/module/protocol/protocolTest.c | 5 +++++
4 files changed, 30 insertions(+)
diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index 032e731e9..16d03f164 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -89,6 +89,10 @@
<p><code>httpClientRequest()</code> accepts a body parameter.</p>
</release-item>
+ <release-item>
+ <p>Add <code>protocolKeepAlive()</code> to send <id>noops</id> to all remotes.</p>
+ </release-item>
+
<release-item>
<p>Make <code>strLstDup()</code> null-tolerant.</p>
</release-item>
diff --git a/src/protocol/helper.c b/src/protocol/helper.c
index 0270c8374..182299f2e 100644
--- a/src/protocol/helper.c
+++ b/src/protocol/helper.c
@@ -327,6 +327,26 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType)
FUNCTION_LOG_RETURN(PROTOCOL_CLIENT, protocolHelperClient->client);
}
+/***********************************************************************************************************************************
+Send keepalives to all remotes
+***********************************************************************************************************************************/
+void
+protocolKeepAlive(void)
+{
+ FUNCTION_LOG_VOID(logLevelTrace);
+
+ if (protocolHelper.memContext != NULL)
+ {
+ for (unsigned int clientIdx = 0; clientIdx < protocolHelper.clientRemoteSize; clientIdx++)
+ {
+ if (protocolHelper.clientRemote[clientIdx].client != NULL)
+ protocolClientNoOp(protocolHelper.clientRemote[clientIdx].client);
+ }
+ }
+
+ FUNCTION_LOG_RETURN_VOID();
+}
+
/***********************************************************************************************************************************
Free the protocol objects and shutdown processes
***********************************************************************************************************************************/
diff --git a/src/protocol/helper.h b/src/protocol/helper.h
index e5686fbca..5023f8492 100644
--- a/src/protocol/helper.h
+++ b/src/protocol/helper.h
@@ -26,6 +26,7 @@ Constants
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
+void protocolKeepAlive(void);
ProtocolClient *protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int protocolId);
ProtocolClient *protocolRemoteGet(ProtocolStorageType protocolStorageType);
diff --git a/test/src/module/protocol/protocolTest.c b/test/src/module/protocol/protocolTest.c
index 73d9cf936..c8405706d 100644
--- a/test/src/module/protocol/protocolTest.c
+++ b/test/src/module/protocol/protocolTest.c
@@ -629,6 +629,10 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("protocolGet()"))
{
+ // Call keep alive before any remotes exist
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_RESULT_VOID(protocolKeepAlive(), "keep alive");
+
// Simple protocol start
// -------------------------------------------------------------------------------------------------------------------------
StringList *argList = strLstNew();
@@ -647,6 +651,7 @@ testRun(void)
TEST_ASSIGN(client, protocolRemoteGet(protocolStorageTypeRepo), "get remote protocol");
TEST_RESULT_PTR(protocolRemoteGet(protocolStorageTypeRepo), client, "get remote cached protocol");
TEST_RESULT_PTR(protocolHelper.clientRemote[0].client, client, "check position in cache");
+ TEST_RESULT_VOID(protocolKeepAlive(), "keep alive");
TEST_RESULT_VOID(protocolFree(), "free remote protocol objects");
TEST_RESULT_VOID(protocolFree(), "free remote protocol objects again");
[parent: f8cbf5d78cba]