From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1awOHz-0003ec-0i for mharc-grub-devel@gnu.org; Sat, 30 Apr 2016 02:22:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awOHq-0003Q5-Ht for grub-devel@gnu.org; Sat, 30 Apr 2016 02:22:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awOHf-0005CD-00 for grub-devel@gnu.org; Sat, 30 Apr 2016 02:21:49 -0400 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]:35178) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awOHd-00056o-Lm for grub-devel@gnu.org; Sat, 30 Apr 2016 02:21:42 -0400 Received: by mail-lf0-x232.google.com with SMTP id j8so7716693lfd.2 for ; Fri, 29 Apr 2016 23:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=sCANO4LjsAPeUywdpzzXIWSHv3WnxWohaMp2o6Fjs0c=; b=VaLhqKf2/a7b//x+pcMZtL6xOdMSLejhLNKy7BgOs1FqlBheGLsmH18vwKzJC8AcXR 0R22xPyhQvJaF0z+AEOtQuoZhHQHSDHIDIpVUfEePsTJNknvf3rBwbzM0XmvEeUXCYil lGTlOfJEBIJSZcNKJcsd8OC0FzkbIYOgkjNkwqZSCyf46HC8EjCFg6f2ULb4AiW3pRj+ 1DAsLzSvI0bWvfZ1U0tYRpxvNqkMyKEJIgd7riEqWaoNS9MjwbBiRBXnJiZ7yT6RLop1 WYF9+WesXHcSaiN7vnp8R7Slmfjy0tKiZTzzmklNwudpNNR2cB/kpOpGM6TzfAmOZSHR uUbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=sCANO4LjsAPeUywdpzzXIWSHv3WnxWohaMp2o6Fjs0c=; b=OAGc70wIFMXlxNgIpodn/l4vvM5hdkpYMpbVO8nQhe3J1GniopyfpTTEDm4detPz+k K87N3EfPU4wNiCKrunlnR82LtsNVJkw5E6WymMJigwuRqQ6wuqBLNOfhaZ4RiLzvcvSd Hx3NKftBwQhn+CY63nOF5dUFreAWkd8fGp/fm7NwFKequ7N5ts5PlnZzpwJ8qsI2oqZy OMgyKPw/cqanYJTu93+5Zdo71Vj+R8hsS1+oETV39cZWRlsUIjKsll+Q2GrGsBv/Sg88 pb75QP8A9hagBPm/nVBuezJBdNtflnaehUY7Q+7LrT0ovx6A8J+Gb6GUwU1Jw3RiXdwk GKkQ== X-Gm-Message-State: AOPr4FU2VsdM4ao1zutbeEWjxzGDJ4c6pBiQTJamsX6B/qj3ptScuwAnilUesFQFW26cGg== X-Received: by 10.25.19.66 with SMTP id j63mr10531104lfi.24.1461997283478; Fri, 29 Apr 2016 23:21:23 -0700 (PDT) Received: from [192.168.1.42] (ppp109-252-90-74.pppoe.spdop.ru. [109.252.90.74]) by smtp.gmail.com with ESMTPSA id p199sm2852388lfd.12.2016.04.29.23.21.21 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 29 Apr 2016 23:21:22 -0700 (PDT) Subject: Re: gzio/http problem To: The development of GNU GRUB References: <57224D3F.1080704@gmail.com> <16066843.M6gESN7E00@k> <5722DE58.6020008@gmail.com> From: Andrei Borzenkov Message-ID: <57244EE1.7060901@gmail.com> Date: Sat, 30 Apr 2016 09:21:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::232 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Apr 2016 06:22:01 -0000 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.