comparison src/core/ngx_cycle.c @ 635:e67b227c8dbb default tip

Merge with current.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 25 Apr 2011 04:07:55 +0400
parents b9763778e212
children
comparison
equal deleted inserted replaced
578:f3a9e57d2e17 635:e67b227c8dbb
22 22
23 static ngx_pool_t *ngx_temp_pool; 23 static ngx_pool_t *ngx_temp_pool;
24 static ngx_event_t ngx_cleaner_event; 24 static ngx_event_t ngx_cleaner_event;
25 25
26 ngx_uint_t ngx_test_config; 26 ngx_uint_t ngx_test_config;
27 ngx_uint_t ngx_quiet_mode;
27 28
28 #if (NGX_THREADS) 29 #if (NGX_THREADS)
29 ngx_tls_key_t ngx_core_tls_key; 30 ngx_tls_key_t ngx_core_tls_key;
30 #endif 31 #endif
31 32
61 /* force localtime update with a new timezone */ 62 /* force localtime update with a new timezone */
62 63
63 tp = ngx_timeofday(); 64 tp = ngx_timeofday();
64 tp->sec = 0; 65 tp->sec = 0;
65 66
66 ngx_time_update(0, 0); 67 ngx_time_update();
67 68
68 69
69 log = old_cycle->log; 70 log = old_cycle->log;
70 71
71 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log); 72 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log);
176 177
177 cycle->listening.nelts = 0; 178 cycle->listening.nelts = 0;
178 cycle->listening.size = sizeof(ngx_listening_t); 179 cycle->listening.size = sizeof(ngx_listening_t);
179 cycle->listening.nalloc = n; 180 cycle->listening.nalloc = n;
180 cycle->listening.pool = pool; 181 cycle->listening.pool = pool;
182
183
184 ngx_queue_init(&cycle->reusable_connections_queue);
181 185
182 186
183 cycle->conf_ctx = ngx_pcalloc(pool, ngx_max_module * sizeof(void *)); 187 cycle->conf_ctx = ngx_pcalloc(pool, ngx_max_module * sizeof(void *));
184 if (cycle->conf_ctx == NULL) { 188 if (cycle->conf_ctx == NULL) {
185 ngx_destroy_pool(pool); 189 ngx_destroy_pool(pool);
264 environ = senv; 268 environ = senv;
265 ngx_destroy_cycle_pools(&conf); 269 ngx_destroy_cycle_pools(&conf);
266 return NULL; 270 return NULL;
267 } 271 }
268 272
269 if (ngx_test_config) { 273 if (ngx_test_config && !ngx_quiet_mode) {
270 ngx_log_stderr(0, "the configuration file %s syntax is ok", 274 ngx_log_stderr(0, "the configuration file %s syntax is ok",
271 cycle->conf_file.data); 275 cycle->conf_file.data);
272 } 276 }
273 277
274 for (i = 0; ngx_modules[i]; i++) { 278 for (i = 0; ngx_modules[i]; i++) {
664 if (ngx_close_socket(ls[i].fd) == -1) { 668 if (ngx_close_socket(ls[i].fd) == -1) {
665 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, 669 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
666 ngx_close_socket_n " listening socket on %V failed", 670 ngx_close_socket_n " listening socket on %V failed",
667 &ls[i].addr_text); 671 &ls[i].addr_text);
668 } 672 }
673
674 #if (NGX_HAVE_UNIX_DOMAIN)
675
676 if (ls[i].sockaddr->sa_family == AF_UNIX) {
677 u_char *name;
678
679 name = ls[i].addr_text.data + sizeof("unix:") - 1;
680
681 ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
682 "deleting socket %s", name);
683
684 if (ngx_delete_file(name) == -1) {
685 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
686 ngx_delete_file_n " %s failed", name);
687 }
688 }
689
690 #endif
669 } 691 }
670 692
671 693
672 /* close the unnecessary open files */ 694 /* close the unnecessary open files */
673 695
833 { 855 {
834 struct sockaddr_in *sin1, *sin2; 856 struct sockaddr_in *sin1, *sin2;
835 #if (NGX_HAVE_INET6) 857 #if (NGX_HAVE_INET6)
836 struct sockaddr_in6 *sin61, *sin62; 858 struct sockaddr_in6 *sin61, *sin62;
837 #endif 859 #endif
860 #if (NGX_HAVE_UNIX_DOMAIN)
861 struct sockaddr_un *saun1, *saun2;
862 #endif
838 863
839 if (sa1->sa_family != sa2->sa_family) { 864 if (sa1->sa_family != sa2->sa_family) {
840 return NGX_DECLINED; 865 return NGX_DECLINED;
841 } 866 }
842 867
845 #if (NGX_HAVE_INET6) 870 #if (NGX_HAVE_INET6)
846 case AF_INET6: 871 case AF_INET6:
847 sin61 = (struct sockaddr_in6 *) sa1; 872 sin61 = (struct sockaddr_in6 *) sa1;
848 sin62 = (struct sockaddr_in6 *) sa2; 873 sin62 = (struct sockaddr_in6 *) sa2;
849 874
850 if (sin61->sin6_port != sin61->sin6_port) { 875 if (sin61->sin6_port != sin62->sin6_port) {
851 return NGX_DECLINED; 876 return NGX_DECLINED;
852 } 877 }
853 878
854 if (ngx_memcmp(&sin61->sin6_addr, &sin62->sin6_addr, 16) != 0) { 879 if (ngx_memcmp(&sin61->sin6_addr, &sin62->sin6_addr, 16) != 0) {
855 return NGX_DECLINED; 880 return NGX_DECLINED;
856 } 881 }
857 882
858 break; 883 break;
884 #endif
885
886 #if (NGX_HAVE_UNIX_DOMAIN)
887 case AF_UNIX:
888 saun1 = (struct sockaddr_un *) sa1;
889 saun2 = (struct sockaddr_un *) sa2;
890
891 if (ngx_memcmp(&saun1->sun_path, &saun2->sun_path,
892 sizeof(saun1->sun_path))
893 != 0)
894 {
895 return NGX_DECLINED;
896 }
897
898 break;
859 #endif 899 #endif
860 900
861 default: /* AF_INET */ 901 default: /* AF_INET */
862 902
863 sin1 = (struct sockaddr_in *) sa1; 903 sin1 = (struct sockaddr_in *) sa1;