File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 11use crossbeam_channel as channel;
22use crossbeam_channel:: RecvTimeoutError ;
33use std:: thread;
4- use std:: time:: Duration ;
4+ use std:: time:: { Duration , Instant } ;
55
66use signal_hook:: consts:: { SIGINT , SIGTERM , SIGUSR1 } ;
77
@@ -34,14 +34,21 @@ impl Waiter {
3434 ] ) ,
3535 }
3636 }
37+
3738 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) {
3946 Ok ( sig) if sig == SIGUSR1 => {
4047 trace ! ( "notified via SIGUSR1" ) ;
4148 if accept_sigusr {
4249 Ok ( ( ) )
4350 } else {
44- self . wait ( duration , accept_sigusr)
51+ self . wait_deadline ( deadline , accept_sigusr)
4552 }
4653 }
4754 Ok ( sig) => bail ! ( ErrorKind :: Interrupt ( sig) ) ,
You can’t perform that action at this time.
0 commit comments