diff --git a/debian/changelog b/debian/changelog index e79dead..6c33cdc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ flexnbd (0.4.0) UNRELEASED; urgency=medium * Explicitly close the server control socket, and wait for it to close, to prevent deadlocks during the server clean-up process (#40 !58) + * Ensure mirroring can be restarted after a break command is sent to the + source (#37, !59) -- Patrick J Cherry Fri, 07 Dec 2018 16:38:56 +0000 diff --git a/src/server/mirror.c b/src/server/mirror.c index b1d917b..75bf3f5 100644 --- a/src/server/mirror.c +++ b/src/server/mirror.c @@ -671,6 +671,7 @@ static void mirror_abandon_cb(struct ev_loop *loop, ev_io * w, int revents) debug("Abandon message received"); mirror_set_state(ctrl->mirror, MS_ABANDONED); self_pipe_signal_clear(ctrl->mirror->abandon_signal); + ev_io_stop(loop, &ctrl->abandon_watcher); ev_break(loop, EVBREAK_ONE); return; } diff --git a/tests/acceptance/test_write_during_migration.rb b/tests/acceptance/test_write_during_migration.rb index 70ef9e6..96ba97d 100755 --- a/tests/acceptance/test_write_during_migration.rb +++ b/tests/acceptance/test_write_during_migration.rb @@ -86,6 +86,14 @@ class TestWriteDuringMigration < Test::Unit::TestCase end end + def stop_mirror + UNIXSocket.open(@source_sock) do |sock| + sock.write("break\x0A\x0A") + sock.flush + sock.readline + end + end + def wait_for_quit Timeout.timeout(10) do Process.waitpid2(@dst_proc) @@ -177,7 +185,6 @@ class TestWriteDuringMigration < Test::Unit::TestCase end end - def test_status_call_after_cleanup Dir.mktmpdir do |tmpdir| Dir.chdir(tmpdir) do @@ -195,4 +202,28 @@ class TestWriteDuringMigration < Test::Unit::TestCase end end end + + def test_mirroring_can_be_restarted + @size = 100 * 1024 * 1024 # 100MB + Dir.mktmpdir do |tmpdir| + Dir.chdir(tmpdir) do + make_files + + launch_servers + + # This is a bit racy. It needs to be slow enough that the migration + # isn't finished before the stop runs, and slow enough so that we can + # stop/start a few times. + 3.times do + start_mirror + sleep 0.1 + stop_mirror + sleep 0.1 + end + start_mirror + + wait_for_quit + end + end + end end