cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/group daemon/main.c gfs_controld/main. ...
Date: 26 Oct 2007 19:33:22 -0000	[thread overview]
Message-ID: <20071026193322.1608.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2007-10-26 19:33:21

Modified files:
	group/daemon   : main.c 
	group/gfs_controld: main.c 
	group/tool     : main.c 

Log message:
	Improve the dumping of debug logs from daemons.
	bz 317181
	
	group_tool reads debug logs from groupd, fenced, and gfs_controld.
	The dumping code in all three daemons is now identical.  The other
	change is that the dumping function terminates the final write
	with \0, and no longer sends the entire 1MB log buffer if it's not full.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/daemon/main.c.diff?cvsroot=cluster&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/tool/main.c.diff?cvsroot=cluster&r1=1.24&r2=1.25

--- cluster/group/daemon/main.c	2007/09/07 19:17:27	1.59
+++ cluster/group/daemon/main.c	2007/10/26 19:33:21	1.60
@@ -553,19 +553,20 @@
 
 static int do_dump(int fd)
 {
-	int rv, len = DUMP_SIZE;
+	int len;
 
 	if (dump_wrap) {
 		len = DUMP_SIZE - dump_point;
-		rv = do_write(fd, dump_buf + dump_point, len);
-		if (rv < 0)
-			log_print("dump write error %d errno %d", rv, errno);
+		do_write(fd, dump_buf + dump_point, len);
+		len = dump_point;
+	} else
 		len = dump_point;
-	}
 
-	rv = do_write(fd, dump_buf, len);
-	if (rv < 0)
-		log_print("dump write error %d errno %d", rv, errno);
+	/* NUL terminate the debug string */
+	dump_buf[dump_point] = '\0';
+
+	do_write(fd, dump_buf, len);
+
 	return 0;
 }
 
@@ -667,6 +668,7 @@
 
 	case DO_DUMP:
 		do_dump(client[ci].fd);
+		close(client[ci].fd);
 		break;
 
 	case DO_LOG:
--- cluster/group/gfs_controld/main.c	2007/06/12 20:04:41	1.30
+++ cluster/group/gfs_controld/main.c	2007/10/26 19:33:21	1.31
@@ -255,17 +255,22 @@
 	return do_write(client[ci].fd, buf, len);
 }
 
-static int dump_debug(int ci)
+static int do_dump(int fd)
 {
-	int len = DUMP_SIZE;
+	int len;
 
 	if (dump_wrap) {
 		len = DUMP_SIZE - dump_point;
-		do_write(client[ci].fd, dump_buf + dump_point, len);
+		do_write(fd, dump_buf + dump_point, len);
 		len = dump_point;
-	}
+	} else
+		len = dump_point;
+
+	/* NUL terminate the debug string */
+	dump_buf[dump_point] = '\0';
+
+	do_write(fd, dump_buf, len);
 
-	do_write(client[ci].fd, dump_buf, len);
 	return 0;
 }
 
@@ -375,7 +380,8 @@
 		goto reply;
 
 	} else if (!strcmp(cmd, "dump")) {
-		dump_debug(ci);
+		do_dump(client[ci].fd);
+		close(client[ci].fd);
 
 	} else if (!strcmp(cmd, "plocks")) {
 		dump_plocks(argv[1], client[ci].fd);
--- cluster/group/tool/main.c	2006/12/01 15:26:05	1.24
+++ cluster/group/tool/main.c	2007/10/26 19:33:21	1.25
@@ -379,10 +379,8 @@
 		return -1;
 	}
 
-	rv = do_read(fd, inbuf, sizeof(inbuf));
-	if (rv < 0)
-		printf("dump read error %d errno %d\n", rv, errno);
-	do_write(STDOUT_FILENO, inbuf, sizeof(inbuf));
+	do_read(fd, inbuf, sizeof(inbuf));
+	do_write(STDOUT_FILENO, inbuf, strlen(inbuf));
 
 	close(fd);
 	return 0;
@@ -405,9 +403,7 @@
 		return -1;
 	}
 
-	rv = do_read(fd, inbuf, sizeof(inbuf));
-	if (rv < 0)
-		printf("dump read error %d errno %d\n", rv, errno);
+	do_read(fd, inbuf, sizeof(inbuf));
 	do_write(STDOUT_FILENO, inbuf, sizeof(inbuf));
 
 	close(fd);



                 reply	other threads:[~2007-10-26 19:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071026193322.1608.qmail@sourceware.org \
    --to=teigland@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).