Mercurial > hg > nginx-quic
comparison src/os/unix/ngx_freebsd_init.c @ 673:b80f94fa2197 release-0.3.58
nginx-0.3.58-RELEASE import
*) Feature: the "error_page" directive supports the variables.
*) Change: now the procfs interface instead of sysctl is used on Linux.
*) Change: now the "Content-Type" header line is inherited from first
response when the "X-Accel-Redirect" was used.
*) Bugfix: the "error_page" directive did not redirect the 413 error.
*) Bugfix: the trailing "?" did not remove old arguments if no new
arguments were added to a rewritten URI.
*) Bugfix: nginx could not run on 64-bit FreeBSD 7.0-CURRENT.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 14 Aug 2006 15:09:38 +0000 |
parents | 818fbd4750b9 |
children | 0b592a68aade |
comparison
equal
deleted
inserted
replaced
672:9542722efd0d | 673:b80f94fa2197 |
---|---|
7 #include <ngx_config.h> | 7 #include <ngx_config.h> |
8 #include <ngx_core.h> | 8 #include <ngx_core.h> |
9 | 9 |
10 | 10 |
11 /* FreeBSD 3.0 at least */ | 11 /* FreeBSD 3.0 at least */ |
12 char ngx_freebsd_kern_ostype[16]; | 12 char ngx_freebsd_kern_ostype[16]; |
13 char ngx_freebsd_kern_osrelease[128]; | 13 char ngx_freebsd_kern_osrelease[128]; |
14 int ngx_freebsd_kern_osreldate; | 14 int ngx_freebsd_kern_osreldate; |
15 int ngx_freebsd_hw_ncpu; | 15 int ngx_freebsd_hw_ncpu; |
16 int ngx_freebsd_net_inet_tcp_sendspace; | 16 int ngx_freebsd_kern_ipc_somaxconn; |
17 int ngx_freebsd_kern_ipc_somaxconn; | 17 u_long ngx_freebsd_net_inet_tcp_sendspace; |
18 | 18 |
19 /* FreeBSD 4.9 */ | 19 /* FreeBSD 4.9 */ |
20 int ngx_freebsd_machdep_hlt_logical_cpus; | 20 int ngx_freebsd_machdep_hlt_logical_cpus; |
21 | 21 |
22 /* FreeBSD 5.0 */ | 22 /* FreeBSD 5.0 */ |
23 int ngx_freebsd_kern_ipc_zero_copy_send; | 23 int ngx_freebsd_kern_ipc_zero_copy_send; |
24 | 24 |
25 | 25 |
26 ngx_uint_t ngx_freebsd_sendfile_nbytes_bug; | 26 ngx_uint_t ngx_freebsd_sendfile_nbytes_bug; |
27 ngx_uint_t ngx_freebsd_use_tcp_nopush; | 27 ngx_uint_t ngx_freebsd_use_tcp_nopush; |
28 | 28 |
41 }; | 41 }; |
42 | 42 |
43 | 43 |
44 typedef struct { | 44 typedef struct { |
45 char *name; | 45 char *name; |
46 int *value; | 46 void *value; |
47 size_t size; | 47 size_t size; |
48 ngx_uint_t exists; | 48 ngx_uint_t exists; |
49 } sysctl_t; | 49 } sysctl_t; |
50 | 50 |
51 | 51 |
52 sysctl_t sysctls[] = { | 52 sysctl_t sysctls[] = { |
53 { "hw.ncpu", | 53 { "hw.ncpu", |
54 &ngx_freebsd_hw_ncpu, | 54 &ngx_freebsd_hw_ncpu, |
55 sizeof(int), 0 }, | 55 sizeof(ngx_freebsd_hw_ncpu), 0 }, |
56 | 56 |
57 { "machdep.hlt_logical_cpus", | 57 { "machdep.hlt_logical_cpus", |
58 &ngx_freebsd_machdep_hlt_logical_cpus, | 58 &ngx_freebsd_machdep_hlt_logical_cpus, |
59 sizeof(int), 0 }, | 59 sizeof(ngx_freebsd_machdep_hlt_logical_cpus), 0 }, |
60 | 60 |
61 { "net.inet.tcp.sendspace", | 61 { "net.inet.tcp.sendspace", |
62 &ngx_freebsd_net_inet_tcp_sendspace, | 62 &ngx_freebsd_net_inet_tcp_sendspace, |
63 sizeof(int), 0 }, | 63 sizeof(ngx_freebsd_net_inet_tcp_sendspace), 0 }, |
64 | 64 |
65 { "kern.ipc.somaxconn", | 65 { "kern.ipc.somaxconn", |
66 &ngx_freebsd_kern_ipc_somaxconn, | 66 &ngx_freebsd_kern_ipc_somaxconn, |
67 sizeof(int), 0 }, | 67 sizeof(ngx_freebsd_kern_ipc_somaxconn), 0 }, |
68 | 68 |
69 { "kern.ipc.zero_copy.send", | 69 { "kern.ipc.zero_copy.send", |
70 &ngx_freebsd_kern_ipc_zero_copy_send, | 70 &ngx_freebsd_kern_ipc_zero_copy_send, |
71 sizeof(int), 0 }, | 71 sizeof(ngx_freebsd_kern_ipc_zero_copy_send), 0 }, |
72 | 72 |
73 { NULL, NULL, 0, 0 } | 73 { NULL, NULL, 0, 0 } |
74 }; | 74 }; |
75 | 75 |
76 | 76 |
175 ngx_freebsd_use_tcp_nopush = 1; | 175 ngx_freebsd_use_tcp_nopush = 1; |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 for (i = 0; sysctls[i].name; i++) { | 179 for (i = 0; sysctls[i].name; i++) { |
180 *sysctls[i].value = 0; | |
181 size = sysctls[i].size; | 180 size = sysctls[i].size; |
182 | 181 |
183 if (sysctlbyname(sysctls[i].name, sysctls[i].value, &size, NULL, 0) | 182 if (sysctlbyname(sysctls[i].name, sysctls[i].value, &size, NULL, 0) |
184 == 0) | 183 == 0) |
185 { | 184 { |
186 sysctls[i].exists = 1; | 185 sysctls[i].exists = 1; |
187 continue; | 186 continue; |
188 } | 187 } |
189 | 188 |
191 | 190 |
192 if (err == NGX_ENOENT) { | 191 if (err == NGX_ENOENT) { |
193 continue; | 192 continue; |
194 } | 193 } |
195 | 194 |
196 #if 0 | |
197 if (sysctls[i].value == &ngx_freebsd_machdep_hlt_logical_cpus) { | |
198 continue; | |
199 } | |
200 #endif | |
201 | |
202 ngx_log_error(NGX_LOG_ALERT, log, err, | 195 ngx_log_error(NGX_LOG_ALERT, log, err, |
203 "sysctlbyname(%s) failed", sysctls[i].name); | 196 "sysctlbyname(%s) failed", sysctls[i].name); |
204 return NGX_ERROR; | 197 return NGX_ERROR; |
205 } | 198 } |
206 | 199 |
207 if (ngx_freebsd_machdep_hlt_logical_cpus) { | 200 if (ngx_freebsd_machdep_hlt_logical_cpus) { |
208 ngx_ncpu = ngx_freebsd_hw_ncpu / 2; | 201 ngx_ncpu = ngx_freebsd_hw_ncpu / 2; |
202 | |
209 } else { | 203 } else { |
210 ngx_ncpu = ngx_freebsd_hw_ncpu; | 204 ngx_ncpu = ngx_freebsd_hw_ncpu; |
211 } | 205 } |
212 | 206 |
213 if (version < 600008) { | 207 somaxconn = version < 600008 ? 32676 : 65535; |
214 somaxconn = 32767; | |
215 } else { | |
216 somaxconn = 65535; | |
217 } | |
218 | 208 |
219 if (ngx_freebsd_kern_ipc_somaxconn > somaxconn) { | 209 if (ngx_freebsd_kern_ipc_somaxconn > somaxconn) { |
220 ngx_log_error(NGX_LOG_ALERT, log, 0, | 210 ngx_log_error(NGX_LOG_ALERT, log, 0, |
221 "sysctl kern.ipc.somaxconn must be no more than %d", | 211 "sysctl kern.ipc.somaxconn must be no more than %d", |
222 somaxconn); | 212 somaxconn); |
232 | 222 |
233 | 223 |
234 void | 224 void |
235 ngx_os_specific_status(ngx_log_t *log) | 225 ngx_os_specific_status(ngx_log_t *log) |
236 { | 226 { |
227 u_long value; | |
237 ngx_uint_t i; | 228 ngx_uint_t i; |
238 | 229 |
239 ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s", | 230 ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s", |
240 ngx_freebsd_kern_ostype, ngx_freebsd_kern_osrelease); | 231 ngx_freebsd_kern_ostype, ngx_freebsd_kern_osrelease); |
241 | 232 |
249 ngx_freebsd_kern_osreldate, __FreeBSD_version); | 240 ngx_freebsd_kern_osreldate, __FreeBSD_version); |
250 #endif | 241 #endif |
251 | 242 |
252 for (i = 0; sysctls[i].name; i++) { | 243 for (i = 0; sysctls[i].name; i++) { |
253 if (sysctls[i].exists) { | 244 if (sysctls[i].exists) { |
254 ngx_log_error(NGX_LOG_NOTICE, log, 0, "%s: %d", | 245 if (sysctls[i].size == sizeof(long)) { |
255 sysctls[i].name, *sysctls[i].value); | 246 value = *(long *) sysctls[i].value; |
247 | |
248 } else { | |
249 value = *(int *) sysctls[i].value; | |
250 } | |
251 | |
252 ngx_log_error(NGX_LOG_NOTICE, log, 0, "%s: %l", | |
253 sysctls[i].name, value); | |
256 } | 254 } |
257 } | 255 } |
258 } | 256 } |