src/client_admin.c | 26 ++++++++++----------------
src/log.c | 7 +------
src/log.h | 2 +-
src/main.c | 8 ++------
4 files changed, 14 insertions(+), 29 deletions(-)
New commits:
commit 6899ed3210b8fdab6b1b8535c54ece954e60a856
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Apr 20 11:55:54 2011 -0500
sanlock: fix log_dump
by not bothering with the size
diff --git a/src/client_admin.c b/src/client_admin.c
index 2c90ad1..c488b50 100644
--- a/src/client_admin.c
+++ b/src/client_admin.c
@@ -47,8 +47,8 @@ int sanlock_shutdown(void)
int sanlock_log_dump(void)
{
struct sm_header h;
- char *buf;
- int fd, rv, len;
+ char buf[4096];
+ int fd, rv;
fd = send_command(SM_CMD_LOG_DUMP, 0);
if (fd < 0)
@@ -62,23 +62,17 @@ int sanlock_log_dump(void)
goto out;
}
- len = h.length - sizeof(h);
+ while (1) {
+ memset(buf, 0, sizeof(buf));
- buf = malloc(len);
- if (!buf) {
- rv = -ENOMEM;
- goto out;
- }
- memset(buf, 0, len);
+ rv = recv(fd, buf, sizeof(buf) - 1, MSG_WAITALL);
- rv = recv(fd, buf, len, MSG_WAITALL);
- if (rv != len) {
- rv = -1;
- goto out;
+ if (rv > 0)
+ printf("%s", buf);
+ else
+ break;
}
-
- rv = 0;
- printf("%s\n", buf);
+ printf("\n");
out:
close(fd);
return rv;
diff --git a/src/log.c b/src/log.c
index ee58898..884507e 100644
--- a/src/log.c
+++ b/src/log.c
@@ -175,15 +175,10 @@ static void write_dropped(int level, int num)
write_entry(level, str);
}
-void write_log_dump(int fd, struct sm_header *hd)
+void write_log_dump(int fd)
{
pthread_mutex_lock(&log_mutex);
- hd->length = sizeof(struct sm_header);
- hd->length += log_wrap ? SM_LOG_DUMP_SIZE : log_point;
-
- send(fd, hd, sizeof(struct sm_header), MSG_DONTWAIT);
-
if (log_wrap)
send(fd, log_dump + log_point, SM_LOG_DUMP_SIZE - log_point, MSG_DONTWAIT);
diff --git a/src/log.h b/src/log.h
index b065787..1aef3b2 100644
--- a/src/log.h
+++ b/src/log.h
@@ -14,7 +14,7 @@ void log_level(int space_id, int token_id, int level, const char *fmt,
...)
int setup_logging(void);
void close_logging(void);
-void write_log_dump(int fd, struct sm_header *hd);
+void write_log_dump(int fd);
#define log_debug(fmt, args...) log_level(0, 0, LOG_DEBUG, fmt, ##args)
#define log_space(space, fmt, args...) log_level(space->space_id, 0, LOG_DEBUG,
fmt, ##args)
diff --git a/src/main.c b/src/main.c
index c1e8abd..5468990 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1642,13 +1642,9 @@ static void cmd_status(int fd, struct sm_header *h_recv)
static void cmd_log_dump(int fd, struct sm_header *h_recv)
{
- struct sm_header h;
-
- memcpy(&h, h_recv, sizeof(struct sm_header));
-
- /* can't send header until taking log_mutex to find the length */
+ send(fd, h_recv, sizeof(struct sm_header), MSG_DONTWAIT);
- write_log_dump(fd, &h);
+ write_log_dump(fd);
}
static void process_cmd_thread_lockspace(int ci_in, struct sm_header *h_recv)