]> git.ipfire.org Git - thirdparty/qemu.git/commit
nbd: take receive_mutex when reading requests[].receiving
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Apr 2022 17:57:55 +0000 (19:57 +0200)
committerEric Blake <eblake@redhat.com>
Tue, 26 Apr 2022 18:16:41 +0000 (13:16 -0500)
commita80a9a1c7397382fc4c4e6feaa8242b25cadb519
tree2f717189fe6409c22cdf0f9599c6ba10a3000032
parentdba5156c0e9c0362b7c6121f9e1c89bb9be1f227
nbd: take receive_mutex when reading requests[].receiving

requests[].receiving is set by nbd_receive_replies() under the receive_mutex;
Read it under the same mutex as well.  Waking up receivers on errors happens
after each reply finishes processing, in nbd_co_receive_one_chunk().
If there is no currently-active reply, there are two cases:

* either there is no active request at all, in which case no
element of request[] can have .receiving = true

* or nbd_receive_replies() must be running and owns receive_mutex;
in that case it will get back to nbd_co_receive_one_chunk() because
the socket has been shutdown, and all waiting coroutines will wake up
in turn.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20220414175756.671165-9-pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Lukas Straub <lukasstraub2@web.de>
Signed-off-by: Eric Blake <eblake@redhat.com>
block/nbd.c