On 6/18/19 6:43 AM, Vladimir Sementsov-Ogievskiy wrote: > To implement reconnect we need several states for the client: > CONNECTED, QUIT and two different CONNECTING states. CONNECTING states > will be added in the following patches. This patch implements CONNECTED > and QUIT. > > QUIT means, that we should close the connection and fail all current > and further requests (like old quit = true). > > CONNECTED means that connection is ok, we can send requests (like old > quit = false). > > For receiving loop we use a comparison of the current state with QUIT, > because reconnect will be in the same loop, so it should be looping > until the end. > > Opposite, for requests we use a comparison of the current state with > CONNECTED, as we don't want to send requests in future CONNECTING > states. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> > Reviewed-by: Eric Blake <[email protected]> > --- > block/nbd.c | 58 ++++++++++++++++++++++++++++++++++------------------- > 1 file changed, 37 insertions(+), 21 deletions(-)
> @@ -556,7 +572,7 @@ static coroutine_fn int nbd_co_do_receive_one_chunk(
> s->requests[i].receiving = true;
> qemu_coroutine_yield();
> s->requests[i].receiving = false;
> - if (s->quit) {
> + if (s->state != NBD_CLIENT_CONNECTED) {
> error_setg(errp, "Connection closed");
> return -EIO;
> }
> @@ -640,7 +656,7 @@ static coroutine_fn int nbd_co_receive_one_chunk(
> request_ret, qiov, payload, errp);
>
> if (ret < 0) {
> - s->quit = true;
> + nbd_channel_error(s, ret);
Minor merge conflict with changes in the meantime; easy enough to sort out.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
