httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yann Ylavic <ylavic....@gmail.com>
Subject Re: svn commit: r1712782 - in /httpd/httpd/trunk/modules/http2: h2_session.c h2_stream_set.c h2_stream_set.h h2_version.h
Date Thu, 05 Nov 2015 16:07:36 GMT
On Thu, Nov 5, 2015 at 5:03 PM, Yann Ylavic <ylavic.dev@gmail.com> wrote:
> On Thu, Nov 5, 2015 at 3:21 PM,  <icing@apache.org> wrote:
>>
>> -h2_stream_set *h2_stream_set_create(apr_pool_t *pool)
>> +static unsigned int stream_hash(const char *key, apr_ssize_t *klen)
>> +{
>> +    /* we use the "int stream_id" has key, which always odd from
>> +    * client and even from server. As long as we do not mix them
>> +    * in one set, snip off the lsb. */
>> +    return (unsigned int)(*((int*)key)) >> 1;
>
> This may cause alignment issues, 'key' is not necessarily int or word
> aligned here.
> You possibly should go for something like:
>   apr_uint32_r k =
>       (key[0] << 0)  |
>       (key[1] << 8)  |
>       (key[2] << 16) |
>       (key[3] << 24) ;

Or maybe simply:
  memcpy(&k, key, 4);
  return k;
...

Mime
View raw message