On Thu, Nov 5, 2015 at 3:21 PM, <[email protected]> wrote:
> Author: icing
> Date: Thu Nov 5 14:21:13 2015
> New Revision: 1712782
>
> URL: http://svn.apache.org/viewvc?rev=1712782&view=rev
> Log:
> replacing own stream_set with apr_hash internally
>
>
> Modified: httpd/httpd/trunk/modules/http2/h2_stream_set.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_stream_set.c?rev=1712782&r1=1712781&r2=1712782&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/http2/h2_stream_set.c (original)
> +++ httpd/httpd/trunk/modules/http2/h2_stream_set.c Thu Nov 5 14:21:13 2015
> @@ -19,31 +19,30 @@
> #include <apr_strings.h>
>
> #include <httpd.h>
> -#include <http_core.h>
> -#include <http_connection.h>
> #include <http_log.h>
>
> #include "h2_private.h"
> -#include "h2_session.h"
> #include "h2_stream.h"
> -#include "h2_task.h"
> #include "h2_stream_set.h"
>
> -#define H2_STREAM_IDX(list, i) ((h2_stream**)(list)->elts)[i]
>
> struct h2_stream_set {
> - apr_array_header_t *list;
> + apr_hash_t *hash;
> };
>
> -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 the other way around depending on byte order (if that matters, probably not).
> +}
Regards,
Yann.