This is the mail archive of the
cluster-cvs@sourceware.org
mailing list for the cluster.
cluster: STABLE3 - groupd: cpg_finalize
- From: David Teigland <teigland at fedoraproject dot org>
- To: cluster-cvs-relay at redhat dot com
- Date: Fri, 27 Feb 2009 18:48:36 +0000 (UTC)
- Subject: cluster: STABLE3 - groupd: cpg_finalize
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=5e5e9381f9a10ecc3a5f62eabf9cb4baac6b11d4
Commit: 5e5e9381f9a10ecc3a5f62eabf9cb4baac6b11d4
Parent: 4ca347ec2e9ecb3e418876e60e6db834aa0be668
Author: David Teigland <teigland@redhat.com>
AuthorDate: Fri Feb 27 12:45:36 2009 -0600
Committer: David Teigland <teigland@redhat.com>
CommitterDate: Fri Feb 27 12:45:36 2009 -0600
groupd: cpg_finalize
Call cpg_finalize on all our cpg handles when shutting down.
Signed-off-by: David Teigland <teigland@redhat.com>
---
group/daemon/cpg.c | 28 ++++++++++++++++++++++++++++
group/daemon/gd_internal.h | 2 ++
group/daemon/main.c | 6 +++++-
3 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/group/daemon/cpg.c b/group/daemon/cpg.c
index 8c28ce4..43c8ddd 100644
--- a/group/daemon/cpg.c
+++ b/group/daemon/cpg.c
@@ -898,6 +898,34 @@ int setup_cpg(void)
return 0;
}
+void close_cpg(void)
+{
+ group_t *g;
+ cpg_error_t error;
+ int i = 0;
+
+ if (!groupd_handle)
+ return;
+ if (cluster_down)
+ goto fin;
+ retry:
+ error = cpg_leave(groupd_handle, &groupd_name);
+ if (error == CPG_ERR_TRY_AGAIN) {
+ sleep(1);
+ if (!(++i % 10))
+ log_print("daemon cpg_leave error retrying");
+ goto retry;
+ }
+ if (error != CPG_OK)
+ log_print("daemon cpg_leave error %d", error);
+ fin:
+ list_for_each_entry(g, &gd_groups, list) {
+ if (g->cpg_handle)
+ cpg_finalize(g->cpg_handle);
+ }
+ cpg_finalize(groupd_handle);
+}
+
int do_cpg_join(group_t *g)
{
cpg_error_t error;
diff --git a/group/daemon/gd_internal.h b/group/daemon/gd_internal.h
index 1927104..7866ba2 100644
--- a/group/daemon/gd_internal.h
+++ b/group/daemon/gd_internal.h
@@ -36,6 +36,7 @@
extern int daemon_debug_opt;
extern int daemon_debug_verbose;
extern int daemon_quit;
+extern int cluster_down;
extern int cman_quorate;
extern int our_nodeid;
extern char *our_name;
@@ -296,6 +297,7 @@ int kill_cman(int nodeid);
/* cpg.c */
int setup_cpg(void);
+void close_cpg(void);
int do_cpg_join(group_t *g);
int do_cpg_leave(group_t *g);
int send_message(group_t *g, void *buf, int len);
diff --git a/group/daemon/main.c b/group/daemon/main.c
index 5b07505..b98b02a 100644
--- a/group/daemon/main.c
+++ b/group/daemon/main.c
@@ -734,8 +734,10 @@ static int setup_listener(char *sock_path)
void cluster_dead(int ci)
{
- log_print("cluster is down, exiting");
+ if (!cluster_down)
+ log_print("cluster is down, exiting");
daemon_quit = 1;
+ cluster_down = 1;
}
#define min(x, y) ({ \
@@ -828,6 +830,7 @@ static void loop(void)
}
}
out:
+ close_cpg();
close_ccs();
close_cman();
@@ -1058,6 +1061,7 @@ void daemon_dump_save(void)
int daemon_debug_opt;
int daemon_debug_verbose;
int daemon_quit;
+int cluster_down;
int cman_quorate;
int our_nodeid;
char *our_name;