From 898bbd3b03540f9276487a4e25480f255e727126 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 15 Feb 2006 10:07:45 +0100 Subject: [PATCH] [PATCH] blktrace: proper end-of-run cleanup for restart --- blktrace.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/blktrace.c b/blktrace.c index 19a039f..a58b3d3 100644 --- a/blktrace.c +++ b/blktrace.c @@ -1267,6 +1267,8 @@ static int net_server_loop(void) */ static int net_server(void) { + struct device_information *dip; + struct thread_information *tip; struct sockaddr_in addr; socklen_t socklen; int fd, opt, i, j; @@ -1320,18 +1322,28 @@ repeat: break; } - for (i = 0; i < ndevs; i++) { - struct device_information *dip = &device_information[i]; - - for (j = 0; j < ncpus; j++) - tip_ftrunc_final(&dip->threads[j]); - } + for_each_dip(dip, i) + for_each_tip(dip, tip, j) + tip_ftrunc_final(tip); show_stats(); if (is_done()) return 0; + /* + * cleanup for next run + */ + for_each_dip(dip, i) { + for_each_tip(dip, tip, j) + fclose(tip->ofile); + + free(dip->threads); + } + + free(device_information); + device_information = NULL; + ncpus = ndevs = 0; goto repeat; } -- 2.25.1