|
|
4d4aa8 |
From 090026f33031c1b46dfe3e2e077c6cb0aa149378 Mon Sep 17 00:00:00 2001
|
|
|
4d4aa8 |
From: David Teigland <teigland@redhat.com>
|
|
|
4d4aa8 |
Date: Wed, 12 Feb 2014 12:09:10 -0600
|
|
|
4d4aa8 |
Subject: [PATCH 5/9] dlm_tool: fix status printing in libdlmcontrol
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
When a node was both a startup node and a normal node,
|
|
|
4d4aa8 |
then status would segfault.
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
Signed-off-by: David Teigland <teigland@redhat.com>
|
|
|
4d4aa8 |
---
|
|
|
4d4aa8 |
dlm_controld/lib.c | 67 +++++++++++++++++++++++++++++++++++++++++++-----------
|
|
|
4d4aa8 |
1 file changed, 54 insertions(+), 13 deletions(-)
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
diff --git a/dlm_controld/lib.c b/dlm_controld/lib.c
|
|
|
4d4aa8 |
index 961626f090ca..efb74e00638f 100644
|
|
|
4d4aa8 |
--- a/dlm_controld/lib.c
|
|
|
4d4aa8 |
+++ b/dlm_controld/lib.c
|
|
|
4d4aa8 |
@@ -337,12 +337,19 @@ int dlmc_print_status(uint32_t flags)
|
|
|
4d4aa8 |
struct dlmc_state *st;
|
|
|
4d4aa8 |
char maxstr[DLMC_STATE_MAXSTR];
|
|
|
4d4aa8 |
char maxbin[DLMC_STATE_MAXBIN];
|
|
|
4d4aa8 |
- char *str, *bin;
|
|
|
4d4aa8 |
- int all_count, node_count, fence_count;
|
|
|
4d4aa8 |
- int all_ids[MAX_SORT], node_ids[MAX_SORT], fence_ids[MAX_SORT];
|
|
|
4d4aa8 |
- char *node_lines[MAX_SORT], *fence_lines[MAX_SORT];
|
|
|
4d4aa8 |
- char *node_line, *fence_line;
|
|
|
4d4aa8 |
- int fd, rv, off;
|
|
|
4d4aa8 |
+ char *str;
|
|
|
4d4aa8 |
+ char *bin;
|
|
|
4d4aa8 |
+ int all_count, node_count, fence_count, startup_count;
|
|
|
4d4aa8 |
+ int all_ids[MAX_SORT];
|
|
|
4d4aa8 |
+ int node_ids[MAX_SORT];
|
|
|
4d4aa8 |
+ int fence_ids[MAX_SORT];
|
|
|
4d4aa8 |
+ int startup_ids[MAX_SORT];
|
|
|
4d4aa8 |
+ char *node_lines[MAX_SORT];
|
|
|
4d4aa8 |
+ char *fence_lines[MAX_SORT];
|
|
|
4d4aa8 |
+ char *node_line;
|
|
|
4d4aa8 |
+ char *fence_line;
|
|
|
4d4aa8 |
+ int found_node;
|
|
|
4d4aa8 |
+ int fd, rv;
|
|
|
4d4aa8 |
int i, j;
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
init_header(&h, DLMC_CMD_DUMP_STATUS, NULL, 0);
|
|
|
4d4aa8 |
@@ -363,14 +370,15 @@ int dlmc_print_status(uint32_t flags)
|
|
|
4d4aa8 |
st = &stat;;
|
|
|
4d4aa8 |
str = maxstr;
|
|
|
4d4aa8 |
bin = maxbin;
|
|
|
4d4aa8 |
- off = 0;
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
all_count = 0;
|
|
|
4d4aa8 |
node_count = 0;
|
|
|
4d4aa8 |
fence_count = 0;
|
|
|
4d4aa8 |
+ startup_count = 0;
|
|
|
4d4aa8 |
memset(&all_ids, 0, sizeof(all_ids));
|
|
|
4d4aa8 |
memset(&node_ids, 0, sizeof(node_ids));
|
|
|
4d4aa8 |
memset(&fence_ids, 0, sizeof(fence_ids));
|
|
|
4d4aa8 |
+ memset(&startup_ids, 0, sizeof(startup_ids));
|
|
|
4d4aa8 |
memset(node_lines, 0, sizeof(node_lines));
|
|
|
4d4aa8 |
memset(fence_lines, 0, sizeof(fence_lines));
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
@@ -402,9 +410,11 @@ int dlmc_print_status(uint32_t flags)
|
|
|
4d4aa8 |
print_daemon(st, str, bin, flags);
|
|
|
4d4aa8 |
break;
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
- case DLMC_STATE_DAEMON_NODE:
|
|
|
4d4aa8 |
case DLMC_STATE_STARTUP_NODE:
|
|
|
4d4aa8 |
+ startup_ids[startup_count++] = st->nodeid;
|
|
|
4d4aa8 |
+ break;
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
+ case DLMC_STATE_DAEMON_NODE:
|
|
|
4d4aa8 |
if (flags & DLMC_STATUS_VERBOSE) {
|
|
|
4d4aa8 |
printf("nodeid %d\n", st->nodeid);
|
|
|
4d4aa8 |
print_str(str, st->str_len);
|
|
|
4d4aa8 |
@@ -426,7 +436,7 @@ int dlmc_print_status(uint32_t flags)
|
|
|
4d4aa8 |
all_ids[all_count++] = st->nodeid;
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
node_ids[node_count] = st->nodeid;
|
|
|
4d4aa8 |
- node_lines[node_count++] = node_line;
|
|
|
4d4aa8 |
+ node_lines[node_count] = node_line;
|
|
|
4d4aa8 |
node_count++;
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
if (!fence_line[0]) {
|
|
|
4d4aa8 |
@@ -450,13 +460,39 @@ int dlmc_print_status(uint32_t flags)
|
|
|
4d4aa8 |
if (all_count)
|
|
|
4d4aa8 |
qsort(all_ids, all_count, sizeof(int), nodeid_compare);
|
|
|
4d4aa8 |
|
|
|
4d4aa8 |
+ /* don't free any node_lines in this startup loop because we are just
|
|
|
4d4aa8 |
+ borrowing them; they are needed in the real node loop below. */
|
|
|
4d4aa8 |
+
|
|
|
4d4aa8 |
+ if (startup_count) {
|
|
|
4d4aa8 |
+ for (i = 0; i < startup_count; i++) {
|
|
|
4d4aa8 |
+ found_node = 0;
|
|
|
4d4aa8 |
+ for (j = 0; j < node_count; j++) {
|
|
|
4d4aa8 |
+ if (startup_ids[i] != node_ids[j])
|
|
|
4d4aa8 |
+ continue;
|
|
|
4d4aa8 |
+ found_node = 1;
|
|
|
4d4aa8 |
+ if (!node_lines[j])
|
|
|
4d4aa8 |
+ printf("startup node %d\n", st->nodeid);
|
|
|
4d4aa8 |
+ else
|
|
|
4d4aa8 |
+ printf("startup %s", node_lines[j]);
|
|
|
4d4aa8 |
+ break;
|
|
|
4d4aa8 |
+ }
|
|
|
4d4aa8 |
+ if (!found_node)
|
|
|
4d4aa8 |
+ printf("startup node %d\n", st->nodeid);
|
|
|
4d4aa8 |
+ }
|
|
|
4d4aa8 |
+ }
|
|
|
4d4aa8 |
+
|
|
|
4d4aa8 |
if (all_count && fence_count) {
|
|
|
4d4aa8 |
for (i = 0; i < all_count; i++) {
|
|
|
4d4aa8 |
for (j = 0; j < fence_count; j++) {
|
|
|
4d4aa8 |
if (all_ids[i] != fence_ids[j])
|
|
|
4d4aa8 |
continue;
|
|
|
4d4aa8 |
- printf("%s", fence_lines[j]);
|
|
|
4d4aa8 |
- free(fence_lines[j]);
|
|
|
4d4aa8 |
+ if (!fence_lines[j]) {
|
|
|
4d4aa8 |
+ printf("fence %d no data\n", fence_ids[j]);
|
|
|
4d4aa8 |
+ } else {
|
|
|
4d4aa8 |
+ printf("%s", fence_lines[j]);
|
|
|
4d4aa8 |
+ free(fence_lines[j]);
|
|
|
4d4aa8 |
+ fence_lines[j] = NULL;
|
|
|
4d4aa8 |
+ }
|
|
|
4d4aa8 |
break;
|
|
|
4d4aa8 |
}
|
|
|
4d4aa8 |
}
|
|
|
4d4aa8 |
@@ -467,8 +503,13 @@ int dlmc_print_status(uint32_t flags)
|
|
|
4d4aa8 |
for (j = 0; j < node_count; j++) {
|
|
|
4d4aa8 |
if (all_ids[i] != node_ids[j])
|
|
|
4d4aa8 |
continue;
|
|
|
4d4aa8 |
- printf("%s", node_lines[j]);
|
|
|
4d4aa8 |
- free(node_lines[j]);
|
|
|
4d4aa8 |
+ if (!node_lines[j]) {
|
|
|
4d4aa8 |
+ printf("node %d no data\n", node_ids[j]);
|
|
|
4d4aa8 |
+ } else {
|
|
|
4d4aa8 |
+ printf("%s", node_lines[j]);
|
|
|
4d4aa8 |
+ free(node_lines[j]);
|
|
|
4d4aa8 |
+ node_lines[j] = NULL;
|
|
|
4d4aa8 |
+ }
|
|
|
4d4aa8 |
break;
|
|
|
4d4aa8 |
}
|
|
|
4d4aa8 |
}
|
|
|
4d4aa8 |
--
|
|
|
4d4aa8 |
1.8.3.1
|
|
|
4d4aa8 |
|