Your RFC question is whether we can just check client->closing before
checking ret, and skip nbd_client_receive_next_request() in that case
(in other words, why even bother to queue up a coroutine that will do
nothing, if we already know the client is going away). And my answer is
yes, I think that makes more sense. So that would be:
diff --git c/nbd/server.c w/nbd/server.c
index 5f292064af0..b230ecb4fb8 100644
--- c/nbd/server.c
+++ w/nbd/server.c
@@ -1543,14 +1543,6 @@ static coroutine_fn void nbd_trip(void *opaque)
req = nbd_request_get(client);
ret = nbd_co_receive_request(req, &request, &local_err);
client->recv_coroutine = NULL;
- nbd_client_receive_next_request(client);
- if (ret == -EIO) {
- goto disconnect;
- }
-
- if (ret < 0) {
- goto reply;
- }
if (client->closing) {
/*
@@ -1560,6 +1552,15 @@ static coroutine_fn void nbd_trip(void *opaque)
goto done;
}
+ nbd_client_receive_next_request(client);
+ if (ret == -EIO) {
+ goto disconnect;
+ }
+
+ if (ret < 0) {
+ goto reply;
+ }
+
switch (request.type) {
case NBD_CMD_READ:
/* XXX: NBD Protocol only documents use of FUA with WRITE */
Unless this revised form fails testing or gets any other review
comments, I will go ahead and amend your commit in this manner.