[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/fence/fenced fd.h main.c member_cman.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland 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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]