summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Noll <maan@systemlinux.org>2008-12-11 14:07:49 +0100
committerAndre Noll <maan@systemlinux.org>2008-12-11 14:07:49 +0100
commita883830b42e84c58233efcf05c16e9aa4bb7597f (patch)
treeacdcddcff035f9af34e8e82fcd372fa3fa1ba401
parent693e5a961e1d1a67ae2c2501913bf77881ebbb19 (diff)
Add some comments to compute_next_snapshot_time().
Also, move the call to gettimeofday() down to where it is needed.
-rw-r--r--dss.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/dss.c b/dss.c
index f8a1e51..c4349a8 100644
--- a/dss.c
+++ b/dss.c
@@ -175,13 +175,13 @@ static void compute_next_snapshot_time(void)
tmp.tv_sec = x;
tmp.tv_usec = 0;
ret = tv_diff(&unit_interval, &tmp, &diff); /* total sleep time per unit interval */
- gettimeofday(&now, NULL);
- if (ret < 0 || !s)
+ if (ret < 0 || !s) /* unit_interval < tmp or no snapshot */
goto min_sleep;
tv_divide(wanted, &diff, &tmp); /* sleep time betweeen two snapshots */
- diff.tv_sec = s->completion_time;
+ diff.tv_sec = s->completion_time; /* completion time of the the latest snaphot */
diff.tv_usec = 0;
tv_add(&diff, &tmp, &next_snapshot_time);
+ gettimeofday(&now, NULL);
if (tv_diff(&now, &next_snapshot_time, NULL) < 0)
goto out;
min_sleep: