Rename structure members for clarity - "tstp_time" becomes "when_tstp_arrived", and "toffset" becomes "total_stoppage_time".
This commit is contained in:
@@ -245,8 +245,8 @@ struct pvstate_s {
|
||||
struct sigaction old_sigusr1;
|
||||
#endif
|
||||
struct sigaction old_sigalrm;
|
||||
struct timespec tstp_time; /* see pv_sig_tstp() / __cont() */
|
||||
struct timespec toffset; /* total time spent stopped */
|
||||
struct timespec when_tstp_arrived; /* see pv_sig_tstp() / __cont() */
|
||||
struct timespec total_stoppage_time; /* total time spent stopped */
|
||||
#ifdef PV_REMOTE_CONTROL
|
||||
volatile sig_atomic_t rxusr2; /* whether SIGUSR2 was received */
|
||||
volatile pid_t sender_usr2; /* PID of sending process for SIGUSR2 */
|
||||
|
||||
+7
-7
@@ -143,7 +143,7 @@ static void pv__show_stats(pvstate_t state)
|
||||
*/
|
||||
static long double pv__elapsed_transfer_time(const struct timespec *loop_start_time,
|
||||
const struct timespec *current_time,
|
||||
const struct timespec *time_spent_stopped)
|
||||
const struct timespec *total_stoppage_time)
|
||||
{
|
||||
struct timespec effective_start_time, transfer_elapsed;
|
||||
|
||||
@@ -154,7 +154,7 @@ static long double pv__elapsed_transfer_time(const struct timespec *loop_start_t
|
||||
* Calculate the effective start time: the time we actually started,
|
||||
* plus the total time we spent stopped.
|
||||
*/
|
||||
pv_elapsedtime_add(&effective_start_time, loop_start_time, time_spent_stopped);
|
||||
pv_elapsedtime_add(&effective_start_time, loop_start_time, total_stoppage_time);
|
||||
|
||||
/*
|
||||
* Now get the effective elapsed transfer time - current time minus
|
||||
@@ -556,7 +556,7 @@ int pv_main_loop(pvstate_t state)
|
||||
*/
|
||||
pv_sig_nopause();
|
||||
pv_elapsedtime_read(&start_time);
|
||||
pv_elapsedtime_zero(&(state->signal.toffset));
|
||||
pv_elapsedtime_zero(&(state->signal.total_stoppage_time));
|
||||
pv_sig_allowpause();
|
||||
|
||||
/*
|
||||
@@ -569,7 +569,7 @@ int pv_main_loop(pvstate_t state)
|
||||
|
||||
/* Calculate the elapsed transfer time. */
|
||||
state->transfer.elapsed_seconds =
|
||||
pv__elapsed_transfer_time(&start_time, &cur_time, &(state->signal.toffset));
|
||||
pv__elapsed_transfer_time(&start_time, &cur_time, &(state->signal.total_stoppage_time));
|
||||
|
||||
/*
|
||||
* Just go round the loop again if there's no display and
|
||||
@@ -1081,12 +1081,12 @@ int pv_watchfd_loop(pvstate_t state)
|
||||
*/
|
||||
info_item->position = position_now;
|
||||
/*
|
||||
* TODO: per-fd toffset counters
|
||||
* (#169).
|
||||
* TODO: per-fd total_stoppage_time
|
||||
* counters (#169).
|
||||
*/
|
||||
info_item->transfer.elapsed_seconds =
|
||||
pv__elapsed_transfer_time(&(info_item->start_time), &cur_time,
|
||||
&(state->signal.toffset));
|
||||
&(state->signal.total_stoppage_time));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+8
-8
@@ -121,7 +121,7 @@ static void pv_sig_tstp( /*@unused@ */ __attribute__((unused))
|
||||
{
|
||||
if (NULL == pv_sig_state)
|
||||
return;
|
||||
pv_elapsedtime_read(&(pv_sig_state->signal.tstp_time));
|
||||
pv_elapsedtime_read(&(pv_sig_state->signal.when_tstp_arrived));
|
||||
if (0 != raise(SIGSTOP)) {
|
||||
debug("%s: %s", "raise", strerror(errno));
|
||||
}
|
||||
@@ -160,7 +160,7 @@ static void pv_sig_cont( /*@unused@ */ __attribute__((unused))
|
||||
* We can only make the time adjustments if this SIGCONT followed a
|
||||
* SIGTSTP such that we have a stop time.
|
||||
*/
|
||||
if (0 != pv_sig_state->signal.tstp_time.tv_sec) {
|
||||
if (0 != pv_sig_state->signal.when_tstp_arrived.tv_sec) {
|
||||
|
||||
memset(¤t_time, 0, sizeof(current_time));
|
||||
memset(&time_spent_stopped, 0, sizeof(time_spent_stopped));
|
||||
@@ -168,14 +168,14 @@ static void pv_sig_cont( /*@unused@ */ __attribute__((unused))
|
||||
pv_elapsedtime_read(¤t_time);
|
||||
|
||||
/* time spent stopped = current time - time SIGTSTP received */
|
||||
pv_elapsedtime_subtract(&time_spent_stopped, ¤t_time, &(pv_sig_state->signal.tstp_time));
|
||||
pv_elapsedtime_subtract(&time_spent_stopped, ¤t_time, &(pv_sig_state->signal.when_tstp_arrived));
|
||||
|
||||
/* add time spent stopped the total stopped-time count */
|
||||
pv_elapsedtime_add(&(pv_sig_state->signal.toffset), &(pv_sig_state->signal.toffset),
|
||||
&time_spent_stopped);
|
||||
pv_elapsedtime_add(&(pv_sig_state->signal.total_stoppage_time),
|
||||
&(pv_sig_state->signal.total_stoppage_time), &time_spent_stopped);
|
||||
|
||||
/* reset the SIGTSTP receipt time */
|
||||
pv_elapsedtime_zero(&(pv_sig_state->signal.tstp_time));
|
||||
pv_elapsedtime_zero(&(pv_sig_state->signal.when_tstp_arrived));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -332,8 +332,8 @@ void pv_sig_init(pvstate_t state)
|
||||
pv_sig_state = state;
|
||||
|
||||
pv_sig_state->flags.suspend_stderr = 0;
|
||||
pv_elapsedtime_zero(&(pv_sig_state->signal.tstp_time));
|
||||
pv_elapsedtime_zero(&(pv_sig_state->signal.toffset));
|
||||
pv_elapsedtime_zero(&(pv_sig_state->signal.when_tstp_arrived));
|
||||
pv_elapsedtime_zero(&(pv_sig_state->signal.total_stoppage_time));
|
||||
|
||||
/*
|
||||
* Note that we cast all sigemptyset() and sigaction() return values
|
||||
|
||||
Reference in New Issue
Block a user