[pve-devel] [PATCH cluster 1/3] ipcc_send_rec: retry once if cached connection failed

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Dec 20 12:00:37 CET 2017


A restart of pmxcfs invalidates the connection cache, we only set the
cached connection to NULL for this case and the next call to
ipcc_send_rec would connect newly.

Instead, retry directly one single time in this case.
If this try fails we return undef anyway and for the case where it
succeeds but the request to the pmxcfs server fails for other reason
stop retrying as here it won't change the problem and would probably
end in an endless loop.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 data/PVE/IPCC.xs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/data/PVE/IPCC.xs b/data/PVE/IPCC.xs
index ded9472..994ff7b 100644
--- a/data/PVE/IPCC.xs
+++ b/data/PVE/IPCC.xs
@@ -32,6 +32,8 @@
 #define PCS_SERVICE1 1
 #define MAX_MSG_SIZE (8192*128)
 
+static int retried_connection;
+
 static qb_ipcc_connection_t *conn;
 static pid_t conn_pid;
 
@@ -56,6 +58,7 @@ CODE:
 	}
 
 	if (conn == NULL) {
+retry_connection:
 		qb_log_init("IPCC.xs", LOG_USER, LOG_EMERG);
 		qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_TRUE);
 		conn = qb_ipcc_connect(PCS_SOCKET_NAME, MAX_MSG_SIZE);
@@ -89,9 +92,15 @@ CODE:
 	if (res < 0) {
 		qb_ipcc_disconnect(conn);
 		conn = NULL;
+		// the first request after restart will always fail, retry once
+		if (!retried_connection) {
+			retried_connection = 1;
+			goto retry_connection;
+		}
 		errno = -res;
 		XSRETURN_UNDEF;
 	}
+	retried_connection = 0;
 
 	struct qb_ipc_response_header *res_header;
 
-- 
2.11.0





More information about the pve-devel mailing list