summaryrefslogtreecommitdiffstats
path: root/src/rpc.c
diff options
context:
space:
mode:
authorSimon Rettberg2020-10-12 09:23:57 +0200
committerSimon Rettberg2020-10-12 09:23:57 +0200
commitd712d3b76d6c2507f1f9b81349bc9b8b780f7a5c (patch)
treef4fbb4d9ddf739fe3f1bf929ec6c9544e72da1d2 /src/rpc.c
parentFix potential strcmp() overflow, better packed struct for pipe (diff)
downloadidle-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.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/rpc.c b/src/rpc.c
index 28e4b2e..0689587 100644
--- a/src/rpc.c
+++ b/src/rpc.c
@@ -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 ) {