From 0c4a63c894fb20eefe72a78789931fe02b6d8d18 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 6 Oct 2017 12:18:19 +0200 Subject: [SERVER] Return client count when requesting stats but not client list --- src/server/rpc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/server/rpc.c') diff --git a/src/server/rpc.c b/src/server/rpc.c index 782c6b8..138e94b 100644 --- a/src/server/rpc.c +++ b/src/server/rpc.c @@ -122,7 +122,7 @@ static bool handleStatus(int sock, const char *request, int permissions) // Call this first because it will update the total bytes sent counter json_t *jsonClients = NULL; if ( stats || clients ) { - jsonClients = net_clientsToJson( permissions & ACL_CLIENT_LIST ); + jsonClients = net_clientsToJson( clients ); } const int uptime = dnbd3_serverUptime(); json_t *statisticsJson; @@ -137,8 +137,12 @@ static bool handleStatus(int sock, const char *request, int permissions) statisticsJson = json_pack( "{sI}", "uptime", (json_int_t) uptime ); } - if ( clients ) { - json_object_set_new( statisticsJson, "clients", jsonClients ); + if ( jsonClients != NULL ) { + if ( clients ) { + json_object_set_new( statisticsJson, "clients", jsonClients ); + } else if ( stats ) { + json_object_set_new( statisticsJson, "clientCount", jsonClients ); + } } if ( images ) { json_object_set_new( statisticsJson, "images", image_getListAsJson() ); -- cgit v1.2.3-55-g7522