dlm: master - dlm_controld: retry connection to corosync if we get a EAGAIN

David Teigland teigland at fedoraproject.org
Tue May 15 15:11:38 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=cef3fc9b1c8096a18d61166abb9e5e0eb2fdc1d7
Commit:        cef3fc9b1c8096a18d61166abb9e5e0eb2fdc1d7
Parent:        bc586574bd252be678506cde92629c86b8f17fa8
Author:        Fabio M. Di Nitto <fdinitto at redhat.com>
AuthorDate:    Tue May 15 09:11:34 2012 +0200
Committer:     Fabio M. Di Nitto <fdinitto at redhat.com>
CommitterDate: Tue May 15 09:11:34 2012 +0200

dlm_controld: retry connection to corosync if we get a EAGAIN

this change is necessary only at the first api_initialize call to corosync.

corosync 2.0 returns
- CS_ERR_LIBRARY (2) when corosync is not running
- CS_ERR_TRY_AGAIN (6) when corosync has started but it's not ready
                       to provide services yet (IPC will refuse connections)
- CS_OK once it's ready or other errors for failures.

Resolves: rhbz#816200

Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
---
 dlm_controld/member.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/dlm_controld/member.c b/dlm_controld/member.c
index ecdfabc..d195ab1 100644
--- a/dlm_controld/member.c
+++ b/dlm_controld/member.c
@@ -11,6 +11,7 @@
 #include <corosync/cfg.h>
 #include <corosync/cmap.h>
 #include <corosync/quorum.h>
+#include <errno.h>
 
 static corosync_cfg_handle_t	ch;
 static quorum_handle_t		qh;
@@ -295,9 +296,17 @@ int setup_cluster_cfg(void)
 	cs_error_t err;
 	unsigned int nodeid;
 	int fd;
+	int retry = 1;
 
+try_again:
 	err = corosync_cfg_initialize(&ch, &cfg_callbacks);
 	if (err != CS_OK) {
+		if ((err == CS_ERR_TRY_AGAIN) && (retry <= 10)) {
+			log_error("corosync has not completed initialization.. retry %d", retry);
+			sleep(1);
+			retry++;
+			goto try_again;
+		}
 		log_error("corosync cfg init error %d", err);
 		return -1;
 	}


More information about the cluster-commits mailing list