]> git.ipfire.org Git - thirdparty/tvheadend.git/commit
Use clock_gettime() instead of time() in epggrab.c
authorMichael Marley <michael@michaelmarley.com>
Sat, 11 Dec 2021 23:09:47 +0000 (18:09 -0500)
committerFlole998 <Flole998@users.noreply.github.com>
Sun, 12 Dec 2021 22:06:16 +0000 (23:06 +0100)
commit9ed7d10ac2e895080d08587048ac5a24a2f9fae3
tree2289b3138204555fac555e2ccebd41f7d8bd898c
parentb8710206eb073c72b142bce95846b77a0ffa34a6
Use clock_gettime() instead of time() in epggrab.c

time() appears to return a slightly-rounded value as compared to
functions that return higher-precision time like gettimeofday() and
timespec_get().  Specifically, when gettimeofday() would return a
value with a low number in tv_usec, time() will return one fewer
seconds than tv_sec from gettimeofday().  The difference is minute
and probably doesn't cause an issue in most cases, but here in
epggrab.c the time of the next cron run is calculated immediately
after the previous run fires.  In this case, the value of time()
is actually one second lower than the specified cron run time. This
value is then passed into cron_multi_next(), which correctly sets
the next cron run to the current time.  Therefore, as soon as the
EPG grab completes, cron triggers again and re-runs it.  Using the
more precise values from gettimeofday() (by way of clock_gettime())
solves this problem and ensures that cron runs only once.

This solves #5545 and #5364.
src/epggrab.c