Due to an NBD protocol limitation, the status code for erofs_nbd_send_reply_header() has already been sent before the data arrives.
A better solution will be considered later. Signed-off-by: Gao Xiang <[email protected]> --- mount/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mount/main.c b/mount/main.c index d98e1e9..ccf4193 100644 --- a/mount/main.c +++ b/mount/main.c @@ -596,11 +596,9 @@ static void *erofsmount_nbd_loopfn(void *arg) erofs_nbd_send_reply_header(ctx->sk.fd, rq.cookie, 0); pos = rq.from; - rem = erofs_io_sendfile(&ctx->sk, &ctx->vd, &pos, rq.len); - if (rem < 0) { - err = -errno; - break; - } + do { + rem = erofs_io_sendfile(&ctx->sk, &ctx->vd, &pos, rq.len); + } while (rem < 0); err = __erofs_0write(ctx->sk.fd, rem); if (err) { if (err > 0) -- 2.43.5
