Mercurial > hg > nginx-vendor-current
comparison src/os/unix/ngx_darwin_init.c @ 390:0b6053502c55 NGINX_0_7_7
nginx 0.7.7
*) Change: now the EAGAIN error returned by connect() is not considered
as temporary error.
*) Change: now the $ssl_client_cert variable value is a certificate
with TAB character intended before each line except first one; an
unchanged certificate is available in the $ssl_client_raw_cert
variable.
*) Feature: the "ask" parameter in the "ssl_verify_client" directive.
*) Feature: byte-range processing improvements.
Thanks to Maxim Dounin.
*) Feature: the "directio" directive.
*) Feature: MacOSX 1.5 sendfile() support.
*) Bugfix: now in MacOSX and Cygwin locations are tested in case
insensitive mode; however, the compare is provided by single-byte
locales only.
*) Bugfix: mail proxy SSL connections hanged, if select, poll, or
/dev/poll methods were used.
*) Bugfix: UTF-8 encoding usage in the ngx_http_autoindex_module.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 30 Jul 2008 00:00:00 +0400 |
parents | |
children | ff86d646f9df |
comparison
equal
deleted
inserted
replaced
389:930e48a26dde | 390:0b6053502c55 |
---|---|
1 | |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 | |
10 | |
11 char ngx_darwin_kern_ostype[16]; | |
12 char ngx_darwin_kern_osrelease[128]; | |
13 int ngx_darwin_hw_ncpu; | |
14 int ngx_darwin_kern_ipc_somaxconn; | |
15 u_long ngx_darwin_net_inet_tcp_sendspace; | |
16 | |
17 | |
18 static ngx_os_io_t ngx_darwin_io = { | |
19 ngx_unix_recv, | |
20 ngx_readv_chain, | |
21 ngx_udp_unix_recv, | |
22 ngx_unix_send, | |
23 #if (NGX_HAVE_SENDFILE) | |
24 ngx_darwin_sendfile_chain, | |
25 NGX_IO_SENDFILE | |
26 #else | |
27 ngx_writev_chain, | |
28 0 | |
29 #endif | |
30 }; | |
31 | |
32 | |
33 typedef struct { | |
34 char *name; | |
35 void *value; | |
36 size_t size; | |
37 ngx_uint_t exists; | |
38 } sysctl_t; | |
39 | |
40 | |
41 sysctl_t sysctls[] = { | |
42 { "hw.ncpu", | |
43 &ngx_darwin_hw_ncpu, | |
44 sizeof(ngx_darwin_hw_ncpu), 0 }, | |
45 | |
46 { "net.inet.tcp.sendspace", | |
47 &ngx_darwin_net_inet_tcp_sendspace, | |
48 sizeof(ngx_darwin_net_inet_tcp_sendspace), 0 }, | |
49 | |
50 { "kern.ipc.somaxconn", | |
51 &ngx_darwin_kern_ipc_somaxconn, | |
52 sizeof(ngx_darwin_kern_ipc_somaxconn), 0 }, | |
53 | |
54 { NULL, NULL, 0, 0 } | |
55 }; | |
56 | |
57 | |
58 ngx_int_t | |
59 ngx_os_specific_init(ngx_log_t *log) | |
60 { | |
61 int somaxconn; | |
62 size_t size; | |
63 ngx_err_t err; | |
64 ngx_uint_t i; | |
65 | |
66 size = sizeof(ngx_darwin_kern_ostype); | |
67 if (sysctlbyname("kern.ostype", | |
68 ngx_darwin_kern_ostype, &size, NULL, 0) == -1) { | |
69 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
70 "sysctlbyname(kern.ostype) failed"); | |
71 | |
72 if (ngx_errno != NGX_ENOMEM) { | |
73 return NGX_ERROR; | |
74 } | |
75 | |
76 ngx_darwin_kern_ostype[size - 1] = '\0'; | |
77 } | |
78 | |
79 size = sizeof(ngx_darwin_kern_osrelease); | |
80 if (sysctlbyname("kern.osrelease", | |
81 ngx_darwin_kern_osrelease, &size, NULL, 0) == -1) { | |
82 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
83 "sysctlbyname(kern.osrelease) failed"); | |
84 | |
85 if (ngx_errno != NGX_ENOMEM) { | |
86 return NGX_ERROR; | |
87 } | |
88 | |
89 ngx_darwin_kern_osrelease[size - 1] = '\0'; | |
90 } | |
91 | |
92 | |
93 for (i = 0; sysctls[i].name; i++) { | |
94 size = sysctls[i].size; | |
95 | |
96 if (sysctlbyname(sysctls[i].name, sysctls[i].value, &size, NULL, 0) | |
97 == 0) | |
98 { | |
99 sysctls[i].exists = 1; | |
100 continue; | |
101 } | |
102 | |
103 err = ngx_errno; | |
104 | |
105 if (err == NGX_ENOENT) { | |
106 continue; | |
107 } | |
108 | |
109 ngx_log_error(NGX_LOG_ALERT, log, err, | |
110 "sysctlbyname(%s) failed", sysctls[i].name); | |
111 return NGX_ERROR; | |
112 } | |
113 | |
114 ngx_ncpu = ngx_darwin_hw_ncpu; | |
115 | |
116 somaxconn = 32676; | |
117 | |
118 if (ngx_darwin_kern_ipc_somaxconn > somaxconn) { | |
119 ngx_log_error(NGX_LOG_ALERT, log, 0, | |
120 "sysctl kern.ipc.somaxconn must be no more than %d", | |
121 somaxconn); | |
122 return NGX_ERROR; | |
123 } | |
124 | |
125 ngx_tcp_nodelay_and_tcp_nopush = 1; | |
126 | |
127 ngx_os_io = ngx_darwin_io; | |
128 | |
129 return NGX_OK; | |
130 } | |
131 | |
132 | |
133 void | |
134 ngx_os_specific_status(ngx_log_t *log) | |
135 { | |
136 u_long value; | |
137 ngx_uint_t i; | |
138 | |
139 ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s", | |
140 ngx_darwin_kern_ostype, ngx_darwin_kern_osrelease); | |
141 | |
142 for (i = 0; sysctls[i].name; i++) { | |
143 if (sysctls[i].exists) { | |
144 if (sysctls[i].size == sizeof(long)) { | |
145 value = *(long *) sysctls[i].value; | |
146 | |
147 } else { | |
148 value = *(int *) sysctls[i].value; | |
149 } | |
150 | |
151 ngx_log_error(NGX_LOG_NOTICE, log, 0, "%s: %l", | |
152 sysctls[i].name, value); | |
153 } | |
154 } | |
155 } |