From 902df6a04aeb776266e605fca782350627e3f802 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 13 May 2019 16:35:44 +0200 Subject: Properly cap sleep after RPC call --- src/main.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/main.c b/src/main.c index cd18aa4..2dd433e 100644 --- a/src/main.c +++ b/src/main.c @@ -281,6 +281,11 @@ int main( int argc, char **argv ) } // Handle requests rpcHandle( listenFd ); + // Might have set a new scheduled action + if ( nextAction.deadline != 0 && ( count == 0 || minIdleTime >= config.minIdle || nextAction.force ) ) { + int delta = nextAction.deadline - monoNOW; + CAP_SLEEP( delta ); + } // Sleep until next run //printf( "Sleeping %d seconds\n ", sleepTime ); rpcWait( listenFd, sleepTime > 5 ? sleepTime : 5 ); -- cgit v1.2.3-55-g7522