summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1326af3)
nanosleep() was called with the current time, meaning that it would
block for years. This correctly subtracts "now" from the metric's time
and only sleeps for the duration between the two.
- /* 1 / 100 second */
- struct timespec ts = { 0, 10000000 };
-
- ts.tv_sec = (time_t) now;
- ts.tv_nsec = (long) ((now - ((double) ts.tv_sec)) * 1e9);
+ double diff = vl->time - now;
+ struct timespec ts = {
+ .tv_sec = (time_t) diff,
+ };
+ ts.tv_nsec = (long) ((diff - ((double) ts.tv_sec)) * 1e9);
nanosleep (&ts, /* remaining = */ NULL);
now = dtime ();
nanosleep (&ts, /* remaining = */ NULL);
now = dtime ();