> On Thu, Apr 23, 2020 at 8:43 PM Dima Stepanov <dimas...@yandex-team.ru> wrote: >> The problem is that vhost_user_write doesn't get an error after >> disconnect and try to call vhost_user_read(). The tcp_chr_write() >> routine should return -1 in case of disconnect. Indicate the EIO error >> if this routine is called in the disconnected state. >> >> Signed-off-by: Dima Stepanov <dimas...@yandex-team.ru> >> --- >> chardev/char-socket.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/chardev/char-socket.c b/chardev/char-socket.c >> index 185fe38..c128cca 100644 >> --- a/chardev/char-socket.c >> +++ b/chardev/char-socket.c >> @@ -175,14 +175,16 @@ static int tcp_chr_write(Chardev *chr, const uint8_t >> *buf, int len) >> if (ret < 0 && errno != EAGAIN) { >> if (tcp_chr_read_poll(chr) <= 0) { >> tcp_chr_disconnect_locked(chr); >> - return len; >> + /* Return an error since we made a disconnect. */ >> + return ret; > > Looks ok, but this return was introduced in commit > b0a335e351103bf92f3f9d0bd5759311be8156ac ("qemu-char: socket backend: > disconnect on write error"). It doesn't say why it didn't return -1 > though. Anton, could you review? thanks >
hej, I think I had no special intent but to repeat the behaviour as in the snippet below, that is to return @len when the socket is disconnected. Seems that tcp_chr_write() worked that way since the very beginning (commit 0bab00f). It looks ok to me to return an error though. If some guest device doesnt expect that I guess it should ignore the error on its side. >> } /* else let the read handler finish it properly */ >> } >> >> return ret; >> } else { >> - /* XXX: indicate an error ? */ >> - return len; >> + /* Indicate an error. */ >> + errno = EIO; >> + return -1; >> } >> }