From: Jeff King Date: Fri, 18 Dec 2015 03:14:33 GMT Subject: Re: [PATCHv2 2/7] xread: poll on non blocking fds Message-ID: <20151218031432.GB8467@sigill.intra.peff.net> In-Reply-To: On Thu, Dec 17, 2015 at 12:51:08PM -0800, Stefan Beller wrote: > > poll() returns -1; errno = EAGAIN /* poll failed. If the fd was OK, the failure may be temporaly, > > as much as poll() can see. > > But most probably we run out ouf memory */ > > Before this patch we would not have asked poll, but had just a continue here, > so I think we need to have it here again no matter of the return code > of the poll. > > If poll determines it is low on memory, this should not make this function fail, > we can still do as good as we did before by just asking read > repeatedly again, though? > > So I'd be convinced now we'd want to have: > > poll(&pfd, 1, -1); /* this is only buying time > for the fd to deliver data, in case it fails > we don't care but just fall back to old > behavior before this patch with busy spinning*/ > continue; Right. I think that is the only sensible thing, and your comment explains perfectly what is going on. -Peff