qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qemu-char: reset errno before qemu char write o


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH] qemu-char: reset errno before qemu char write or read action
Date: Sun, 1 Jul 2018 22:42:03 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 07/01/2018 09:49 PM, xinhua.Cao wrote:
> In the tcp_chr_write function, we checked errno,
> but errno was not reset before a read or write operation.
> Therefore, this check of errno's actions is often
> incorrect after EAGAIN has occurred.
> We reset errno before reading and writing to
> ensure the correctness of errno's judgment
> 
> Signed-off-by: xinhua.Cao <address@hidden>

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>

> ---
>  chardev/char-fe.c | 1 +
>  chardev/char.c    | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/chardev/char-fe.c b/chardev/char-fe.c
> index b1f228e..d96ca6f 100644
> --- a/chardev/char-fe.c
> +++ b/chardev/char-fe.c
> @@ -69,6 +69,7 @@ int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int 
> len)
>  
>      while (offset < len) {
>      retry:
> +        errno = 0;
>          res = CHARDEV_GET_CLASS(s)->chr_sync_read(s, buf + offset,
>                                                    len - offset);
>          if (res == -1 && errno == EAGAIN) {
> diff --git a/chardev/char.c b/chardev/char.c
> index 76d866e..3387442 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -85,6 +85,7 @@ static void qemu_chr_write_log(Chardev *s, const uint8_t 
> *buf, size_t len)
>  
>      while (done < len) {
>      retry:
> +        errno = 0;
>          ret = write(s->logfd, buf + done, len - done);
>          if (ret == -1 && errno == EAGAIN) {
>              g_usleep(100);
> @@ -109,6 +110,7 @@ static int qemu_chr_write_buffer(Chardev *s,
>      qemu_mutex_lock(&s->chr_write_lock);
>      while (*offset < len) {
>      retry:
> +        errno = 0;
>          res = cc->chr_write(s, buf + *offset, len - *offset);
>          if (res < 0 && errno == EAGAIN && write_all) {
>              g_usleep(100);
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]