diff src/http/modules/ngx_http_userid_filter_module.c @ 330:c60beecc6ab5 NGINX_0_5_35

nginx 0.5.35 *) Change: now the ngx_http_userid_module adds start time microseconds to the cookie field contains a pid value. *) Change: now the uname(2) is used on Linux instead of procfs. Thanks to Ilya Novikov. *) Feature: the "If-Range" request header line support. Thanks to Alexander V. Inyukhin. *) Bugfix: in HTTPS mode requests might fail with the "bad write retry" error; bug appeared in 0.5.13. *) Bugfix: the STARTTLS in SMTP mode did not work. Thanks to Oleg Motienko. *) Bugfix: large_client_header_buffers did not freed before going to keep-alive state. Thanks to Olexander Shtepa. *) Bugfix: the "limit_rate" directive did not allow to use full throughput, even if limit value was very high. *) Bugfix: the $status variable was equal to 0 if a proxied server returned response in HTTP/0.9 version. *) Bugfix: if the "?" character was in a "error_page" directive, then it was escaped in a proxied request; bug appeared in 0.5.32.
author Igor Sysoev <http://sysoev.ru>
date Tue, 08 Jan 2008 00:00:00 +0300
parents 26ff8d6b618d
children
line wrap: on
line diff
--- 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
 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_mod
     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
                 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
             }
 
             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
 
     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;
+}
+