summaryrefslogtreecommitdiff
path: root/pppd/tty.c
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@mail.ru>2018-08-15 22:03:45 +0500
committerVladislav Grishenko <themiron@mail.ru>2020-05-22 12:53:20 +0500
commitc78e3129d404f20d556f727ceee3704722de8cc7 (patch)
treeddc4fd9257dff95cc885ac4aa5d6b05aeabdbfe7 /pppd/tty.c
parent347904e33a8a1993316e57445a1ba8243cd947ce (diff)
downloadppp-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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/pppd/tty.c b/pppd/tty.c
index c9a0b33..485a44d 100644
--- a/pppd/tty.c
+++ b/pppd/tty.c
@@ -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);