]> git.ipfire.org Git - thirdparty/qemu.git/commit
nbd/server: do not poll within a coroutine context
authorZhu Yangyang <zhuyangyang14@huawei.com>
Mon, 8 Apr 2024 16:00:43 +0000 (11:00 -0500)
committerMichael Tokarev <mjt@tls.msk.ru>
Sun, 28 Apr 2024 12:13:13 +0000 (15:13 +0300)
commit304dc04347e15568e83c3482b9b3b9ce00b7e434
tree6a029cb6d6144b0a88fcfd455dfe6477ebe690ba
parentd6cdc6b29ad40623358023ad9d5b1c91303e3c7f
nbd/server: do not poll within a coroutine context

Coroutines are not supposed to block. Instead, they should yield.

The client performs TLS upgrade outside of an AIOContext, during
synchronous handshake; this still requires g_main_loop.  But the
server responds to TLS upgrade inside a coroutine, so a nested
g_main_loop is wrong.  Since the two callbacks no longer share more
than the setting of data.complete and data.error, it's just as easy to
use static helpers instead of trying to share a common code path.  It
is also possible to add assertions that no other code is interfering
with the eventual path to qio reaching the callback, whether or not it
required a yield or main loop.

Fixes: f95910f ("nbd: implement TLS support in the protocol negotiation")
Signed-off-by: Zhu Yangyang <zhuyangyang14@huawei.com>
[eblake: move callbacks to their use point, add assertions]
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20240408160214.1200629-5-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
(cherry picked from commit ae6d91a7e9b77abb029ed3fa9fad461422286942)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
nbd/client.c
nbd/common.c
nbd/nbd-internal.h
nbd/server.c