serve: Allow number of clients currently being used to be counted

This commit is contained in:
nick
2013-09-23 13:37:13 +01:00
parent 94654419c5
commit a6c175ed1d
2 changed files with 17 additions and 0 deletions

View File

@@ -326,6 +326,20 @@ int cleanup_and_find_client_slot(struct server* params)
return slot; return slot;
} }
int server_count_clients( struct server *params )
{
NULLCHECK( params );
int i, count = 0;
for ( i = 0 ; i < params->max_nbd_clients ; i++ ) {
if ( params->nbd_client[i].thread != 0 ) {
count++;
}
}
return count;
}
/** Check whether the address client_address is allowed or not according /** Check whether the address client_address is allowed or not according
* to the current acl. If params->acl is NULL, the result will be 1, * to the current acl. If params->acl is NULL, the result will be 1,

View File

@@ -137,6 +137,9 @@ void server_close_clients( struct server *serve );
void server_join_clients( struct server *serve ); void server_join_clients( struct server *serve );
void server_allow_new_clients( struct server *serve ); void server_allow_new_clients( struct server *serve );
/* Returns a count (ish) of the number of currently-running client threads */
int server_count_clients( struct server *params );
void server_unlink( struct server * serve ); void server_unlink( struct server * serve );
int do_serve( struct server *, struct self_pipe * ); int do_serve( struct server *, struct self_pipe * );