migration/socket: Close the listener at the end

Delay closing the listener until the cleanup hook at the end; mptcp
needs the listener to stay open while the other paths come in.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20210421112834.107651-5-dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
Dr. David Alan Gilbert 2021-04-21 12:28:33 +01:00
parent 1df6ddb43b
commit a59136f3b1
2 changed files with 23 additions and 6 deletions

View File

@ -1166,6 +1166,11 @@ bool multifd_recv_all_channels_created(void)
return true;
}
if (!multifd_recv_state) {
/* Called before any connections created */
return false;
}
return thread_count == qatomic_read(&multifd_recv_state->count);
}

View File

@ -126,22 +126,31 @@ static void socket_accept_incoming_migration(QIONetListener *listener,
{
trace_migration_socket_incoming_accepted();
if (migration_has_all_channels()) {
error_report("%s: Extra incoming migration connection; ignoring",
__func__);
return;
}
qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming");
migration_channel_process_incoming(QIO_CHANNEL(cioc));
if (migration_has_all_channels()) {
/* Close listening socket as its no longer needed */
qio_net_listener_disconnect(listener);
object_unref(OBJECT(listener));
}
}
static void
socket_incoming_migration_end(void *opaque)
{
QIONetListener *listener = opaque;
qio_net_listener_disconnect(listener);
object_unref(OBJECT(listener));
}
static void
socket_start_incoming_migration_internal(SocketAddress *saddr,
Error **errp)
{
QIONetListener *listener = qio_net_listener_new();
MigrationIncomingState *mis = migration_incoming_get_current();
size_t i;
int num = 1;
@ -156,6 +165,9 @@ socket_start_incoming_migration_internal(SocketAddress *saddr,
return;
}
mis->transport_data = listener;
mis->transport_cleanup = socket_incoming_migration_end;
qio_net_listener_set_client_func_full(listener,
socket_accept_incoming_migration,
NULL, NULL,