From 8d9bb0defb3f63640d557b377fa937d0db0de013 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Fri, 9 Apr 2010 22:31:24 -0400 Subject: [PATCH] afsmonitor: fix segv on exit Fix crash during afsmonitor shutdown when monitoring multiple fileserver or clients. Change-Id: I5fa5cb7d89dbdfcc5f97541a0e0c6b0836d558b1 Reviewed-on: http://gerrit.openafs.org/1735 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afsmonitor/afsmonitor.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/afsmonitor/afsmonitor.c b/src/afsmonitor/afsmonitor.c index 84a73b216..184a0f9ba 100644 --- a/src/afsmonitor/afsmonitor.c +++ b/src/afsmonitor/afsmonitor.c @@ -362,7 +362,7 @@ afsmon_Exit(int a_exitVal) /* exit code */ struct afsmon_cm_Results_list *next_cmlist; struct xstat_cm_ProbeResults *tmp_xstat_cmPR; struct afsmon_hostEntry *curr_hostEntry; - struct afsmon_hostEntry *prev_hostEntry; + struct afsmon_hostEntry *next_hostEntry; int i; int j; int bufslot; @@ -507,14 +507,12 @@ afsmon_Exit(int a_exitVal) /* exit code */ if (afsmon_debug) fprintf(debugFD, "Deallocating FS hostEntries .."); curr_hostEntry = FSnameList; - for (i = 0; i < numFS; i++) { - prev_hostEntry = curr_hostEntry; + while (curr_hostEntry) { + next_hostEntry = curr_hostEntry->next; if (curr_hostEntry->thresh != NULL) free(curr_hostEntry->thresh); free(curr_hostEntry); - if (afsmon_debug) - fprintf(debugFD, " %d", i); - curr_hostEntry = prev_hostEntry->next; + curr_hostEntry = next_hostEntry; } if (afsmon_debug) fprintf(debugFD, "\n"); @@ -523,14 +521,12 @@ afsmon_Exit(int a_exitVal) /* exit code */ if (afsmon_debug) fprintf(debugFD, "Deallocating CM hostEntries .."); curr_hostEntry = CMnameList; - for (i = 0; i < numCM; i++) { - prev_hostEntry = curr_hostEntry; + while (curr_hostEntry) { + next_hostEntry = curr_hostEntry->next; if (curr_hostEntry->thresh != NULL) free(curr_hostEntry->thresh); free(curr_hostEntry); - if (afsmon_debug) - fprintf(debugFD, " %d", i); - curr_hostEntry = prev_hostEntry->next; + curr_hostEntry = next_hostEntry; } if (afsmon_debug) fprintf(debugFD, "\n"); -- 2.39.5