You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2007/03/12 16:05:51 UTC
svn commit: r517238 - in /httpd/httpd/trunk: CHANGES modules/http/http_etag.c
Author: jorton
Date: Mon Mar 12 08:05:50 2007
New Revision: 517238
URL: http://svn.apache.org/viewvc?view=rev&rev=517238
Log:
Generate etags consistently across 32-bit and 64-bit platforms:
* modules/http/http_etag.c (etag_uint64_to_hex): Renamed from
etag_ulong_to_hex; take an apr_uint64_t argument.
(ap_make_etag): Adjust to use new function and macro names.
Pass arguments directly to etag_uint64_to_hex without casting
down to unsigned long.
PR: 40064
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/modules/http/http_etag.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?view=diff&rev=517238&r1=517237&r2=517238
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Mar 12 08:05:50 2007
@@ -2,6 +2,9 @@
Changes with Apache 2.3.0
[Remove entries to the current 2.0 and 2.2 section below, when backported]
+ *) core: Change etag generation to produce identical results on
+ 32-bit and 64-bit platforms. PR 40064. [Joe Orton]
+
*) ab: Add -r option to continue after socket receive errors.
[Filip Hanik <devlist hanik.com>]
Modified: httpd/httpd/trunk/modules/http/http_etag.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_etag.c?view=diff&rev=517238&r1=517237&r2=517238
==============================================================================
--- httpd/httpd/trunk/modules/http/http_etag.c (original)
+++ httpd/httpd/trunk/modules/http/http_etag.c Mon Mar 12 08:05:50 2007
@@ -28,16 +28,16 @@
#include "http_protocol.h" /* For index_of_response(). Grump. */
#include "http_request.h"
-/* Generate the human-readable hex representation of an unsigned long
- * (basically a faster version of 'sprintf("%lx")')
+/* Generate the human-readable hex representation of an apr_uint64_t
+ * (basically a faster version of 'sprintf("%llx")')
*/
#define HEX_DIGITS "0123456789abcdef"
-static char *etag_ulong_to_hex(char *next, unsigned long u)
+static char *etag_uint64_to_hex(char *next, apr_uint64_t u)
{
int printing = 0;
int shift = sizeof(unsigned long) * 8 - 4;
do {
- unsigned long next_digit = ((u >> shift) & (unsigned long)0xf);
+ unsigned short next_digit = ((u >> shift) & (apr_uint64_t)0xf);
if (next_digit) {
*next++ = HEX_DIGITS[next_digit];
printing = 1;
@@ -47,12 +47,12 @@
}
shift -= 4;
} while (shift);
- *next++ = HEX_DIGITS[u & (unsigned long)0xf];
+ *next++ = HEX_DIGITS[u & (apr_uint64_t)0xf];
return next;
}
#define ETAG_WEAK "W/"
-#define CHARS_PER_UNSIGNED_LONG (sizeof(unsigned long) * 2)
+#define CHARS_PER_UINT64 (sizeof(apr_uint64_t) * 2)
/*
* Construct an entity tag (ETag) from resource information. If it's a real
* file, build in some of the file characteristics. If the modification time
@@ -115,7 +115,7 @@
* FileETag keywords.
*/
etag = apr_palloc(r->pool, weak_len + sizeof("\"--\"") +
- 3 * CHARS_PER_UNSIGNED_LONG + 1);
+ 3 * CHARS_PER_UINT64 + 1);
next = etag;
if (weak) {
while (*weak) {
@@ -125,21 +125,21 @@
*next++ = '"';
bits_added = 0;
if (etag_bits & ETAG_INODE) {
- next = etag_ulong_to_hex(next, (unsigned long)r->finfo.inode);
+ next = etag_uint64_to_hex(next, r->finfo.inode);
bits_added |= ETAG_INODE;
}
if (etag_bits & ETAG_SIZE) {
if (bits_added != 0) {
*next++ = '-';
}
- next = etag_ulong_to_hex(next, (unsigned long)r->finfo.size);
+ next = etag_uint64_to_hex(next, r->finfo.size);
bits_added |= ETAG_SIZE;
}
if (etag_bits & ETAG_MTIME) {
if (bits_added != 0) {
*next++ = '-';
}
- next = etag_ulong_to_hex(next, (unsigned long)r->mtime);
+ next = etag_uint64_to_hex(next, r->mtime);
}
*next++ = '"';
*next = '\0';
@@ -149,7 +149,7 @@
* Not a file document, so just use the mtime: [W/]"mtime"
*/
etag = apr_palloc(r->pool, weak_len + sizeof("\"\"") +
- CHARS_PER_UNSIGNED_LONG + 1);
+ CHARS_PER_UINT64 + 1);
next = etag;
if (weak) {
while (*weak) {
@@ -157,7 +157,7 @@
}
}
*next++ = '"';
- next = etag_ulong_to_hex(next, (unsigned long)r->mtime);
+ next = etag_uint64_to_hex(next, r->mtime);
*next++ = '"';
*next = '\0';
}
Re: svn commit: r517238 - in /httpd/httpd/trunk: CHANGES modules/http/http_etag.c
Posted by Joe Orton <jo...@redhat.com>.
On Mon, Mar 12, 2007 at 09:38:34PM +0100, Ruediger Pluem wrote:
> On 03/12/2007 04:05 PM, jorton@apache.org wrote:
...
> > + * (basically a faster version of 'sprintf("%llx")')
> > */
> > #define HEX_DIGITS "0123456789abcdef"
> > -static char *etag_ulong_to_hex(char *next, unsigned long u)
> > +static char *etag_uint64_to_hex(char *next, apr_uint64_t u)
> > {
> > int printing = 0;
> > int shift = sizeof(unsigned long) * 8 - 4;
>
> Shouldn't this be
>
> int shift = sizeof(apr_uint64_t) * 8 - 4;
>
> instead of the above?
It should indeed! Good catch, thanks - fixed in r517654.
joe
Re: svn commit: r517238 - in /httpd/httpd/trunk: CHANGES modules/http/http_etag.c
Posted by Ruediger Pluem <rp...@apache.org>.
On 03/12/2007 04:05 PM, jorton@apache.org wrote:
> Author: jorton
> Date: Mon Mar 12 08:05:50 2007
> New Revision: 517238
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=517238
> Log:
> Generate etags consistently across 32-bit and 64-bit platforms:
>
> * modules/http/http_etag.c (etag_uint64_to_hex): Renamed from
> etag_ulong_to_hex; take an apr_uint64_t argument.
> (ap_make_etag): Adjust to use new function and macro names.
> Pass arguments directly to etag_uint64_to_hex without casting
> down to unsigned long.
>
> PR: 40064
>
> Modified:
> httpd/httpd/trunk/CHANGES
> httpd/httpd/trunk/modules/http/http_etag.c
>
> Modified: httpd/httpd/trunk/modules/http/http_etag.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_etag.c?view=diff&rev=517238&r1=517237&r2=517238
> ==============================================================================
> --- httpd/httpd/trunk/modules/http/http_etag.c (original)
> +++ httpd/httpd/trunk/modules/http/http_etag.c Mon Mar 12 08:05:50 2007
> @@ -28,16 +28,16 @@
> #include "http_protocol.h" /* For index_of_response(). Grump. */
> #include "http_request.h"
>
> -/* Generate the human-readable hex representation of an unsigned long
> - * (basically a faster version of 'sprintf("%lx")')
> +/* Generate the human-readable hex representation of an apr_uint64_t
> + * (basically a faster version of 'sprintf("%llx")')
> */
> #define HEX_DIGITS "0123456789abcdef"
> -static char *etag_ulong_to_hex(char *next, unsigned long u)
> +static char *etag_uint64_to_hex(char *next, apr_uint64_t u)
> {
> int printing = 0;
> int shift = sizeof(unsigned long) * 8 - 4;
Shouldn't this be
int shift = sizeof(apr_uint64_t) * 8 - 4;
instead of the above?
Regards
RĂ¼diger