mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 02:24:51 +00:00
nbd: Avoid deadlock in client connecting to same-process server
See the previous patch for a longer description of the deadlock. Now that QIONetListener supports waiting for clients in the main loop AioContext, NBD can use that to ensure that the server can make progress even when a client is intentionally starving the GMainContext from any activity not tied to an AioContext. Note that command-line arguments and QMP commands like nbd-server-start or nbd-server-stop that manipulate whether the NBD server exists are serviced in the main loop; and therefore, this patch does not fall foul of the restrictions in the previous patch about the inherent unsafe race possible if a QIONetListener can have its async callback modified by a different thread than the one servicing polls. Fixes: https://gitlab.com/qemu-project/qemu/-/issues/3169 Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20251113011625.878876-27-eblake@redhat.com>
This commit is contained in:
@@ -94,10 +94,10 @@ static void nbd_update_server_watch(NBDServerData *s)
|
|||||||
{
|
{
|
||||||
if (s->listener) {
|
if (s->listener) {
|
||||||
if (!s->max_connections || s->connections < s->max_connections) {
|
if (!s->max_connections || s->connections < s->max_connections) {
|
||||||
qio_net_listener_set_client_func(s->listener, nbd_accept, NULL,
|
qio_net_listener_set_client_aio_func(s->listener, nbd_accept, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
} else {
|
} else {
|
||||||
qio_net_listener_set_client_func(s->listener, NULL, NULL, NULL);
|
qio_net_listener_set_client_aio_func(s->listener, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user