From mboxrd@z Thu Jan 1 00:00:00 1970 From: teigland@sourceware.org Date: 26 Oct 2007 19:33:22 -0000 Subject: [Cluster-devel] cluster/group daemon/main.c gfs_controld/main. ... Message-ID: <20071026193322.1608.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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);