public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Aaron Merey <amerey@redhat.com>, elfutils-devel@sourceware.org
Subject: Re: [PATCH] [PATCH] debuginfod: Use the debuginfod-size response header
Date: Thu, 31 Mar 2022 19:37:59 +0200	[thread overview]
Message-ID: <9e72049a6e8b9a964d68cfc70b98aea682911b13.camel@klomp.org> (raw)
In-Reply-To: <20220112030755.434016-1-amerey@redhat.com>

Hi Aaron,

On Tue, 2022-01-11 at 22:07 -0500, Aaron Merey via Elfutils-devel
wrote:
> In some cases the content-length header may not be available in order
> to pass to a progressfn.  If content-length isn't available then attempt
> to get the size of the download from the debuginfod-size header instead.
> 
> It should be mentioned that if a compressed file (ex. gzip) is being
> transferred, the actual transfer length will be less than debuginfod-size.
> In this case debuginfod-size is a best-guess upper bound on the size of
> the transfer.

Sorry this patch wasn't reviewed for such a long time. It looks correct
and is also a nice cleanup. Consolidating getting the download size in
one place instead of two (for the progress function and the maxsize
check).

Just a question about this part:

> +          /* If Content-Length is -1, try to get the size from
> +             X-Debuginfod-Size */
> +          if (dl_size == -1 && c->winning_headers != NULL)
> +            {
> +              double xdl;
> +              char *hdr = strstr(c->winning_headers, "x-debuginfod-size");
> +
> +              if (hdr != NULL
> +                  && sscanf(hdr, "x-debuginfod-size: %lf", &xdl) == 1)
> +                dl_size = (xdl >= (double)(LONG_MAX+1UL) ? LONG_MAX : (long)xdl);
> +            }
> +        }

In debuginfod.cxx the header is spelled all uppercase as "X-DEBUGINFOD-
SIZE" which is also what is checked for in the run-debuginfod-response-
headers.sh test. So shouldn't the above also be all uppercase or should
you use strcasestr?

When using sscanf why are you using a double and %lf? Isn't it simpler
to use a long and %ld?

Is there a way to test this easily? When would Content-Length not be
available?

Cheers,

Mark




  reply	other threads:[~2022-03-31 17:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12  3:07 Aaron Merey
2022-03-31 17:37 ` Mark Wielaard [this message]
2022-04-21 20:53   ` Aaron Merey
2022-04-22 22:56     ` Aaron Merey
2022-04-24 15:04       ` Mark Wielaard
2022-04-25 15:03         ` Aaron Merey

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=9e72049a6e8b9a964d68cfc70b98aea682911b13.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=amerey@redhat.com \
    --cc=elfutils-devel@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).