From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: gzio/http problem
Date: Sat, 30 Apr 2016 09:21:21 +0300 [thread overview]
Message-ID: <57244EE1.7060901@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1604292254240.1947@eru.sfritsch.de>
30.04.2016 00:00, Stefan Fritsch пишет:
> On Fri, 29 Apr 2016, Andrei Borzenkov wrote:
>
>> 29.04.2016 00:54, Vladimir 'phcoder' Serbinenko пишет:
>>> HTTP code should never return short reads. The whole subsystem relies on
>>> never having short reads from any fs or network driver
>>>
>>
>> HTTP code never returns short reads itself. But it sets EOF on socket in
>> case something bad happens, and in this case we return currently
>> received data to caller in net core.
>>
>> if (!net->eof)
>> {
>> try++;
>> grub_net_poll_cards (GRUB_NET_INTERVAL +
>> (try * GRUB_NET_INTERVAL_ADDITION),
>> &net->stall);
>> }
>> else
>> return total;
>>
>> Disallowing short reads means also we should also disallow files with
>> unknown size. I think that's unrealistic.
>
> I think I have found the problem:
>
> http_seek() creates a new connection but does not reset the eof flag.
> grub_net_fs_read_real() then does a short read because of the set eof
> flag.
>
>
> This patch seems to fix the issue:
>
> @@ -453,6 +461,7 @@ http_seek (struct grub_file *file, grub_off_t off)
> }
>
> file->device->net->stall = 0;
> + file->device->net->eof = 0;
> file->device->net->offset = off;
>
> data = grub_zalloc (sizeof (*data));
>
Good catch! Committed.
>
> Though one could also argue that grub_net_seek_real() should reset the eof
> flag before calling file->device->net->protocol->seek().
>
It does it if it re-establishes connection itself (BTW it needs to reset
->stall in this case as well, I also added patch for it). But it does
not know how low level protocol implements it, so it would be wrong here.
We probably need to consolidate cleanup code to make sure it is done in
one place.
next prev parent reply other threads:[~2016-04-30 6:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-28 11:11 [PATCH] Rewrite and fix grub_bufio_read() Stefan Fritsch
2016-04-28 17:49 ` Andrei Borzenkov
2016-04-28 19:52 ` Stefan Fritsch
2016-04-28 21:30 ` gzio/http problem (was: [PATCH] Rewrite and fix grub_bufio_read()) Stefan Fritsch
2016-04-28 21:54 ` Vladimir 'phcoder' Serbinenko
2016-04-29 4:08 ` gzio/http problem Andrei Borzenkov
2016-04-29 21:00 ` Stefan Fritsch
2016-04-30 6:21 ` Andrei Borzenkov [this message]
2016-04-29 3:50 ` [PATCH] Rewrite and fix grub_bufio_read() Andrei Borzenkov
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57244EE1.7060901@gmail.com \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
/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.
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 NNTP newsgroup(s).