Commit c1ef667
committed
libc: make timerfd_* functions handle wall clock jumps
When wall clock jumps backwards triggered for example by host clock
change and propagated through kvmclock synchronization mechanism
implemented by the commit e694d06,
timerfd::read() may see 'now' timepoint before the 'expiration' upon
wakeup event which is opposite to what the current implementation
expects and leads to broken assert crash.
This patch fixes the implementation of timerfd::read() by
differentiating between CLOCK_MONOTONIC and CLOCK_REALTIME
and handling the case when clock is realtime (wall clock)
and 'now' is before the 'expiration'. In which case we
simply re-arm to wake up at the 'expiration' + 'interval' timepoint.
Partially addresses #1076. Please note that we need to adjust
tst-timerfd to account for clock jumping forwards or backwards.
Signed-off-by: Waldemar Kozaczuk <jwkozaczuk@gmail.com>1 parent 752b6bb commit c1ef667
1 file changed
+16
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
| |||
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
204 | 212 | | |
205 | 213 | | |
206 | 214 | | |
| |||
0 commit comments