On Wed, 11.09.13 21:50, cee1 (fykc...@gmail.com) wrote:

> Hi all,
> 
> loop_read/loop_write:
> http://cgit.freedesktop.org/systemd/systemd/tree/src/shared/util.c#n2179
> 
> In a scenario of pipes, loop_read on read side, if the write side is
> closed, loop_read will return 0 if do_poll is false(let's assume no
> data available to read). When do_poll is true, it will return:
> 1) 0, if write side is closed while loop_read is just doing a read
> 2) or -EIO when poll returns pollfd.revent with POLLHUP flag set
> 
> The behavior is not very consistent.
> IMHO, it's preferred loop_read follows read behavior as much as
> possible -- returns 0 to indicate end of a file here, e.g. We can try
> to read 0 bytes when pollfd.revents != POLLIN.

EOF and temporarily not being able to read more data is something very
different. 

It might make sense to return EAGAIN if POLLHUP is set though.

(But note that POLLHUP has more complex semantics when combined with
shutdown() and half-open connections...)

> The same with loop_write.

EOF doesn't exist for loop_write(), so this is even weirder....

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to