File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1
1
use crossbeam_channel as channel;
2
2
use crossbeam_channel:: RecvTimeoutError ;
3
3
use std:: thread;
4
- use std:: time:: Duration ;
4
+ use std:: time:: { Duration , Instant } ;
5
5
6
6
use signal_hook:: consts:: { SIGINT , SIGTERM , SIGUSR1 } ;
7
7
@@ -34,14 +34,21 @@ impl Waiter {
34
34
] ) ,
35
35
}
36
36
}
37
+
37
38
pub fn wait ( & self , duration : Duration , accept_sigusr : bool ) -> Result < ( ) > {
38
- match self . receiver . recv_timeout ( duration) {
39
+ // Determine the deadline time based on the duration, so that it doesn't
40
+ // get pushed back when wait_deadline() recurses
41
+ self . wait_deadline ( Instant :: now ( ) + duration, accept_sigusr)
42
+ }
43
+
44
+ fn wait_deadline ( & self , deadline : Instant , accept_sigusr : bool ) -> Result < ( ) > {
45
+ match self . receiver . recv_deadline ( deadline) {
39
46
Ok ( sig) if sig == SIGUSR1 => {
40
47
trace ! ( "notified via SIGUSR1" ) ;
41
48
if accept_sigusr {
42
49
Ok ( ( ) )
43
50
} else {
44
- self . wait ( duration , accept_sigusr)
51
+ self . wait_deadline ( deadline , accept_sigusr)
45
52
}
46
53
}
47
54
Ok ( sig) => bail ! ( ErrorKind :: Interrupt ( sig) ) ,
You can’t perform that action at this time.
0 commit comments