diff options
author | Simon Rettberg | 2020-10-12 09:23:57 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-10-12 09:23:57 +0200 |
commit | d712d3b76d6c2507f1f9b81349bc9b8b780f7a5c (patch) | |
tree | f4fbb4d9ddf739fe3f1bf929ec6c9544e72da1d2 /src/rpc.c | |
parent | Fix potential strcmp() overflow, better packed struct for pipe (diff) | |
download | idle-daemon-d712d3b76d6c2507f1f9b81349bc9b8b780f7a5c.tar.gz idle-daemon-d712d3b76d6c2507f1f9b81349bc9b8b780f7a5c.tar.xz idle-daemon-d712d3b76d6c2507f1f9b81349bc9b8b780f7a5c.zip |
Add usercount to RPC, simplify timing calculation
Diffstat (limited to 'src/rpc.c')
-rw-r--r-- | src/rpc.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -68,15 +68,17 @@ int rpc_open( void ) return fd; } -void rpc_wait( int listenFd, int seconds ) +bool rpc_wait( int listenFd, int seconds ) { struct pollfd pd[2] = { { .fd = listenFd, .events = POLLIN | POLLHUP | POLLRDHUP }, { .fd = rpcPipe.read, .events = POLLIN | POLLHUP | POLLRDHUP }, }; - if ( poll( pd, 2, seconds * 1000 ) == -1 ) { + int ret = poll( pd, 2, seconds * 1000 ); + if ( ret == -1 ) { perror( "Error polling RPC sockets" ); } + return ret > 0; } void rpc_handle( int listenFd ) @@ -167,11 +169,13 @@ static void handleClient( int fd, struct ucred *creds ) // 1) Global state time_t deadline; const char *name = "none"; - main_getStatus( &name, &deadline ); + int userCount; + main_getStatus( &name, &deadline, &userCount ); fprintf( s, "[General]\n" "nextAction=%s\n" - "nextActionTime=%lld\n", - name, (long long)deadline ); + "nextActionTime=%lld\n" + "userCount=%d\n", + name, (long long)deadline, userCount ); // 2) Requested sessions char *tok = strtok( buffer + 4, " \t\n\r" ); while ( tok != NULL ) { |