summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-01-08 17:09:49 +0000
committerIgor Sysoev <igor@sysoev.ru>2008-01-08 17:09:49 +0000
commit2650ae3a28332ee4fb904af8ac7513ee73fbbd34 (patch)
tree9c65bf83868e70d7ec2389a26894d86209434813
parent180eccfb5c78b052e54069f8e2131f859f5881b0 (diff)
downloadnginx-2650ae3a28332ee4fb904af8ac7513ee73fbbd34.tar.gz
r1652 merge:
use usec and pid as start value
-rw-r--r--src/http/modules/ngx_http_userid_filter_module.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/http/modules/ngx_http_userid_filter_module.c b/src/http/modules/ngx_http_userid_filter_module.c
index 5587b002a..cfeb80a36 100644
--- a/src/http/modules/ngx_http_userid_filter_module.c
+++ b/src/http/modules/ngx_http_userid_filter_module.c
@@ -61,9 +61,11 @@ static char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd,
static char *ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data);
static char *ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
+static ngx_int_t ngx_http_userid_init_worker(ngx_cycle_t *cycle);
+static uint32_t start_value;
static uint32_t sequencer_v1 = 1;
static uint32_t sequencer_v2 = 0x03030302;
@@ -173,7 +175,7 @@ ngx_module_t ngx_http_userid_filter_module = {
NGX_HTTP_MODULE, /* module type */
NULL, /* init master */
NULL, /* init module */
- NULL, /* init process */
+ ngx_http_userid_init_worker, /* init process */
NULL, /* init thread */
NULL, /* exit thread */
NULL, /* exit process */
@@ -319,7 +321,7 @@ ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx,
ctx->uid_set[0] = conf->service;
}
ctx->uid_set[1] = ngx_time();
- ctx->uid_set[2] = ngx_pid;
+ ctx->uid_set[2] = start_value;
ctx->uid_set[3] = sequencer_v1;
sequencer_v1 += 0x100;
@@ -346,7 +348,7 @@ ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx,
}
ctx->uid_set[1] = htonl(ngx_time());
- ctx->uid_set[2] = htonl(ngx_pid);
+ ctx->uid_set[2] = htonl(start_value);
ctx->uid_set[3] = htonl(sequencer_v2);
sequencer_v2 += 0x100;
if (sequencer_v2 < 0x03030302) {
@@ -706,3 +708,18 @@ ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_OK;
}
+
+
+static ngx_int_t
+ngx_http_userid_init_worker(ngx_cycle_t *cycle)
+{
+ struct timeval tp;
+
+ ngx_gettimeofday(&tp);
+
+ /* use the most significant usec part that fits to 16 bits */
+ start_value = ((tp.tv_usec / 20) << 16) | ngx_pid;
+
+ return NGX_OK;
+}
+