Call the thread cleanup code when requesting status
This ensures the correct number of connected clients is returned when the status command is issued. Previously the thread pool would only be cleaned up on a new connection.
This commit is contained in:
@@ -332,6 +332,8 @@ int server_count_clients( struct server *params )
|
|||||||
{
|
{
|
||||||
NULLCHECK( params );
|
NULLCHECK( params );
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
|
|
||||||
|
cleanup_client_threads( params->nbd_client, params->max_nbd_clients );
|
||||||
|
|
||||||
for ( i = 0 ; i < params->max_nbd_clients ; i++ ) {
|
for ( i = 0 ; i < params->max_nbd_clients ; i++ ) {
|
||||||
if ( params->nbd_client[i].thread != 0 ) {
|
if ( params->nbd_client[i].thread != 0 ) {
|
||||||
|
@@ -207,4 +207,14 @@ class TestServeMode < Test::Unit::TestCase
|
|||||||
'TCP keepalive count not set to 3')
|
'TCP keepalive count not set to 3')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_status_returns_correct_client_count
|
||||||
|
require 'pp'
|
||||||
|
connect_to_server do |client|
|
||||||
|
status = @env.status1
|
||||||
|
assert_equal('1', status['num_clients'])
|
||||||
|
end
|
||||||
|
status = @env.status1
|
||||||
|
assert_equal('0', status['num_clients'])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user