Merge branch 'fix-correct-num-clients-status' into 'develop'
Call the thread cleanup code when requesting `status` See merge request open-source/flexnbd-c!46
This commit is contained in:
2
debian/changelog
vendored
2
debian/changelog
vendored
@@ -21,6 +21,8 @@ flexnbd (0.2.0) UNRELEASED; urgency=medium
|
||||
calculating if a request exceeds the max block size (!45)
|
||||
* Added tests for setting TCP_NODELAY on upstream-reconnections in the
|
||||
proxy, and refactored the other LD_PRELOAD tests (!43)
|
||||
* Clean up dead threads before calculating the number of connected clients
|
||||
on the status command (!46)
|
||||
|
||||
-- James Carter <james.carter@bytemark.co.uk> Thu, 11 Jan 2018 10:05:35 +0000
|
||||
|
||||
|
@@ -332,6 +332,8 @@ int server_count_clients( struct server *params )
|
||||
{
|
||||
NULLCHECK( params );
|
||||
int i, count = 0;
|
||||
|
||||
cleanup_client_threads( params->nbd_client, params->max_nbd_clients );
|
||||
|
||||
for ( i = 0 ; i < params->max_nbd_clients ; i++ ) {
|
||||
if ( params->nbd_client[i].thread != 0 ) {
|
||||
|
@@ -207,4 +207,17 @@ class TestServeMode < Test::Unit::TestCase
|
||||
'TCP keepalive count not set to 3')
|
||||
end
|
||||
end
|
||||
|
||||
def test_status_returns_correct_client_count
|
||||
@env.writefile1('0')
|
||||
@env.serve1
|
||||
assert_equal('0', @env.status1['num_clients'])
|
||||
client = FlexNBD::FakeSource.new(@env.ip, @env.port1, 'Connecting to server failed')
|
||||
assert_equal('1', @env.status1['num_clients'])
|
||||
client2 = FlexNBD::FakeSource.new(@env.ip, @env.port1, 'Connecting to server failed')
|
||||
assert_equal('2', @env.status1['num_clients'])
|
||||
client2.close
|
||||
client.close
|
||||
assert_equal('0', @env.status1['num_clients'])
|
||||
end
|
||||
end
|
||||
|
@@ -105,25 +105,6 @@ START_TEST( test_gets_clients_allowed )
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST( test_gets_num_clients )
|
||||
{
|
||||
struct server * server = mock_server();
|
||||
struct status * status = status_create( server );
|
||||
|
||||
fail_if( status->num_clients != 0, "num_clients was wrong" );
|
||||
status_destroy( status );
|
||||
|
||||
server->nbd_client[0].thread = 1;
|
||||
server->nbd_client[1].thread = 1;
|
||||
status = status_create( server );
|
||||
|
||||
fail_unless( status->num_clients == 2, "num_clients was wrong" );
|
||||
status_destroy( status );
|
||||
destroy_mock_server( server );
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST( test_gets_pid )
|
||||
{
|
||||
struct server * server = mock_server();
|
||||
@@ -357,7 +338,6 @@ Suite *status_suite(void)
|
||||
tcase_add_test(tc_create, test_gets_has_control);
|
||||
tcase_add_test(tc_create, test_gets_is_mirroring);
|
||||
tcase_add_test(tc_create, test_gets_clients_allowed);
|
||||
tcase_add_test(tc_create, test_gets_num_clients);
|
||||
tcase_add_test(tc_create, test_gets_pid);
|
||||
tcase_add_test(tc_create, test_gets_size);
|
||||
tcase_add_test(tc_create, test_gets_migration_statistics);
|
||||
|
Reference in New Issue
Block a user