cluster: RHEL6 - dlm_controld: always return error if the daemon is not ready to operate

Fabio M. Di Nitto fabbione at fedoraproject.org
Thu May 19 07:38:57 UTC 2011


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=25d93b389fd4d7ae72aa3eae2acd7cb67fd1749c
Commit:        25d93b389fd4d7ae72aa3eae2acd7cb67fd1749c
Parent:        493b100fab97cd9ab746124d460eda069abfc56f
Author:        David Teigland <teigland at redhat.com>
AuthorDate:    Mon Mar 7 19:44:22 2011 +0100
Committer:     Fabio M. Di Nitto <fdinitto at redhat.com>
CommitterDate: Thu May 19 09:38:31 2011 +0200

dlm_controld: always return error if the daemon is not ready to operate

This change allows dlm_tool to effectively poll dlm_controld for readiness.

There is a short window while dlm_controld starts up and configures itself
while it is effectively unable to operate properly.
Applications starting immediatly after dlm_controld, and that don't check
directly for this condition, could fail to start.

By allowing dlm_tool to poll, we can introduced a controlled check
in the cman init script to close to window and avoid any startup race condition.

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

diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index ce88a83..eeab77c 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -19,6 +19,7 @@ static pthread_t query_thread;
 static pthread_mutex_t query_mutex;
 static struct list_head fs_register_list;
 static int kernel_monitor_fd;
+static int daemon_ready;
 
 struct client {
 	int fd;
@@ -587,6 +588,12 @@ static void query_lockspaces(int fd, int max)
 		goto out;
 	}
 
+	/* return error if daemon is not even ready to create lockspaces */
+	if (!daemon_ready) {
+		result = -1;
+		goto out;
+	}
+
 	if (ls_count > max) {
 		result = -E2BIG;
 		ls_count = max;
@@ -995,6 +1002,10 @@ static void loop(void)
 		plock_ci = client_add(rv, process_plocks, NULL);
 	}
 
+	query_lock();
+	daemon_ready = 1;
+	query_unlock();
+
 	for (;;) {
 		rv = poll(pollfd, client_maxi + 1, poll_timeout);
 		if (rv == -1 && errno == EINTR) {


More information about the cluster-commits mailing list