comparison src/event/ngx_event.c @ 516:7efcdb937752 NGINX_0_8_10

nginx 0.8.10 *) Bugfix: memory leaks if GeoIP City database was used. *) Bugfix: in copying temporary files to permanent storage area; the bug had appeared in 0.8.9.
author Igor Sysoev <http://sysoev.ru>
date Mon, 24 Aug 2009 00:00:00 +0400
parents f39b9e29530d
children be4f34123024
comparison
equal deleted inserted replaced
515:607556aed0a1 516:7efcdb937752
41 41
42 ngx_uint_t ngx_event_flags; 42 ngx_uint_t ngx_event_flags;
43 ngx_event_actions_t ngx_event_actions; 43 ngx_event_actions_t ngx_event_actions;
44 44
45 45
46 ngx_atomic_t connection_counter = 1; 46 static ngx_atomic_t connection_counter = 1;
47 ngx_atomic_t *ngx_connection_counter = &connection_counter; 47 ngx_atomic_t *ngx_connection_counter = &connection_counter;
48 48
49 49
50 ngx_atomic_t *ngx_accept_mutex_ptr; 50 ngx_atomic_t *ngx_accept_mutex_ptr;
51 ngx_shmtx_t ngx_accept_mutex; 51 ngx_shmtx_t ngx_accept_mutex;
427 { 427 {
428 void ***cf; 428 void ***cf;
429 u_char *shared; 429 u_char *shared;
430 size_t size, cl; 430 size_t size, cl;
431 ngx_shm_t shm; 431 ngx_shm_t shm;
432 ngx_time_t *tp;
432 ngx_core_conf_t *ccf; 433 ngx_core_conf_t *ccf;
433 ngx_event_conf_t *ecf; 434 ngx_event_conf_t *ecf;
434 435
435 cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module); 436 cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module);
436 437
490 /* cl should be equal or bigger than cache line size */ 491 /* cl should be equal or bigger than cache line size */
491 492
492 cl = 128; 493 cl = 128;
493 494
494 size = cl /* ngx_accept_mutex */ 495 size = cl /* ngx_accept_mutex */
495 + cl; /* ngx_connection_counter */ 496 + cl /* ngx_connection_counter */
497 + cl; /* ngx_temp_number */
496 498
497 #if (NGX_STAT_STUB) 499 #if (NGX_STAT_STUB)
498 500
499 size += cl /* ngx_stat_accepted */ 501 size += cl /* ngx_stat_accepted */
500 + cl /* ngx_stat_handled */ 502 + cl /* ngx_stat_handled */
524 return NGX_ERROR; 526 return NGX_ERROR;
525 } 527 }
526 528
527 ngx_connection_counter = (ngx_atomic_t *) (shared + 1 * cl); 529 ngx_connection_counter = (ngx_atomic_t *) (shared + 1 * cl);
528 530
529 #if (NGX_STAT_STUB)
530
531 ngx_stat_accepted = (ngx_atomic_t *) (shared + 2 * cl);
532 ngx_stat_handled = (ngx_atomic_t *) (shared + 3 * cl);
533 ngx_stat_requests = (ngx_atomic_t *) (shared + 4 * cl);
534 ngx_stat_active = (ngx_atomic_t *) (shared + 5 * cl);
535 ngx_stat_reading = (ngx_atomic_t *) (shared + 6 * cl);
536 ngx_stat_writing = (ngx_atomic_t *) (shared + 7 * cl);
537
538 #endif
539
540 (void) ngx_atomic_cmp_set(ngx_connection_counter, 0, 1); 531 (void) ngx_atomic_cmp_set(ngx_connection_counter, 0, 1);
541 532
542 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, 533 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
543 "counter: %p, %d", 534 "counter: %p, %d",
544 ngx_connection_counter, *ngx_connection_counter); 535 ngx_connection_counter, *ngx_connection_counter);
536
537 ngx_temp_number = (ngx_atomic_t *) (shared + 2 * cl);
538
539 tp = ngx_timeofday();
540
541 ngx_random_number = (tp->msec << 16) + ngx_pid;
542
543 #if (NGX_STAT_STUB)
544
545 ngx_stat_accepted = (ngx_atomic_t *) (shared + 3 * cl);
546 ngx_stat_handled = (ngx_atomic_t *) (shared + 4 * cl);
547 ngx_stat_requests = (ngx_atomic_t *) (shared + 5 * cl);
548 ngx_stat_active = (ngx_atomic_t *) (shared + 6 * cl);
549 ngx_stat_reading = (ngx_atomic_t *) (shared + 7 * cl);
550 ngx_stat_writing = (ngx_atomic_t *) (shared + 8 * cl);
551
552 #endif
545 553
546 return NGX_OK; 554 return NGX_OK;
547 } 555 }
548 556
549 557