mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-07 17:17:44 +03:00
tree-wide: convert bootchart and lldp code to use clock_boottime_or_monotonic()
We should avoid using CLOCK_BOOTTIME directly unless we actually can sensible distuingish it from CLOCK_MONOTONIC. CLOCK_BOOTTIME is only fully feature on very recent Linux kernels, hence we should stick to a fallback logic, which is already available in the clock_boottime_or_monotonic() call.
This commit is contained in:
parent
5ef9b2203e
commit
27ec691bfd
@ -367,7 +367,7 @@ int main(int argc, char *argv[]) {
|
||||
struct timespec n;
|
||||
double uptime;
|
||||
|
||||
clock_gettime(CLOCK_BOOTTIME, &n);
|
||||
clock_gettime(clock_boottime_or_monotonic(), &n);
|
||||
uptime = (n.tv_sec + (n.tv_nsec / (double) NSEC_PER_SEC));
|
||||
|
||||
log_start = gettime_ns();
|
||||
|
@ -392,7 +392,7 @@ static void lldp_mib_delete_objects(sd_lldp *lldp) {
|
||||
break;
|
||||
|
||||
if (t <= 0)
|
||||
t = now(CLOCK_BOOTTIME);
|
||||
t = now(clock_boottime_or_monotonic());
|
||||
|
||||
if (p->until > t)
|
||||
break;
|
||||
@ -490,7 +490,7 @@ int sd_lldp_save(sd_lldp *lldp, const char *lldp_file) {
|
||||
free(s);
|
||||
s = k;
|
||||
|
||||
time = now(CLOCK_BOOTTIME);
|
||||
time = now(clock_boottime_or_monotonic());
|
||||
|
||||
/* Don't write expired packets */
|
||||
if (time - p->until <= 0)
|
||||
|
@ -976,7 +976,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||
return log_warning_errno(r < 0 ? r : ERANGE,
|
||||
"Failed to parse TTL \"%s\": %m", b);
|
||||
|
||||
time = now(CLOCK_BOOTTIME);
|
||||
time = now(clock_boottime_or_monotonic());
|
||||
if (x < time)
|
||||
continue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user