fix key length and alignment
diff --git a/src/http/modules/ngx_http_limit_zone_module.c b/src/http/modules/ngx_http_limit_zone_module.c
index 4071074..218c0de 100644
--- a/src/http/modules/ngx_http_limit_zone_module.c
+++ b/src/http/modules/ngx_http_limit_zone_module.c
@@ -10,7 +10,8 @@
typedef struct {
- u_short len;
+ u_char color;
+ u_char len;
u_short conn;
u_char data[1];
} ngx_http_limit_zone_node_t;
@@ -148,12 +149,12 @@
}
if (hash == node->key ){
- lz = (ngx_http_limit_zone_node_t *) &node->data;
+ lz = (ngx_http_limit_zone_node_t *) &node->color;
if (len == (size_t) lz->len
&& ngx_strncmp(lz->data, vv->data, len) == 0)
{
- if (lz->conn < (u_short) lzcf->conn) {
+ if ((ngx_uint_t) lz->conn < lzcf->conn) {
lz->conn++;
goto done;
}
@@ -165,7 +166,7 @@
}
}
- n = offsetof(ngx_rbtree_node_t, data)
+ n = offsetof(ngx_rbtree_node_t, color)
+ offsetof(ngx_http_limit_zone_node_t, data)
+ len;
@@ -175,10 +176,10 @@
return NGX_HTTP_SERVICE_UNAVAILABLE;
}
- lz = (ngx_http_limit_zone_node_t *) &node->data;
+ lz = (ngx_http_limit_zone_node_t *) &node->color;
node->key = hash;
- lz->len = (u_short) len;
+ lz->len = (u_char) len;
lz->conn = 1;
ngx_memcpy(lz->data, vv->data, len);
@@ -214,7 +215,7 @@
rbtree = lzcln->shm_zone->data;
shpool = (ngx_slab_pool_t *) lzcln->shm_zone->shm.addr;
node = lzcln->node;
- lz = (ngx_http_limit_zone_node_t *) &node->data;
+ lz = (ngx_http_limit_zone_node_t *) &node->color;
ngx_shmtx_lock(&shpool->mutex);