From: "Torsten Bögershausen" <tboegi@web.de>
To: "Jeff King" <peff@peff.net>, "Torsten Bögershausen" <tboegi@web.de>
Cc: Stefan Beller <sbeller@google.com>,
"git@vger.kernel.org" <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Jonathan Nieder <jrnieder@gmail.com>,
Johannes Schindelin <johannes.schindelin@gmail.com>,
Jens Lehmann <Jens.Lehmann@web.de>,
Eric Sunshine <ericsunshine@gmail.com>,
Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCHv2 2/7] xread: poll on non blocking fds
Date: Fri, 18 Dec 2015 09:50:46 +0100 [thread overview]
Message-ID: <5673C8E6.8010001@web.de> (raw)
In-Reply-To: <20151218031336.GA8467@sigill.intra.peff.net>
On 18.12.15 04:13, Jeff King wrote:
> On Thu, Dec 17, 2015 at 09:42:01PM +0100, Torsten Bögershausen wrote:
>
>>> Or do you mean to insert another continue in here?
>> I was thinking that we run into similar loop as before:
>> read() returns -1; errno = EAGAIN /* No data to read */
>> 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 */
>>
>> So the code would look like this:
>>
>> if (!poll(&pfd, 1, -1))
>> return -1;
>
> That changes the semantics of the function. The poll() is just a
> convenience to avoid spinning. If it fails, with Stefan's patch[1] the
> worst case is that we would spin on read() and poll(), instead of
> actually blocking in the poll().
>
> But if we return on poll() failure, now the caller will see errors from
> poll() even though they don't know or care that we called poll() in the
> first place. Consider what would happen with your code if read got
> EAGAIN and then poll got EINTR. We would report an error, even though
> the whole point of xread() is to loop on these conditions.
>
> -Peff
>
> [1] Stefan's patch does have a bug. It forgets to "continue" after
> calling poll, which means we will block with poll and _then_ exit
> with -1, instead of restarting the loop.
> --
I love this group: Curing one bug with another doesn't work :-)
/* So the code v2 would look like this: */
if (!poll(&pfd, 1, -1)) {
if (errno == EINTR)
continue;
return -1; /* poll() failed, this is serious. */
}
next prev parent reply other threads:[~2015-12-18 8:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-16 0:04 [PATCHv2 0/7] Rerolling sb/submodule-parallel-fetch for the time after 2.7 Stefan Beller
2015-12-16 0:04 ` [PATCHv2 1/7] submodule.c: write "Fetching submodule <foo>" to stderr Stefan Beller
2015-12-16 0:04 ` [PATCHv2 2/7] xread: poll on non blocking fds Stefan Beller
2015-12-17 20:12 ` Torsten Bögershausen
2015-12-17 20:22 ` Stefan Beller
2015-12-17 20:42 ` Torsten Bögershausen
2015-12-17 20:51 ` Stefan Beller
2015-12-18 3:14 ` Jeff King
2015-12-18 3:13 ` Jeff King
2015-12-18 8:50 ` Torsten Bögershausen [this message]
2015-12-18 18:12 ` Jeff King
2015-12-18 3:07 ` Jeff King
2015-12-16 0:04 ` [PATCHv2 3/7] strbuf: add strbuf_read_once to read without blocking Stefan Beller
2015-12-16 0:04 ` [PATCHv2 4/7] sigchain: add command to pop all common signals Stefan Beller
2015-12-16 0:04 ` [PATCHv2 5/7] run-command: add an asynchronous parallel child processor Stefan Beller
2015-12-16 0:04 ` [PATCHv2 6/7] fetch_populated_submodules: use new parallel job processing Stefan Beller
2015-12-16 0:04 ` [PATCHv2 7/7] submodules: allow parallel fetching, add tests and documentation Stefan Beller
2015-12-16 0:19 ` [PATCHv2 0/7] Rerolling sb/submodule-parallel-fetch for the time after 2.7 Stefan Beller
2015-12-16 20:20 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5673C8E6.8010001@web.de \
--to=tboegi@web.de \
--cc=Jens.Lehmann@web.de \
--cc=ericsunshine@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=johannes.schindelin@gmail.com \
--cc=jrnieder@gmail.com \
--cc=peff@peff.net \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).