Block a second mirror attempt
If a second mirror command is run while the first is still going, flexnbd needs to prevent the second because we only have one dirty map. Also, the shutdown becomes Complicated if we allow more than one mirror at a time.
This commit is contained in:
@@ -361,6 +361,11 @@ int control_mirror(struct control_client* client, int linesc, char** lines)
|
||||
flexnbd_lock_switch( flexnbd );
|
||||
{
|
||||
struct server * serve = flexnbd_server(flexnbd);
|
||||
|
||||
if ( serve->mirror_super ) {
|
||||
warn( "Tried to start a second mirror run" );
|
||||
write_socket( "1: mirror already running" );
|
||||
} else {
|
||||
serve->mirror_super = mirror_super_create(
|
||||
serve->filename,
|
||||
connect_to,
|
||||
@@ -385,6 +390,7 @@ int control_mirror(struct control_client* client, int linesc, char** lines)
|
||||
debug("Control thread writing response");
|
||||
control_write_mirror_response( state, client->socket );
|
||||
}
|
||||
}
|
||||
debug( "Control thread unlocking switch" );
|
||||
flexnbd_unlock_switch( flexnbd );
|
||||
debug( "Control thread going away." );
|
||||
|
Reference in New Issue
Block a user