comparison src/os/unix/ngx_darwin_init.c @ 646:615b5ea36fc0 NGINX_1_1_7

nginx 1.1.7 *) Feature: support of several resolvers in the "resolver" directive. Thanks to Kirill A. Korinskiy. *) Bugfix: a segmentation fault occurred on start or while reconfiguration if the "ssl" directive was used at http level and there was no "ssl_certificate" defined. *) Bugfix: reduced memory consumption while proxying of big files if they were buffered to disk. *) Bugfix: a segmentation fault might occur in a worker process if "proxy_http_version 1.1" directive was used. *) Bugfix: in the "expires @time" directive.
author Igor Sysoev <http://sysoev.ru>
date Mon, 31 Oct 2011 00:00:00 +0400
parents ff86d646f9df
children d0f7a625f27c
comparison
equal deleted inserted replaced
645:e461dead01e9 646:615b5ea36fc0
11 char ngx_darwin_kern_ostype[16]; 11 char ngx_darwin_kern_ostype[16];
12 char ngx_darwin_kern_osrelease[128]; 12 char ngx_darwin_kern_osrelease[128];
13 int ngx_darwin_hw_ncpu; 13 int ngx_darwin_hw_ncpu;
14 int ngx_darwin_kern_ipc_somaxconn; 14 int ngx_darwin_kern_ipc_somaxconn;
15 u_long ngx_darwin_net_inet_tcp_sendspace; 15 u_long ngx_darwin_net_inet_tcp_sendspace;
16
17 ngx_uint_t ngx_debug_malloc;
16 18
17 19
18 static ngx_os_io_t ngx_darwin_io = { 20 static ngx_os_io_t ngx_darwin_io = {
19 ngx_unix_recv, 21 ngx_unix_recv,
20 ngx_readv_chain, 22 ngx_readv_chain,
53 55
54 { NULL, NULL, 0, 0 } 56 { NULL, NULL, 0, 0 }
55 }; 57 };
56 58
57 59
60 void
61 ngx_debug_init()
62 {
63 #if (NGX_DEBUG_MALLOC)
64
65 /*
66 * MacOSX 10.6, 10.7: MallocScribble fills freed memory with 0x55
67 * and fills allocated memory with 0xAA.
68 * MacOSX 10.4, 10.5: MallocScribble fills freed memory with 0x55,
69 * MallocPreScribble fills allocated memory with 0xAA.
70 * MacOSX 10.3: MallocScribble fills freed memory with 0x55,
71 * and no way to fill allocated memory.
72 */
73
74 setenv("MallocScribble", "1", 0);
75
76 ngx_debug_malloc = 1;
77
78 #else
79
80 if (getenv("MallocScribble")) {
81 ngx_debug_malloc = 1;
82 }
83
84 #endif
85 }
86
87
58 ngx_int_t 88 ngx_int_t
59 ngx_os_specific_init(ngx_log_t *log) 89 ngx_os_specific_init(ngx_log_t *log)
60 { 90 {
61 int somaxconn;
62 size_t size; 91 size_t size;
63 ngx_err_t err; 92 ngx_err_t err;
64 ngx_uint_t i; 93 ngx_uint_t i;
65 94
66 size = sizeof(ngx_darwin_kern_ostype); 95 size = sizeof(ngx_darwin_kern_ostype);
123 return NGX_ERROR; 152 return NGX_ERROR;
124 } 153 }
125 154
126 ngx_ncpu = ngx_darwin_hw_ncpu; 155 ngx_ncpu = ngx_darwin_hw_ncpu;
127 156
128 somaxconn = 32676; 157 if (ngx_darwin_kern_ipc_somaxconn > 32767) {
129
130 if (ngx_darwin_kern_ipc_somaxconn > somaxconn) {
131 ngx_log_error(NGX_LOG_ALERT, log, 0, 158 ngx_log_error(NGX_LOG_ALERT, log, 0,
132 "sysctl kern.ipc.somaxconn must be no more than %d", 159 "sysctl kern.ipc.somaxconn must be less than 32768");
133 somaxconn);
134 return NGX_ERROR; 160 return NGX_ERROR;
135 } 161 }
136 162
137 ngx_tcp_nodelay_and_tcp_nopush = 1; 163 ngx_tcp_nodelay_and_tcp_nopush = 1;
138 164