From 70a3a4bb55e621947f2eac4af99f5a6c41dcd03a Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 7 Dec 2018 15:02:55 +0000 Subject: [PATCH] Close the control socket during cleanup This should prevent further requests coming in, triggering deadlocks. --- src/server/serve.c | 14 +++++--------- tests/acceptance/test_write_during_migration.rb | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/server/serve.c b/src/server/serve.c index e5cc588..af7afb4 100644 --- a/src/server/serve.c +++ b/src/server/serve.c @@ -827,6 +827,11 @@ void serve_cleanup(struct server *params, close(params->server_fd); } + /* close the control socket too */ + if (params->flexnbd && params->flexnbd->control) { + control_signal_close(params->flexnbd->control); + } + /* need to stop background build if we're killed very early on */ pthread_cancel(params->allocation_map_builder_thread); pthread_join(params->allocation_map_builder_thread, &status); @@ -861,15 +866,6 @@ void serve_cleanup(struct server *params, server_unlock_acl(params); } - /* if( params->flexnbd ) { */ - /* if ( params->flexnbd->control ) { */ - /* flexnbd_stop_control( params->flexnbd ); */ - /* } */ - /* flexnbd_destroy( params->flexnbd ); */ - /* } */ - - /* server_destroy( params ); */ - debug("Cleanup done"); } diff --git a/tests/acceptance/test_write_during_migration.rb b/tests/acceptance/test_write_during_migration.rb index 053fcc2..70ef9e6 100755 --- a/tests/acceptance/test_write_during_migration.rb +++ b/tests/acceptance/test_write_during_migration.rb @@ -114,7 +114,7 @@ class TestWriteDuringMigration < Test::Unit::TestCase sock.flush sock.readline end - rescue Errno::ENOENT + rescue StandardError # If the socket disappears, that's OK. break end