From 600e1c92fd3e3e576fa8978473d956911e874b09 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 14 Jan 2022 13:19:30 +0100 Subject: Cap sleep time to 5 after RPC activity --- src/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 316aec5..138713f 100644 --- a/src/main.c +++ b/src/main.c @@ -316,9 +316,12 @@ int main( int argc, char **argv ) //printf( "Sleeping %d seconds\n ", sn ); if ( rpc_wait( listenFd, sn < 1 ? 1 : sn ) ) { rpc_handle( listenFd ); - // Might have set a new scheduled action, run main loop again if ( nextAction.deadline != oldDeadline ) { + // Might have set a new scheduled action, run main loop again soon CAP_SLEEP( 1 ); + } else { + // Otherwise, still update rather quickly, in case we get polled again + CAP_SLEEP( 5 ); } } // Detect time changes @@ -329,6 +332,7 @@ int main( int argc, char **argv ) // Adjust for clock changes const int diff = ( endWall - startWall ) - ( endMono - startMono ); if ( diff != 0 ) { + printf( "Correcting time by %d seconds\n", diff ); for ( idx = 0; idx < count; ++idx ) { if ( users[idx].display[0] == '\0' ) continue; -- cgit v1.2.3-55-g7522