You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Wilfredo Sanchez <ws...@apache.org> on 2002/07/24 16:45:40 UTC

atol

   There are several places in HTTPD where we use atol to parse ranges from HTTP headers.  Problem (at least on Darwin) is that a long is smaller than size_t, and we're unable to handle large files in the 2-4GB range.

   atol is the same as calling strtol with NULL and 10 as the last to args, and we can use strtoll instead, so this is an easy fix, except than strtoll may not be on all of our platforms, so this seems like a job for APR, lest we have #ifdef HAVE_STRTOLL all over the place.  The patch I got from Shantonu adds an APR function apr_atoll which returns a long long.  It uses strtoll is available, otherwise falls back to strtol.

   Questions:

  1- Is adding apr_strtoll kosher?
  2- Should I also add apr_strtoll for completeness?

	-wsv


Re: atol

Posted by Thom May <th...@planetarytramp.net>.
* Wilfredo Sanchez (wsanchez@apache.org) wrote :
>   There are several places in HTTPD where we use atol to parse ranges from 
>   HTTP headers.  Problem (at least on Darwin) is that a long is smaller 
>   than size_t, and we're unable to handle large files in the 2-4GB range.
> 
>   atol is the same as calling strtol with NULL and 10 as the last to args, 
>   and we can use strtoll instead, so this is an easy fix, except than 
>   strtoll may not be on all of our platforms, so this seems like a job for 
>   APR, lest we have #ifdef HAVE_STRTOLL all over the place.  The patch I 
>   got from Shantonu adds an APR function apr_atoll which returns a long 
>   long.  It uses strtoll is available, otherwise falls back to strtol.
> 
>   Questions:
> 
>  1- Is adding apr_strtoll kosher?
+1
>  2- Should I also add apr_strtoll for completeness?
+1

-Thom
-- 
Thom May -> thom@planetarytramp.net


Re: atol

Posted by Thom May <th...@planetarytramp.net>.
* Wilfredo Sanchez (wsanchez@apache.org) wrote :
>   There are several places in HTTPD where we use atol to parse ranges from 
>   HTTP headers.  Problem (at least on Darwin) is that a long is smaller 
>   than size_t, and we're unable to handle large files in the 2-4GB range.
> 
>   atol is the same as calling strtol with NULL and 10 as the last to args, 
>   and we can use strtoll instead, so this is an easy fix, except than 
>   strtoll may not be on all of our platforms, so this seems like a job for 
>   APR, lest we have #ifdef HAVE_STRTOLL all over the place.  The patch I 
>   got from Shantonu adds an APR function apr_atoll which returns a long 
>   long.  It uses strtoll is available, otherwise falls back to strtol.
> 
>   Questions:
> 
>  1- Is adding apr_strtoll kosher?
+1
>  2- Should I also add apr_strtoll for completeness?
+1

-Thom
-- 
Thom May -> thom@planetarytramp.net


Re: atol

Posted by Justin Erenkrantz <je...@apache.org>.
On Wed, Jul 24, 2002 at 10:45:40AM -0400, Wilfredo Sanchez wrote:
>  1- Is adding apr_strtoll kosher?

+1.

>  2- Should I also add apr_strtoll for completeness?

+1.  -- justin

Re: atol

Posted by Justin Erenkrantz <je...@apache.org>.
On Wed, Jul 24, 2002 at 10:45:40AM -0400, Wilfredo Sanchez wrote:
>  1- Is adding apr_strtoll kosher?

+1.

>  2- Should I also add apr_strtoll for completeness?

+1.  -- justin

Re: atol

Posted by Shantonu Sen <ss...@apple.com>.

On Wed, 24 Jul 2002, Wilfredo Sanchez wrote:

>    There are several places in HTTPD where we use atol to parse ranges
> from HTTP headers.  Problem (at least on Darwin) is that a long is
> smaller than size_t, and we're unable to handle large files in the 2-4GB
> range.

Also smaller than an off_t (for platforms where it's a 64-bit quantity and
a long isn't), which is the issue the patches directly address. For
platforms where an off_t is a 32-bit quantity, or a long is a 64-bit
quantity, or both, the compiler will do the right thing in assigning a
64-bit rval to a 32-bit lval, which is better than the currect situation
of a 32-bit rval to a 64-bit lval (for those platforms with support it).

Supporting HEAD requests even of files >4GB seems to have another problem
where the file size is being reported as 2^31 (I know, that's out of
bounds for a signed 32-bit number, so something else is afoot), which is
why the patches don't unlock serving of larger files with HTTP/1.1 partial
ranges.

> It uses strtoll is available, otherwise falls back to
> strtol.

I did not feel comfortable pulling over the strtoll(3) implementation from
Darwin or FreeBSD (they are the same) without doing more investigation
about how portable *their* implementation is. I've verified that
strtoll(3) exists at least on Darwin 5.5, Darwin 6.0 (aka Mac OS X 10.2
"Jaguar"), FreeBSD 4.6, and Solaris 8, which seems like a broad enough
cross section of operating systems to make the "use it if you got it"
approach reasonable.

Shantonu Sen
Apple Computer, Inc.


Re: atol

Posted by "B. W. Fitzpatrick" <fi...@apple.com>.
On Wednesday, July 24, 2002, at 09:45  AM, Wilfredo Sanchez wrote:

>  1- Is adding apr_strtoll kosher?

I think so.

>  2- Should I also add apr_strtoll for completeness?

Do you mean apr_atoll? If so, sure.

-Fitz