diff options
Diffstat (limited to 'block/nbd.c')
-rw-r--r-- | block/nbd.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/block/nbd.c b/block/nbd.c index 1b0e384c39..e0af5b4725 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -151,10 +151,18 @@ static void nbd_reply_ready(void *opaque) { BDRVNBDState *s = opaque; uint64_t i; + int ret; if (s->reply.handle == 0) { - /* No reply already in flight. Fetch a header. */ - if (nbd_receive_reply(s->sock, &s->reply) < 0) { + /* No reply already in flight. Fetch a header. It is possible + * that another thread has done the same thing in parallel, so + * the socket is not readable anymore. + */ + ret = nbd_receive_reply(s->sock, &s->reply); + if (ret == -EAGAIN) { + return; + } + if (ret < 0) { s->reply.handle = 0; goto fail; } |