All of lore.kernel.org
 help / color / mirror / Atom feed
From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/fence/fenced fd.h main.c member_cman.c
Date: 25 Jul 2006 20:05:53 -0000	[thread overview]
Message-ID: <20060725200553.29538.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2006-07-25 20:05:52

Modified files:
	fence/fenced   : fd.h main.c member_cman.c 

Log message:
	keep 1MB circular buffer of debug messages that can be sent to a
	connected client

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/fd.h.diff?cvsroot=cluster&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/main.c.diff?cvsroot=cluster&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/member_cman.c.diff?cvsroot=cluster&r1=1.12&r2=1.13

--- cluster/fence/fenced/fd.h	2006/07/10 17:02:43	1.22
+++ cluster/fence/fenced/fd.h	2006/07/25 20:05:52	1.23
@@ -42,22 +42,27 @@
 #include "list.h"
 #include "libgroup.h"
 
-extern char			*prog_name;
-extern int			fenced_debug_opt;
-extern char			fenced_debug_buf[256];
-
 #define MAX_NODENAME_LEN	255   /* should match libcman.h */
 #define MAX_GROUPNAME_LEN	32    /* should match libgroup.h */
 #define MAX_NODES		256
 #define MAXARGS                 100  /* FIXME */
 #define MAXLINE                 256
 #define MAX_CLIENTS		5
+#define DUMP_SIZE               (1024 * 1024)
 
 #define DEFAULT_POST_JOIN_DELAY	6
 #define DEFAULT_POST_FAIL_DELAY	0
 #define DEFAULT_CLEAN_START	0
 #define FENCED_SOCK_PATH	"fenced_socket"
 
+extern char			*prog_name;
+extern int			daemon_debug_opt;
+extern char			daemon_debug_buf[256];
+extern char dump_buf[DUMP_SIZE];
+extern int dump_point;
+extern int dump_wrap;
+
+extern void daemon_dump_save(void);
 
 /* use this one before we fork into the background */
 #define die1(fmt, args...) \
@@ -100,16 +105,11 @@
   sleep(1); \
 }
 
-#define log_print(fmt, args...) \
-do { \
-	snprintf(fenced_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \
-	if (fenced_debug_opt) fprintf(stderr, "%s", fenced_debug_buf); \
-} while (0)
-
-/* FIXME: send down debug client connection */
 #define log_debug(fmt, args...) \
 do { \
-	log_print(fmt, ##args); \
+	snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \
+	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
+	daemon_dump_save(); \
 } while (0)
 
 #define log_error(fmt, args...) \
--- cluster/fence/fenced/main.c	2006/03/23 17:05:25	1.35
+++ cluster/fence/fenced/main.c	2006/07/25 20:05:52	1.36
@@ -283,6 +283,24 @@
 		client[i].fd = -1;
 }
 
+static int do_dump(int ci)
+{
+	int rv, len;
+
+	if (dump_wrap) {
+		len = DUMP_SIZE - dump_point;
+		rv = write(client[ci].fd, dump_buf + dump_point, len);
+		if (rv != len)
+			log_debug("write error %d errno %d", rv, errno);
+	}
+	len = dump_point;
+
+	rv = write(client[ci].fd, dump_buf, len);
+	if (rv != len)
+		log_debug("write error %d errno %d", rv, errno);
+	return 0;
+}
+
 static int client_process(int ci)
 {
 	char buf[MAXLINE], *argv[MAXARGS], *cmd, *name, out[MAXLINE];
@@ -312,15 +330,16 @@
 		rv = do_join(name);
 	else if (!strcmp(cmd, "leave"))
 		rv = do_leave(name);
-	else
+	else if (!strcmp(cmd, "dump")) {
+		do_dump(ci);
+		return 0;
+	} else
 		rv = -EINVAL;
 
 	sprintf(out, "%d", rv);
 	rv = write(client[ci].fd, out, MAXLINE);
 
-	/* monitor: set var to cause log_debug messages to be
-	   sent down client socket
-           exit: cause fenced loop to exit */
+	/* exit: cause fenced loop to exit */
 
 	return rv;
 }
@@ -511,7 +530,7 @@
 			break;
 
 		case 'D':
-			fenced_debug_opt = TRUE;
+			daemon_debug_opt = TRUE;
 			break;
 
 		case 'h':
@@ -558,7 +577,7 @@
 	INIT_LIST_HEAD(&domains);
 	client_init();
 
-	if (!fenced_debug_opt) {
+	if (!daemon_debug_opt) {
 		pid_t pid = fork();
 		if (pid < 0) {
 			perror("main: cannot fork");
@@ -584,7 +603,26 @@
 	return error;
 }
 
+void daemon_dump_save(void)
+{
+	int len, i;
+
+	len = strlen(daemon_debug_buf);
+
+	for (i = 0; i < len; i++) {
+		dump_buf[dump_point++] = daemon_debug_buf[i];
+
+		if (dump_point == DUMP_SIZE) {
+			dump_point = 0;
+			dump_wrap = 1;
+		}
+	}
+}
+
 char *prog_name;
-int fenced_debug_opt;
-char fenced_debug_buf[256];
+int daemon_debug_opt;
+char daemon_debug_buf[256];
+char dump_buf[DUMP_SIZE];
+int dump_point;
+int dump_wrap;
 
--- cluster/fence/fenced/member_cman.c	2006/06/30 15:38:39	1.12
+++ cluster/fence/fenced/member_cman.c	2006/07/25 20:05:52	1.13
@@ -87,7 +87,7 @@
 
 	rv = cman_get_nodes(ch, MAX_NODES, &cman_node_count, cman_nodes);
 	if (rv < 0)
-		log_print("cman_get_nodes error %d %d", rv, errno);
+		log_error("cman_get_nodes error %d %d", rv, errno);
 }
 
 static void process_cman_callback(void)



                 reply	other threads:[~2006-07-25 20:05 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=20060725200553.29538.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.