mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
dmstats: separate TIMERFD and useleep() exit conditions
The time management code mixes tests of the _timer_fd value with code that should be timer agnostic: this causes problems for users of the usleep() timer, since it cannot properly detect the start of a new interval: Beginning first interval Interval #18446744069414584348 time delta: 1000000000ns Interval #18446744069414584348 current err: 0ns End interval #18446744069414584348 duration: 1000000000ns Adjusted sample interval duration: 1000000000ns [...] Beginning first interval Interval #18446744069414584349 time delta: 1000000000ns Interval #18446744069414584349 current err: 0ns End interval #18446744069414584349 duration: 1000000000ns Adjusted sample interval duration: 1000000000ns Separate these out, by defining a _timer_running() call that each timer implements, and only define _timer_fd if we are compiling with TIMERFD enabled.
This commit is contained in:
parent
886b4f755d
commit
5635cd3b03
@ -286,7 +286,9 @@ static struct dm_timestamp *_start_timestamp = NULL;
|
||||
static uint64_t _interval = 0; /* configured interval in nsecs */
|
||||
static uint64_t _new_interval = 0; /* flag top-of-interval */
|
||||
static uint64_t _last_interval = 0; /* approx. measured interval in nsecs */
|
||||
#ifdef HAVE_SYS_TIMERFD_H
|
||||
static int _timer_fd = -1; /* timerfd file descriptor. */
|
||||
#endif /* HAVE_SYS_TIMERFD_H */
|
||||
|
||||
/* Invalid fd value used to signal end-of-reporting. */
|
||||
#define TIMER_STOPPED -2
|
||||
@ -647,6 +649,14 @@ static int _do_timer_wait(void)
|
||||
return _do_timerfd_wait();
|
||||
}
|
||||
|
||||
static int _timer_running(void)
|
||||
{
|
||||
/*
|
||||
* Clock shutdown for exit - nothing to do.
|
||||
*/
|
||||
return ((_timer_fd == TIMER_STOPPED) && !_cycle_timestamp);
|
||||
}
|
||||
|
||||
#else /* !HAVE_SYS_TIMERFD_H */
|
||||
static int _start_usleep_timer(void)
|
||||
{
|
||||
@ -718,6 +728,11 @@ static int _do_timer_wait(void)
|
||||
return _do_usleep_wait();
|
||||
}
|
||||
|
||||
static int _timer_running(void)
|
||||
{
|
||||
return (_start_timestamp != NULL);
|
||||
}
|
||||
|
||||
#endif /* HAVE_SYS_TIMERFD_H */
|
||||
|
||||
static int _update_interval_times(void)
|
||||
@ -729,7 +744,7 @@ static int _update_interval_times(void)
|
||||
/*
|
||||
* Clock shutdown for exit - nothing to do.
|
||||
*/
|
||||
if ((_timer_fd == TIMER_STOPPED) && !_cycle_timestamp)
|
||||
if (!_timer_running())
|
||||
goto out;
|
||||
|
||||
/* clock is running */
|
||||
@ -805,7 +820,7 @@ static int _update_interval_times(void)
|
||||
|
||||
out:
|
||||
/* timer stopped or never started */
|
||||
if (!r || _timer_fd < 0) {
|
||||
if (!r || !_timer_running()) {
|
||||
/* The _cycle_timestamp has not yet been allocated if we
|
||||
* fail to obtain this_timestamp on the first interval.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user