@@ -1084,26 +1084,20 @@ impl State {
10841084 return Err ( Error :: invalid ( "test timer exceeds one day" ) . into ( ) ) ;
10851085 }
10861086 let slot = self . views . slot ( & input. view ) ?;
1087- let monitor = self
1087+ if ! self
10881088 . monitors
10891089 . lock ( )
10901090 . map_err ( |_| Error :: corrupt ( "monitor registry poisoned" ) ) ?
1091- . get ( & input. view )
1092- . cloned ( )
1093- . ok_or_else ( || Error :: invalid ( "view has no monitor" ) ) ?;
1091+ . contains_key ( & input. view )
10941092 {
1095- let mut monitor = monitor
1096- . lock ( )
1097- . map_err ( |_| Error :: corrupt ( "monitor poisoned" ) ) ?;
1098- let now = Instant :: now ( ) ;
1099- monitor. last_reconcile = now
1100- . checked_sub ( Duration :: from_millis ( input. elapsed_ms ) )
1101- . ok_or_else ( || Error :: invalid ( "test timer is out of range" ) ) ?;
1102- monitor. last_schedule = now
1103- . checked_sub ( Duration :: from_secs ( 30 ) )
1104- . ok_or_else ( || Error :: invalid ( "test retry timer is out of range" ) ) ?;
1093+ return Err ( Error :: invalid ( "view has no monitor" ) . into ( ) ) ;
11051094 }
1106- self . schedule_view ( & slot) ?;
1095+ self . schedule_view_with_elapsed ( & slot, |_| {
1096+ (
1097+ Duration :: from_secs ( 30 ) ,
1098+ Duration :: from_millis ( input. elapsed_ms ) ,
1099+ )
1100+ } ) ?;
11071101 Ok ( json ! ( { "input_epoch" : slot. input_epoch( ) } ) )
11081102 }
11091103 #[ cfg( feature = "managed-test-hooks" ) ]
@@ -1468,6 +1462,19 @@ impl State {
14681462 }
14691463
14701464 fn schedule_view ( & self , slot : & Arc < ViewSlot > ) -> Result < ( ) > {
1465+ self . schedule_view_with_elapsed ( slot, |monitor| {
1466+ (
1467+ monitor. last_schedule . elapsed ( ) ,
1468+ monitor. last_reconcile . elapsed ( ) ,
1469+ )
1470+ } )
1471+ }
1472+
1473+ fn schedule_view_with_elapsed (
1474+ & self ,
1475+ slot : & Arc < ViewSlot > ,
1476+ elapsed : impl FnOnce ( & Monitor ) -> ( Duration , Duration ) ,
1477+ ) -> Result < ( ) > {
14711478 let status = self . views . status ( slot. id ( ) ) ?;
14721479 if status. leases == 0 {
14731480 return Ok ( ( ) ) ;
@@ -1526,10 +1533,9 @@ impl State {
15261533 return Ok ( ( ) ) ;
15271534 }
15281535 let retry = Duration :: from_millis ( 200_u64 . saturating_mul ( 1_u64 << monitor. failures . min ( 7 ) ) ) ;
1529- let elapsed = monitor. last_schedule . elapsed ( ) ;
1530- let periodic = self . watches . polling ( & monitor)
1531- && monitor. last_reconcile . elapsed ( ) >= self . watches . interval ;
1532- if ( !status. ready || periodic) && elapsed >= retry {
1536+ let ( schedule_elapsed, reconcile_elapsed) = elapsed ( & monitor) ;
1537+ let periodic = self . watches . polling ( & monitor) && reconcile_elapsed >= self . watches . interval ;
1538+ if ( !status. ready || periodic) && schedule_elapsed >= retry {
15331539 monitor. last_schedule = Instant :: now ( ) ;
15341540 drop ( monitor) ;
15351541 if periodic {
@@ -1545,7 +1551,7 @@ impl State {
15451551 ) ?;
15461552 self . enqueue ( & operation) ?;
15471553 } else if status. ready
1548- && elapsed >= retry
1554+ && schedule_elapsed >= retry
15491555 && matches ! (
15501556 self . namespace. policy( ) ?. policy. advancement,
15511557 managed:: policy:: Advancement :: Adaptive { .. }
0 commit comments