block/nbd: move from quit to state
commita34b1e5e06de777c0faaa78694c4e0775b2bef0c
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Tue, 18 Jun 2019 11:43:22 +0000 (18 14:43 +0300)
committerEric Blake <eblake@redhat.com>
Thu, 15 Aug 2019 18:22:14 +0000 (15 13:22 -0500)
tree4af65ffa1961f64ecf7ab84185ff1517116b042e
parenta8e2bb6a76c7c661c117327f70f06eb628554230
block/nbd: move from quit to state

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 <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190618114328.55249-4-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
block/nbd.c