Skip to content
  • Ben Gamari's avatar
    f454c0ea
    rts/OSThreads: Fix reference clock of timedWaitCondition · f454c0ea
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    Previously `timedWaitCondition` assumed that timeouts were referenced
    against `CLOCK_MONOTONIC`. This is wrong; by default
    `pthread_cond_timedwait` references against `CLOCK_REALTIME`, although
    this can be overridden using `pthread_condattr_setclock`.
    
    Fix this and add support for using `CLOCK_MONOTONIC` whenever possible
    as it is more robust against system time changes and is likely cheaper
    to query. Unfortunately, this is complicated by the fact that older
    versions of Darwin did not provide `clock_gettime`, which means we also
    need to introduce a fallback path using `gettimeofday`.
    
    Fixes #20144.
    f454c0ea
    rts/OSThreads: Fix reference clock of timedWaitCondition
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    Previously `timedWaitCondition` assumed that timeouts were referenced
    against `CLOCK_MONOTONIC`. This is wrong; by default
    `pthread_cond_timedwait` references against `CLOCK_REALTIME`, although
    this can be overridden using `pthread_condattr_setclock`.
    
    Fix this and add support for using `CLOCK_MONOTONIC` whenever possible
    as it is more robust against system time changes and is likely cheaper
    to query. Unfortunately, this is complicated by the fact that older
    versions of Darwin did not provide `clock_gettime`, which means we also
    need to introduce a fallback path using `gettimeofday`.
    
    Fixes #20144.
Loading