File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1616- Added ` mq_timedreceive ` to ` ::nix::mqueue ` .
1717 ([ #1966 ] )(https://github.com/nix-rust/nix/pull/1966 )
1818- Added ` LocalPeerPid ` to ` nix::sys::socket::sockopt ` for macOS. ([ #1967 ] ( https://github.com/nix-rust/nix/pull/1967 ) )
19+ - Added ` TFD_TIMER_CANCEL_ON_SET ` to ` ::nix::sys::time::TimerSetTimeFlags ` on Linux and Android.
20+ ([ #2040 ] ( https://github.com/nix-rust/nix/pull/2040 ) )
1921
2022### Changed
2123
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ pub(crate) mod timer {
9393 /// Flags that are used for arming the timer.
9494 pub struct TimerSetTimeFlags : libc:: c_int {
9595 const TFD_TIMER_ABSTIME = libc:: TFD_TIMER_ABSTIME ;
96+ const TFD_TIMER_CANCEL_ON_SET = libc:: TFD_TIMER_CANCEL_ON_SET ;
9697 }
9798 }
9899 #[ cfg( any(
Original file line number Diff line number Diff line change @@ -135,6 +135,13 @@ impl TimerFd {
135135 /// Then the one shot TimeSpec and the delay TimeSpec of the delayed
136136 /// interval are going to be interpreted as absolute.
137137 ///
138+ /// # Cancel on a clock change
139+ ///
140+ /// If you set a `TFD_TIMER_CANCEL_ON_SET` alongside `TFD_TIMER_ABSTIME`
141+ /// and the clock for this timer is `CLOCK_REALTIME` or `CLOCK_REALTIME_ALARM`,
142+ /// then this timer is marked as cancelable if the real-time clock undergoes
143+ /// a discontinuous change.
144+ ///
138145 /// # Disabling alarms
139146 ///
140147 /// Note: Only one alarm can be set for any given timer. Setting a new alarm
@@ -202,6 +209,9 @@ impl TimerFd {
202209 /// Note: If the alarm is unset, then you will wait forever.
203210 pub fn wait ( & self ) -> Result < ( ) > {
204211 while let Err ( e) = read ( self . fd . as_fd ( ) . as_raw_fd ( ) , & mut [ 0u8 ; 8 ] ) {
212+ if e == Errno :: ECANCELED {
213+ break ;
214+ }
205215 if e != Errno :: EINTR {
206216 return Err ( e) ;
207217 }
You can’t perform that action at this time.
0 commit comments