[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH] Fix misuse of cman FD in fenced



This patch fixes a caching of the cman file descriptor in fenced, which the header file explicitly says you should not do.

I have seen symptoms that are consistent with this going wrong and while I can't prove that this is the cause it looks highly likely.

The patch is against the RHEL5 branch, but the bug also exists in RHEL6 and upstream versions

There also is a chance that this mistake exists in other cluster daemons, I haven't checked as yet.
diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h
index c4204c8..584367c 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -197,5 +197,6 @@ int is_member(char *name);
 int is_fenced(char *name);
 fd_node_t *get_new_node(fd_t *fd, int nodeid, char *in_name);
 void update_cman(char *victim, char *agent);
+int get_member_fd(void);
 
 #endif				/*  __FD_DOT_H__  */
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index 3d553b2..72961f5 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -531,6 +531,7 @@ static int setup_listen(void)
 static int loop(void)
 {
 	int rv, i, f, maxi = 0, listen_fd, member_fd, groupd_fd;
+	int cluster_fd_pos;
 
 	rv = listen_fd = setup_listen();
 	if (rv < 0)
@@ -540,7 +541,7 @@ static int loop(void)
 	rv = member_fd = setup_member();
 	if (rv < 0)
 		goto out;
-	client_add(member_fd, &maxi);
+	cluster_fd_pos = client_add(member_fd, &maxi);
 
 	rv = groupd_fd = setup_groupd();
 	if (rv < 0)
@@ -551,6 +552,8 @@ static int loop(void)
 		  listen_fd, member_fd, groupd_fd);
 
 	for (;;) {
+                /* We need to re-get the cluster FD eac time */
+		pollfd[cluster_fd_pos].fd = get_member_fd();
 		rv = poll(pollfd, maxi + 1, -1);
 		if (rv < 0) {
 			if (errno == EINTR)
diff --git a/fence/fenced/member_cman.c b/fence/fenced/member_cman.c
index 6ef74c3..8086af4 100644
--- a/fence/fenced/member_cman.c
+++ b/fence/fenced/member_cman.c
@@ -241,6 +241,11 @@ void exit_member(void)
 	cman_finish(ch);
 }
 
+int get_member_fd()
+{
+	return cman_get_fd(ch);
+}
+
 int is_member(char *name)
 {
 	cman_node_t *cn;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]