[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 28/34] nbd/client-connection: return only one io channel
From: |
Eric Blake |
Subject: |
Re: [PULL 28/34] nbd/client-connection: return only one io channel |
Date: |
Fri, 18 Jun 2021 10:55:29 -0500 |
User-agent: |
NeoMutt/20210205 |
On Thu, Jun 17, 2021 at 09:32:02PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Logic is wrong and uninitialized use of ioc really possible, as Peter (and
> clang) reports.
>
> So, I propose the following squash-in. It doesn't conflict with following
> patches.
>
> squash-in:
>
> diff --git a/nbd/client-connection.c b/nbd/client-connection.c
> index 500b8591e8..396d7f17f0 100644
> --- a/nbd/client-connection.c
> +++ b/nbd/client-connection.c
> @@ -275,7 +275,6 @@ QIOChannel *coroutine_fn
> nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info,
> Error **errp)
> {
> - QIOChannel *ioc;
> QemuThread thread;
> if (conn->do_negotiation) {
> @@ -293,17 +292,19 @@ nbd_co_establish_connection(NBDClientConnection *conn,
> NBDExportInfo *info,
> if (conn->sioc) {
> /* Previous attempt finally succeeded in background */
> if (conn->do_negotiation) {
> - ioc = g_steal_pointer(&conn->ioc);
> memcpy(info, &conn->updated_info, sizeof(*info));
> + if (conn->ioc) {
> + /* TLS channel now has own reference to parent */
> + object_unref(OBJECT(conn->sioc));
> + conn->sioc = NULL;
> +
> + return g_steal_pointer(&conn->ioc);
> + }
> }
> - if (ioc) {
> - /* TLS channel now has own reference to parent */
> - object_unref(OBJECT(conn->sioc));
> - } else {
> - ioc = QIO_CHANNEL(conn->sioc);
> - }
> - conn->sioc = NULL;
> - return ioc;
> +
> + assert(!conn->ioc);
> +
> + return QIO_CHANNEL(g_steal_pointer(&conn->sioc));
Reviewed-by: Eric Blake <eblake@redhat.com>
I'll squash this in and send v2 of the pull request
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
- [PULL 21/34] nbd/client-connection: add possibility of negotiation, (continued)
- [PULL 21/34] nbd/client-connection: add possibility of negotiation, Eric Blake, 2021/06/15
- [PULL 19/34] nbd: move connection code from block/nbd to nbd/client-connection, Eric Blake, 2021/06/15
- [PULL 23/34] nbd/client-connection: shutdown connection on release, Eric Blake, 2021/06/15
- [PULL 25/34] block/nbd: use negotiation of NBDClientConnection, Eric Blake, 2021/06/15
- [PULL 26/34] block/nbd: don't touch s->sioc in nbd_teardown_connection(), Eric Blake, 2021/06/15
- [PULL 24/34] block/nbd: split nbd_handle_updated_info out of nbd_client_handshake(), Eric Blake, 2021/06/15
- [PULL 27/34] block/nbd: drop BDRVNBDState::sioc, Eric Blake, 2021/06/15
- [PULL 30/34] block/nbd: split nbd_co_do_establish_connection out of nbd_reconnect_attempt, Eric Blake, 2021/06/15
- [PULL 28/34] nbd/client-connection: return only one io channel, Eric Blake, 2021/06/15
- [PULL 31/34] nbd/client-connection: add option for non-blocking connection attempt, Eric Blake, 2021/06/15
- [PULL 29/34] block-coroutine-wrapper: allow non bdrv_ prefix, Eric Blake, 2021/06/15
- [PULL 33/34] block/nbd: add nbd_client_connected() helper, Eric Blake, 2021/06/15
- [PULL 32/34] block/nbd: reuse nbd_co_do_establish_connection() in nbd_open(), Eric Blake, 2021/06/15
- [PULL 34/34] block/nbd: safer transition to receiving request, Eric Blake, 2021/06/15
- Re: [PULL 00/34] NBD patches for 2021-06-15, Peter Maydell, 2021/06/17