LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File dlm_controld_always_return_error_if_daemon_is_not_ready_to_operate.patch of Package cluster (Project home:sschapiro:openstack:upstream)

commit 6b4c33ff0487fc7dc6410796d9eb967129467b81
Author: David Teigland <teigland@redhat.com>
Date:   Mon Mar 7 19:44:22 2011 +0100

    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@redhat.com>

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) {