Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: cabcd8334dff93f4a520eefda7b15cb26b495285
Parent: 7d2b388cfe9cdc7e0eac65218788527a3969fe8c
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Mar 7 19:44:22 2011 +0100
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: 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(a)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 b3be2fc..1766537 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) {