From e96041e18fa5f8f0ccb50d31ee0b1c9fb6c5db21 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Wed, 12 Aug 2015 19:16:05 +0100 Subject: [PATCH] dmsetup: only free resources once in the final interval The _update_interval_times() function is called once per reported object: when shutting down at the end of a run only the first call should free timestamps. Clear the timestamp pointers after free and use this to signal to other callers that the clock is already shut down. --- tools/dmsetup.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 9876bd27a..459639b4b 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -637,6 +637,12 @@ static int _update_interval_times(void) uint64_t delta_t; int r = 0; + /* + * Clock shutdown for exit - nothing to do. + */ + if (_timer_fd == TIMER_STOPPED && !_cycle_timestamp) + return 1; + /* * Current timestamp. If _new_interval is set this is used as * the new cycle start timestamp. @@ -717,6 +723,9 @@ out: if (_cycle_timestamp) dm_timestamp_destroy(_cycle_timestamp); dm_timestamp_destroy(this_timestamp); + + /* Clear timestamp pointers to signal shutdown. */ + _cycle_timestamp = this_timestamp = NULL; } return r; }