summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2019-05-13 16:35:44 +0200
committerSimon Rettberg2019-05-13 16:35:44 +0200
commit902df6a04aeb776266e605fca782350627e3f802 (patch)
tree03e95e32ec593e647ecafb2a05a7ad595fe31e74 /src
parentSupport --min-idle (diff)
downloadidle-daemon-902df6a04aeb776266e605fca782350627e3f802.tar.gz
idle-daemon-902df6a04aeb776266e605fca782350627e3f802.tar.xz
idle-daemon-902df6a04aeb776266e605fca782350627e3f802.zip
Properly cap sleep after RPC call
Diffstat (limited to 'src')
-rw-r--r--src/main.c5
1 files changed, 5 insertions, 0 deletions
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 );