This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: RHEL5 - rgmanager: randomize state dump file name


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=5bf3964b3bebc418bbe970c55aabcfc7e5e57dba
Commit:        5bf3964b3bebc418bbe970c55aabcfc7e5e57dba
Parent:        210681e5612703a5b9f3e578db31e234cf58cb6d
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Thu May 21 09:59:17 2009 -0400
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Thu May 21 10:27:58 2009 -0400

rgmanager: randomize state dump file name

---
 rgmanager/src/daemons/main.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c
index e23f8ef..94de2d3 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -694,10 +694,11 @@ void dump_vf_states(FILE *fp);
 void dump_cluster_ctx(FILE *fp);
 
 void
-dump_internal_state(char *loc)
+dump_internal_state(int fd)
 {
 	FILE *fp;
-	fp=fopen(loc, "w+");
+
+	fp=fdopen(fd, "w+");
  	dump_config_version(fp);
  	dump_threads(fp);
  	dump_vf_states(fp);
@@ -716,14 +717,20 @@ event_loop(msgctx_t *localctx, msgctx_t *clusterctx)
 	msgctx_t *newctx;
 	struct timeval tv;
 	int nodeid;
+	char template[128] = "/tmp/rgmanager-dump.XXXXXX";
+	int temp_fd = -1;
 
 	tv.tv_sec = status_poll_interval;
 	tv.tv_usec = 0;
 
 	if (signalled) {
 		signalled = 0;
- 
-		dump_internal_state("/tmp/rgmanager-dump");
+
+		temp_fd = mkstemp(template);
+		if (temp_fd >= 0) {
+			dump_internal_state(temp_fd);
+			close(temp_fd);
+		}
 	}
 
 	while (running && (tv.tv_sec || tv.tv_usec)) {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]