Mercurial > hg > nginx
annotate src/os/unix/ngx_freebsd_init.c @ 8837:8f0f6407ae23 quic
QUIC: Stateless Reset Token debug logging cleanup.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 24 Aug 2021 14:41:31 +0300 |
parents | 56fc55e32f23 |
children |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
6 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
183
4c698194c56d
nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
8 #include <ngx_config.h> |
4c698194c56d
nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
9 #include <ngx_core.h> |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
12 /* FreeBSD 3.0 at least */ |
673 | 13 char ngx_freebsd_kern_ostype[16]; |
14 char ngx_freebsd_kern_osrelease[128]; | |
15 int ngx_freebsd_kern_osreldate; | |
16 int ngx_freebsd_hw_ncpu; | |
17 int ngx_freebsd_kern_ipc_somaxconn; | |
18 u_long ngx_freebsd_net_inet_tcp_sendspace; | |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
19 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
20 /* FreeBSD 4.9 */ |
673 | 21 int ngx_freebsd_machdep_hlt_logical_cpus; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 |
1771
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
24 ngx_uint_t ngx_freebsd_sendfile_nbytes_bug; |
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
25 ngx_uint_t ngx_freebsd_use_tcp_nopush; |
4223
1b779cb69dc8
malloc() debugging on MacOSX.
Igor Sysoev <igor@sysoev.ru>
parents:
2414
diff
changeset
|
26 |
1b779cb69dc8
malloc() debugging on MacOSX.
Igor Sysoev <igor@sysoev.ru>
parents:
2414
diff
changeset
|
27 ngx_uint_t ngx_debug_malloc; |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
28 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
29 |
539 | 30 static ngx_os_io_t ngx_freebsd_io = { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
31 ngx_unix_recv, |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
32 ngx_readv_chain, |
1689 | 33 ngx_udp_unix_recv, |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
34 ngx_unix_send, |
6436 | 35 ngx_udp_unix_send, |
6692 | 36 ngx_udp_unix_sendmsg_chain, |
469 | 37 #if (NGX_HAVE_SENDFILE) |
94
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
38 ngx_freebsd_sendfile_chain, |
196
11fbd0fc041d
nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
39 NGX_IO_SENDFILE |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
40 #else |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
41 ngx_writev_chain, |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
183
diff
changeset
|
42 0 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
43 #endif |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
44 }; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
45 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
46 |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
47 typedef struct { |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
48 char *name; |
673 | 49 void *value; |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
50 size_t size; |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
51 ngx_uint_t exists; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
52 } sysctl_t; |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
53 |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
54 |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
55 sysctl_t sysctls[] = { |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
56 { "hw.ncpu", |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
57 &ngx_freebsd_hw_ncpu, |
673 | 58 sizeof(ngx_freebsd_hw_ncpu), 0 }, |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
59 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
60 { "machdep.hlt_logical_cpus", |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
61 &ngx_freebsd_machdep_hlt_logical_cpus, |
673 | 62 sizeof(ngx_freebsd_machdep_hlt_logical_cpus), 0 }, |
373
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
63 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
64 { "net.inet.tcp.sendspace", |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
65 &ngx_freebsd_net_inet_tcp_sendspace, |
673 | 66 sizeof(ngx_freebsd_net_inet_tcp_sendspace), 0 }, |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
67 |
501 | 68 { "kern.ipc.somaxconn", |
69 &ngx_freebsd_kern_ipc_somaxconn, | |
673 | 70 sizeof(ngx_freebsd_kern_ipc_somaxconn), 0 }, |
501 | 71 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
72 { NULL, NULL, 0, 0 } |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
73 }; |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
74 |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
75 |
539 | 76 void |
5225
15a7deeaa19a
Use "void" for functions with empty parameter list.
Sergey Kandaurov <pluknet@nginx.com>
parents:
4645
diff
changeset
|
77 ngx_debug_init(void) |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
78 { |
547 | 79 #if (NGX_DEBUG_MALLOC) |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
80 |
4645
f329a1d2127b
Fixed compilation with -DNGX_DEBUG_MALLOC on FreeBSD 10.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
81 #if __FreeBSD_version >= 500014 && __FreeBSD_version < 1000011 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
82 _malloc_options = "J"; |
4645
f329a1d2127b
Fixed compilation with -DNGX_DEBUG_MALLOC on FreeBSD 10.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
83 #elif __FreeBSD_version < 500014 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
84 malloc_options = "J"; |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
85 #endif |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
86 |
4223
1b779cb69dc8
malloc() debugging on MacOSX.
Igor Sysoev <igor@sysoev.ru>
parents:
2414
diff
changeset
|
87 ngx_debug_malloc = 1; |
1771
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
88 |
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
89 #else |
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
90 char *mo; |
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
91 |
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
92 mo = getenv("MALLOC_OPTIONS"); |
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
93 |
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
94 if (mo && ngx_strchr(mo, 'J')) { |
4223
1b779cb69dc8
malloc() debugging on MacOSX.
Igor Sysoev <igor@sysoev.ru>
parents:
2414
diff
changeset
|
95 ngx_debug_malloc = 1; |
1771
b794d78e52c5
take MALLOC_OPTIONS=J into account in slab allocator
Igor Sysoev <igor@sysoev.ru>
parents:
1689
diff
changeset
|
96 } |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
97 #endif |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
98 } |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
99 |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
100 |
539 | 101 ngx_int_t |
102 ngx_os_specific_init(ngx_log_t *log) | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 { |
4226
003f0f341edf
Fixed range checking for the "somaxconn" sysctl.
Ruslan Ermilov <ru@nginx.com>
parents:
4223
diff
changeset
|
104 int version; |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
105 size_t size; |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
106 ngx_err_t err; |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
107 ngx_uint_t i; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
109 size = sizeof(ngx_freebsd_kern_ostype); |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
110 if (sysctlbyname("kern.ostype", |
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
111 ngx_freebsd_kern_ostype, &size, NULL, 0) == -1) { |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
112 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
113 "sysctlbyname(kern.ostype) failed"); |
461 | 114 |
115 if (ngx_errno != NGX_ENOMEM) { | |
116 return NGX_ERROR; | |
117 } | |
118 | |
119 ngx_freebsd_kern_ostype[size - 1] = '\0'; | |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
120 } |
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
121 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
122 size = sizeof(ngx_freebsd_kern_osrelease); |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
123 if (sysctlbyname("kern.osrelease", |
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
124 ngx_freebsd_kern_osrelease, &size, NULL, 0) == -1) { |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
125 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
126 "sysctlbyname(kern.osrelease) failed"); |
461 | 127 |
128 if (ngx_errno != NGX_ENOMEM) { | |
129 return NGX_ERROR; | |
130 } | |
131 | |
132 ngx_freebsd_kern_osrelease[size - 1] = '\0'; | |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
133 } |
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
134 |
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
135 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
136 size = sizeof(int); |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
137 if (sysctlbyname("kern.osreldate", |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
138 &ngx_freebsd_kern_osreldate, &size, NULL, 0) == -1) { |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
139 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
140 "sysctlbyname(kern.osreldate) failed"); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
141 return NGX_ERROR; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
144 version = ngx_freebsd_kern_osreldate; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
145 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
146 |
469 | 147 #if (NGX_HAVE_SENDFILE) |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
149 /* |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
150 * The determination of the sendfile() "nbytes bug" is complex enough. |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
151 * There are two sendfile() syscalls: a new #393 has no bug while |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
152 * an old #336 has the bug in some versions and has not in others. |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
153 * Besides libc_r wrapper also emulates the bug in some versions. |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
154 * There is no way to say exactly if syscall #336 in FreeBSD circa 4.6 |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
155 * has the bug. We use the algorithm that is correct at least for |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
156 * RELEASEs and for syscalls only (not libc_r wrapper). |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
157 * |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
158 * 4.6.1-RELEASE and below have the bug |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
159 * 4.6.2-RELEASE and above have the new syscall |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
160 * |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
161 * We detect the new sendfile() syscall available at the compile time |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
162 * to allow an old binary to run correctly on an updated FreeBSD system. |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
163 */ |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 #if (__FreeBSD__ == 4 && __FreeBSD_version >= 460102) \ |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 || __FreeBSD_version == 460002 || __FreeBSD_version >= 500039 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 /* a new syscall without the bug */ |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
169 |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
170 ngx_freebsd_sendfile_nbytes_bug = 0; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 #else |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
174 /* an old syscall that may have the bug */ |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
175 |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
176 ngx_freebsd_sendfile_nbytes_bug = 1; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
177 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 #endif |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 |
469 | 180 #endif /* NGX_HAVE_SENDFILE */ |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
182 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
183 if ((version < 500000 && version >= 440003) || version >= 500017) { |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
184 ngx_freebsd_use_tcp_nopush = 1; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
185 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
186 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
187 |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
188 for (i = 0; sysctls[i].name; i++) { |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
189 size = sysctls[i].size; |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
190 |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
191 if (sysctlbyname(sysctls[i].name, sysctls[i].value, &size, NULL, 0) |
673 | 192 == 0) |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
193 { |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
194 sysctls[i].exists = 1; |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
195 continue; |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
196 } |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
197 |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
198 err = ngx_errno; |
373
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
199 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
200 if (err == NGX_ENOENT) { |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
201 continue; |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
202 } |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
203 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
204 ngx_log_error(NGX_LOG_ALERT, log, err, |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
205 "sysctlbyname(%s) failed", sysctls[i].name); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
206 return NGX_ERROR; |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
207 } |
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
208 |
373
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
209 if (ngx_freebsd_machdep_hlt_logical_cpus) { |
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
210 ngx_ncpu = ngx_freebsd_hw_ncpu / 2; |
673 | 211 |
373
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
212 } else { |
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
213 ngx_ncpu = ngx_freebsd_hw_ncpu; |
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
214 } |
018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
215 |
4226
003f0f341edf
Fixed range checking for the "somaxconn" sysctl.
Ruslan Ermilov <ru@nginx.com>
parents:
4223
diff
changeset
|
216 if (version < 600008 && ngx_freebsd_kern_ipc_somaxconn > 32767) { |
501 | 217 ngx_log_error(NGX_LOG_ALERT, log, 0, |
4226
003f0f341edf
Fixed range checking for the "somaxconn" sysctl.
Ruslan Ermilov <ru@nginx.com>
parents:
4223
diff
changeset
|
218 "sysctl kern.ipc.somaxconn must be less than 32768"); |
501 | 219 return NGX_ERROR; |
220 } | |
452 | 221 |
473 | 222 ngx_tcp_nodelay_and_tcp_nopush = 1; |
223 | |
539 | 224 ngx_os_io = ngx_freebsd_io; |
473 | 225 |
539 | 226 return NGX_OK; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 } |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
228 |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
229 |
539 | 230 void |
231 ngx_os_specific_status(ngx_log_t *log) | |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
232 { |
673 | 233 u_long value; |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
234 ngx_uint_t i; |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
235 |
531 | 236 ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s", |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
237 ngx_freebsd_kern_ostype, ngx_freebsd_kern_osrelease); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
238 |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
239 #ifdef __DragonFly_version |
531 | 240 ngx_log_error(NGX_LOG_NOTICE, log, 0, |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
241 "kern.osreldate: %d, built on %d", |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
242 ngx_freebsd_kern_osreldate, __DragonFly_version); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
243 #else |
531 | 244 ngx_log_error(NGX_LOG_NOTICE, log, 0, |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
245 "kern.osreldate: %d, built on %d", |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
246 ngx_freebsd_kern_osreldate, __FreeBSD_version); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
247 #endif |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
248 |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
249 for (i = 0; sysctls[i].name; i++) { |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
250 if (sysctls[i].exists) { |
673 | 251 if (sysctls[i].size == sizeof(long)) { |
252 value = *(long *) sysctls[i].value; | |
253 | |
254 } else { | |
255 value = *(int *) sysctls[i].value; | |
256 } | |
257 | |
258 ngx_log_error(NGX_LOG_NOTICE, log, 0, "%s: %l", | |
259 sysctls[i].name, value); | |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
260 } |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
261 } |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
262 } |