diff options
author | Vladislav Grishenko <themiron@mail.ru> | 2018-08-15 22:03:45 +0500 |
---|---|---|
committer | Vladislav Grishenko <themiron@mail.ru> | 2020-05-22 12:53:20 +0500 |
commit | c78e3129d404f20d556f727ceee3704722de8cc7 (patch) | |
tree | ddc4fd9257dff95cc885ac4aa5d6b05aeabdbfe7 /pppd/tty.c | |
parent | 347904e33a8a1993316e57445a1ba8243cd947ce (diff) | |
download | ppp-c78e3129d404f20d556f727ceee3704722de8cc7.tar.gz |
pppd: linux: use monotonic time if possible
gettimeofday() suffers from time jumps due ntp or any manual change,
so duration measurements and scheduling can not be accurate.
let's use monotonic time source instead, if available.
it's known glibc (< 2.3.4) & old uclibc don't provide CLOCK_MONOTONIC
denine, but kernel may have it supported. so, use clock_gettime()
with fallback to gettimeofday() if first call has failed.
several gettimeofday()/time() calls still have to be preserved for
debug, pseudoterminal timestamping and string formatting. all the
rest calls are replaced to new get_time() call.
solaris kept with gettimeofday() as before, corresponding get_time()
system implementation can be updated/added in any future.
Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
Diffstat (limited to 'pppd/tty.c')
-rw-r--r-- | pppd/tty.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1072,7 +1072,7 @@ charshunt(ifd, ofd, record_file) pty_readable = stdin_readable = 1; ilevel = olevel = 0; - gettimeofday(&levelt, NULL); + get_time(&levelt); if (max_data_rate) { max_level = max_data_rate / 10; if (max_level < 100) @@ -1121,7 +1121,7 @@ charshunt(ifd, ofd, record_file) int nbt; struct timeval now; - gettimeofday(&now, NULL); + get_time(&now); dt = (now.tv_sec - levelt.tv_sec + (now.tv_usec - levelt.tv_usec) / 1e6); nbt = (int)(dt * max_data_rate); |