@@ -1860,31 +1860,35 @@ _dispatch_timers_get_delay(uint64_t nows[], struct dispatch_timer_s timer[],
18601860
18611861
18621862#ifdef __linux__
1863- // in linux we map the _dispatch_kevent_qos_s to struct kevent instead of struct kevent64.
1864- // we loose the kevent.ext[] members and the time out is based on relavite msec based time
1865- // vs. absolute nsec based time. For now we make the adjustments right here until the solution
1866- // to either extend libkqueue with a proper kevent64 API or removing kevent all together
1867- // and move to a lower API (e.g. epoll or kernel_module. Also leeway is ignored.
1863+ // in linux we map the _dispatch_kevent_qos_s to struct kevent instead
1864+ // of struct kevent64. We loose the kevent.ext[] members and the time
1865+ // out is based on relavite msec based time vs. absolute nsec based time.
1866+ // For now we make the adjustments right here until the solution
1867+ // to either extend libkqueue with a proper kevent64 API or removing kevent
1868+ // all together and move to a lower API (e.g. epoll or kernel_module.
1869+ // Also leeway is ignored.
18681870
18691871static void
1870- kevent_set_delay (_dispatch_kevent_qos_s * ke , uint64_t delay ,uint64_t leeway , uint64_t nows [])
1872+ _dispatch_kevent_timer_set_delay (_dispatch_kevent_qos_s * ke , uint64_t delay ,
1873+ uint64_t leeway , uint64_t nows [])
18711874{
1872- _dispatch_source_timer_now (nows , DISPATCH_TIMER_KIND_WALL ); // called to return nows[]
1873-
1875+ // call to return nows[]
1876+ _dispatch_source_timer_now (nows , DISPATCH_TIMER_KIND_WALL );
1877+ // adjust nsec based delay to msec based and ignore leeway
18741878 delay /= 1000000L ;
1875- if ((int64_t )(delay ) <= 0 )
1876- delay = 1 ; /* if he value is negative or 0 then the dispatch will stop */
1879+ if ((int64_t )(delay ) <= 0 ) {
1880+ delay = 1 ; // if value <= 0 the dispatch will stop
1881+ }
18771882 ke -> data = (int64_t )delay ;
18781883}
18791884
18801885#else
18811886
18821887static void
1883- kevent_set_delay (_dispatch_kevent_qos_s * ke , uint64_t delay ,uint64_t leeway , uint64_t nows [])
1888+ _dispatch_kevent_timer_set_delay (_dispatch_kevent_qos_s * ke , uint64_t delay ,
1889+ uint64_t leeway , uint64_t nows [])
18841890{
1885-
18861891 delay += _dispatch_source_timer_now (nows , DISPATCH_TIMER_KIND_WALL );
1887-
18881892 if (slowpath (_dispatch_timers_force_max_leeway )) {
18891893 ke -> data = (int64_t )(delay + leeway );
18901894 ke -> ext [1 ] = 0 ;
@@ -1918,12 +1922,10 @@ _dispatch_timers_program2(uint64_t nows[], _dispatch_kevent_qos_s *ke,
19181922 _dispatch_trace_next_timer_set (
19191923 TAILQ_FIRST (& _dispatch_kevent_timer [tidx ].dk_sources ), qos );
19201924 _dispatch_trace_next_timer_program (delay , qos );
1921-
1922- kevent_set_delay (ke ,delay ,leeway ,nows );
1925+ _dispatch_kevent_timer_set_delay (ke , delay , leeway , nows );
1926+ ke -> flags |= EV_ADD |EV_ENABLE ;
1927+ ke -> flags &= ~EV_DELETE ;
19231928 }
1924-
1925- ke -> flags |= EV_ADD |EV_ENABLE ;
1926- ke -> flags &= ~EV_DELETE ;
19271929 _dispatch_kq_update (ke );
19281930 return poll ;
19291931}
0 commit comments