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: master - qdiskd: Always use O_NONBLOCK when writing tostatus_file


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=333e9450cf50db94688ce7cc81153abff767afca
Commit:        333e9450cf50db94688ce7cc81153abff767afca
Parent:        817c11a83609033cb1d72f2bd39c28dc1d1c7a6d
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Mon Nov 17 15:03:21 2008 -0500
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Wed Nov 19 14:07:35 2008 -0500

qdiskd: Always use O_NONBLOCK when writing to status_file

---
 cman/qdisk/main.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index 4dbe511..158c442 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -649,6 +649,8 @@ update_local_status(qd_ctx *ctx, node_info_t *ni, int max, int score,
 	FILE *fp;
 	int x, need_close = 0;
 	time_t now;
+	long flags;
+	int fd;
 
 	if (!ctx->qc_status_file)
 		return;
@@ -662,6 +664,17 @@ update_local_status(qd_ctx *ctx, node_info_t *ni, int max, int score,
 		need_close = 1;
 	}
 
+	/* Don't block while writing to this file 
+	 * XXX Not set O_NONBLOCK twice on stdout?
+	 */
+	fd = fileno(fp);
+	flags = fcntl(fd, F_GETFD, 0);
+	if (fcntl(fd, F_SETFD, flags | O_NONBLOCK) != 0) {
+		if (need_close)
+			fclose(fp);
+		return;
+	}
+
 	now = time(NULL);
 	fprintf(fp, "Time Stamp: %s", ctime(&now));
 	fprintf(fp, "Node ID: %d\n", ctx->qc_my_id);


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