Blob Blame History Raw
From 8ab7743068cc6cd5bf235d1ccae65de1d91784f0 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Tue, 17 May 2016 12:04:13 +0200
Subject: [PATCH] cmapctl: Handle corosync errors in print_key func

print_key handles only CS_ERR_TRY_AGAIN error. If different error is
returned, print_key loops forewer.

Solution is to handle all errors.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
---
 tools/corosync-cmapctl.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/corosync-cmapctl.c b/tools/corosync-cmapctl.c
index a8da499..d31a73d 100644
--- a/tools/corosync-cmapctl.c
+++ b/tools/corosync-cmapctl.c
@@ -284,15 +284,16 @@ static void print_key(cmap_handle_t handle,
 			break;
 		}
 
-		if (err == CS_OK)
+		if (err == CS_OK) {
 			end_loop = 1;
-
-		if (err == CS_ERR_TRY_AGAIN) {
+		} else if (err == CS_ERR_TRY_AGAIN) {
 			sleep(1);
 			no_retries++;
-		}
 
-		if (no_retries > MAX_TRY_AGAIN) {
+			if (no_retries > MAX_TRY_AGAIN) {
+				end_loop = 1;
+			}
+		} else {
 			end_loop = 1;
 		}
 	};
-- 
1.7.1