Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Jeff King
On Tue, Sep 22, 2015 at 05:14:42PM -0700, Stefan Beller wrote: > We should not care if the call to poll failed, as we're in an infinite loop > and > can only get out with the correct read(..). So maybe an implementation like > this > would already suffice: > > ssize_t xread(int fd, void *buf, s

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Junio C Hamano
Stefan Beller writes: > We should not care if the call to poll failed, as we're in an infinite loop > and > can only get out with the correct read(..). I think I agree with that reasoning. The only thing we want out of this call to poll(2) is to delay calling read(2) again when we know we woul

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Stefan Beller
On Tue, Sep 22, 2015 at 1:00 PM, Junio C Hamano wrote: > Jeff King writes: > >> On Tue, Sep 22, 2015 at 12:45:51PM -0700, Junio C Hamano wrote: >> >>> One caveat is that the caller may not know in the first place. >>> >>> The last time I checked the existing callers of xread(), there were >>> a f

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Junio C Hamano
Jeff King writes: > On Tue, Sep 22, 2015 at 12:45:51PM -0700, Junio C Hamano wrote: > >> One caveat is that the caller may not know in the first place. >> >> The last time I checked the existing callers of xread(), there were >> a few that read from a file descriptor they did not open themselves

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Jeff King
On Tue, Sep 22, 2015 at 12:45:51PM -0700, Junio C Hamano wrote: > Jacob Keller writes: > > > I don't think this patch actually changes behavior as it stands now. I > > think Junio's suggestion does. Personally, I'd prefer some sort of > > warning when you use xread and get EAGAIN or EWOULDBLOCK.

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Junio C Hamano
Jacob Keller writes: > I don't think this patch actually changes behavior as it stands now. I > think Junio's suggestion does. Personally, I'd prefer some sort of > warning when you use xread and get EAGAIN or EWOULDBLOCK. I'd rather > see it somehow warn so that we can find the bug (since we rea

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Stefan Beller
On Tue, Sep 22, 2015 at 11:21 AM, Junio C Hamano wrote: > Stefan Beller writes: > >> On Tue, Sep 22, 2015 at 8:58 AM, Junio C Hamano wrote: >>> Eric Sunshine writes: >>> > while (1) { > nr = read(fd, buf, len); > - if ((nr < 0) && (errno == EAGA

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Torsten Bögershausen
On 22.09.15 08:23, Jacob Keller wrote: > On Mon, Sep 21, 2015 at 9:55 PM, Torsten Bögershausen wrote: >> But in any case I suggest to xread() as it is, and not to change the >> functionality >> behind the back of the users. >> >> > > I don't think this patch actually changes behavior as it stand

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Junio C Hamano
Stefan Beller writes: > On Tue, Sep 22, 2015 at 8:58 AM, Junio C Hamano wrote: >> Eric Sunshine writes: >> while (1) { nr = read(fd, buf, len); - if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) - continue;

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Stefan Beller
On Tue, Sep 22, 2015 at 8:58 AM, Junio C Hamano wrote: > Eric Sunshine writes: > >>> while (1) { >>> nr = read(fd, buf, len); >>> - if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) >>> - continue; >>> + if (nr < 0) { >>

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-22 Thread Junio C Hamano
Eric Sunshine writes: >> while (1) { >> nr = read(fd, buf, len); >> - if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) >> - continue; >> + if (nr < 0) { >> + if (errno == EINTR) >> +

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-21 Thread Jacob Keller
On Mon, Sep 21, 2015 at 9:55 PM, Torsten Bögershausen wrote: > But in any case I suggest to xread() as it is, and not to change the > functionality > behind the back of the users. > > I don't think this patch actually changes behavior as it stands now. I think Junio's suggestion does. Personally

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-21 Thread Torsten Bögershausen
On 09/22/2015 01:55 AM, Junio C Hamano wrote: Stefan Beller writes: So if we get an EAGAIN or EWOULDBLOCK error the fd must be nonblocking. As the intend of xread is to read as much as possible either until the fd is EOF or an actual error occurs, we can ease the feeder of the fd by not spinni

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-21 Thread Eric Sunshine
On Mon, Sep 21, 2015 at 6:39 PM, Stefan Beller wrote: > From the man page: > [...] > So if we get an EAGAIN or EWOULDBLOCK error the fd must be nonblocking. s/So/&,/ s/error/&,/ > As the intend of xread is to read as much as possible either until the s/intend/intent/ > fd is EOF or an actual e

Re: [PATCHv3 02/13] xread: poll on non blocking fds

2015-09-21 Thread Junio C Hamano
Stefan Beller writes: > So if we get an EAGAIN or EWOULDBLOCK error the fd must be nonblocking. > As the intend of xread is to read as much as possible either until the > fd is EOF or an actual error occurs, we can ease the feeder of the fd > by not spinning the whole time, but rather wait for it

[PATCHv3 02/13] xread: poll on non blocking fds

2015-09-21 Thread Stefan Beller
>From the man page: EAGAIN The file descriptor fd refers to a file other than a socket and has been marked nonblocking (O_NONBLOCK), and the read would block. EAGAIN or EWOULDBLOCK The file descriptor fd refers to a socket and has been marked nonblocking (O_NONBLOCK), a