File tree 3 files changed +13
-0
lines changed
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/).
16
16
- Added ` mq_timedreceive ` to ` ::nix::mqueue ` .
17
17
([ #1966 ] )(https://github.com/nix-rust/nix/pull/1966 )
18
18
- 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 ) )
19
21
20
22
### Changed
21
23
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ pub(crate) mod timer {
93
93
/// Flags that are used for arming the timer.
94
94
pub struct TimerSetTimeFlags : libc:: c_int {
95
95
const TFD_TIMER_ABSTIME = libc:: TFD_TIMER_ABSTIME ;
96
+ const TFD_TIMER_CANCEL_ON_SET = libc:: TFD_TIMER_CANCEL_ON_SET ;
96
97
}
97
98
}
98
99
#[ cfg( any(
Original file line number Diff line number Diff line change @@ -135,6 +135,13 @@ impl TimerFd {
135
135
/// Then the one shot TimeSpec and the delay TimeSpec of the delayed
136
136
/// interval are going to be interpreted as absolute.
137
137
///
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
+ ///
138
145
/// # Disabling alarms
139
146
///
140
147
/// Note: Only one alarm can be set for any given timer. Setting a new alarm
@@ -202,6 +209,9 @@ impl TimerFd {
202
209
/// Note: If the alarm is unset, then you will wait forever.
203
210
pub fn wait ( & self ) -> Result < ( ) > {
204
211
while let Err ( e) = read ( self . fd . as_fd ( ) . as_raw_fd ( ) , & mut [ 0u8 ; 8 ] ) {
212
+ if e == Errno :: ECANCELED {
213
+ break ;
214
+ }
205
215
if e != Errno :: EINTR {
206
216
return Err ( e) ;
207
217
}
You can’t perform that action at this time.
0 commit comments