[systemd-devel] Some thoughts about loop_read/loop_write in util.c

Lennart Poettering lennart at poettering.net
Thu Sep 12 05:36:44 PDT 2013


On Thu, 12.09.13 09:43, cee1 (fykcee1 at gmail.com) wrote:

> What about the following patch? It simply do read/write again if poll
> returns, and let read/write report error if something is wrong.

I guess that patch makes sense, but could you change it to not just
comment but delete the old lines? Also, could you add a comment there:

/* We knowingly ignore the revents value here, and expect that any
   error/EOF is reported via read()/write() */

> 
> >From 3b83e839ebfc161565db76ce8d0e1dd4da1b0afc Mon Sep 17 00:00:00 2001
> From: Chen Jie <chenj at lemote.com>
> Date: Thu, 12 Sep 2013 09:21:41 +0800
> Subject: [PATCH] util.c: not check pollfd.revent for loop_read/loop_write
> 
> If an error occurred, let read/write report it.
> ---
>  src/shared/util.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/shared/util.c b/src/shared/util.c
> index 1dde8af..e08ec44 100644
> --- a/src/shared/util.c
> +++ b/src/shared/util.c
> @@ -2206,8 +2206,10 @@ ssize_t loop_read(int fd, void *buf, size_t
> nbytes, bool do_poll) {
>                                          return n > 0 ? n : -errno;
>                                  }
> 
> +                                /*
>                                  if (pollfd.revents != POLLIN)
>                                          return n > 0 ? n : -EIO;
> +                                 */
> 
>                                  continue;
>                          }
> @@ -2254,8 +2256,10 @@ ssize_t loop_write(int fd, const void *buf,
> size_t nbytes, bool do_poll) {
>                                          return n > 0 ? n : -errno;
>                                  }
> 
> +                                /*
>                                  if (pollfd.revents != POLLOUT)
>                                          return n > 0 ? n : -EIO;
> +                                 */
> 
>                                  continue;
>                          }
> 
> 


Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list