comparison 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
comparison
equal deleted inserted replaced
329:d792b2cd78fe 330:c60beecc6ab5
59 static char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, 59 static char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd,
60 void *conf); 60 void *conf);
61 static char *ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data); 61 static char *ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data);
62 static char *ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd, 62 static char *ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd,
63 void *conf); 63 void *conf);
64 64 static ngx_int_t ngx_http_userid_init_worker(ngx_cycle_t *cycle);
65 65
66 66
67
68 static uint32_t start_value;
67 static uint32_t sequencer_v1 = 1; 69 static uint32_t sequencer_v1 = 1;
68 static uint32_t sequencer_v2 = 0x03030302; 70 static uint32_t sequencer_v2 = 0x03030302;
69 71
70 72
71 static u_char expires[] = "; expires=Thu, 31-Dec-37 23:55:55 GMT"; 73 static u_char expires[] = "; expires=Thu, 31-Dec-37 23:55:55 GMT";
171 &ngx_http_userid_filter_module_ctx, /* module context */ 173 &ngx_http_userid_filter_module_ctx, /* module context */
172 ngx_http_userid_commands, /* module directives */ 174 ngx_http_userid_commands, /* module directives */
173 NGX_HTTP_MODULE, /* module type */ 175 NGX_HTTP_MODULE, /* module type */
174 NULL, /* init master */ 176 NULL, /* init master */
175 NULL, /* init module */ 177 NULL, /* init module */
176 NULL, /* init process */ 178 ngx_http_userid_init_worker, /* init process */
177 NULL, /* init thread */ 179 NULL, /* init thread */
178 NULL, /* exit thread */ 180 NULL, /* exit thread */
179 NULL, /* exit process */ 181 NULL, /* exit process */
180 NULL, /* exit master */ 182 NULL, /* exit master */
181 NGX_MODULE_V1_PADDING 183 NGX_MODULE_V1_PADDING
317 ctx->uid_set[0] = 0; 319 ctx->uid_set[0] = 0;
318 } else { 320 } else {
319 ctx->uid_set[0] = conf->service; 321 ctx->uid_set[0] = conf->service;
320 } 322 }
321 ctx->uid_set[1] = ngx_time(); 323 ctx->uid_set[1] = ngx_time();
322 ctx->uid_set[2] = ngx_pid; 324 ctx->uid_set[2] = start_value;
323 ctx->uid_set[3] = sequencer_v1; 325 ctx->uid_set[3] = sequencer_v1;
324 sequencer_v1 += 0x100; 326 sequencer_v1 += 0x100;
325 327
326 } else { 328 } else {
327 if (conf->service == NGX_CONF_UNSET) { 329 if (conf->service == NGX_CONF_UNSET) {
344 } else { 346 } else {
345 ctx->uid_set[0] = htonl(conf->service); 347 ctx->uid_set[0] = htonl(conf->service);
346 } 348 }
347 349
348 ctx->uid_set[1] = htonl(ngx_time()); 350 ctx->uid_set[1] = htonl(ngx_time());
349 ctx->uid_set[2] = htonl(ngx_pid); 351 ctx->uid_set[2] = htonl(start_value);
350 ctx->uid_set[3] = htonl(sequencer_v2); 352 ctx->uid_set[3] = htonl(sequencer_v2);
351 sequencer_v2 += 0x100; 353 sequencer_v2 += 0x100;
352 if (sequencer_v2 < 0x03030302) { 354 if (sequencer_v2 < 0x03030302) {
353 sequencer_v2 = 0x03030302; 355 sequencer_v2 = 0x03030302;
354 } 356 }
704 706
705 ucf->mark = value[1].data[0]; 707 ucf->mark = value[1].data[0];
706 708
707 return NGX_CONF_OK; 709 return NGX_CONF_OK;
708 } 710 }
711
712
713 static ngx_int_t
714 ngx_http_userid_init_worker(ngx_cycle_t *cycle)
715 {
716 struct timeval tp;
717
718 ngx_gettimeofday(&tp);
719
720 /* use the most significant usec part that fits to 16 bits */
721 start_value = ((tp.tv_usec / 20) << 16) | ngx_pid;
722
723 return NGX_OK;
724 }
725