Mercurial > hg > nginx
comparison src/os/unix/ngx_freebsd_init.c @ 99:a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 02 Jun 2003 15:24:30 +0000 |
parents | 70d2345a903f |
children | 2e069b6e6920 |
comparison
equal
deleted
inserted
replaced
98:c9b243802a17 | 99:a059e1aa65d4 |
---|---|
7 char ngx_freebsd_kern_osrelease[20]; | 7 char ngx_freebsd_kern_osrelease[20]; |
8 int ngx_freebsd_kern_osreldate; | 8 int ngx_freebsd_kern_osreldate; |
9 int ngx_freebsd_hw_ncpu; | 9 int ngx_freebsd_hw_ncpu; |
10 int ngx_freebsd_net_inet_tcp_sendspace; | 10 int ngx_freebsd_net_inet_tcp_sendspace; |
11 int ngx_freebsd_sendfile_nbytes_bug; | 11 int ngx_freebsd_sendfile_nbytes_bug; |
12 int ngx_freebsd_tcp_nopush_flush; | |
12 | 13 |
13 /* FreeBSD 5.0 */ | 14 /* FreeBSD 5.0 */ |
14 int ngx_freebsd_kern_ipc_zero_copy_send; | 15 int ngx_freebsd_kern_ipc_zero_copy_send; |
15 | 16 |
16 | 17 |
37 | 38 |
38 {"net.inet.tcp.sendspace", | 39 {"net.inet.tcp.sendspace", |
39 &ngx_freebsd_net_inet_tcp_sendspace, | 40 &ngx_freebsd_net_inet_tcp_sendspace, |
40 sizeof(int)}, | 41 sizeof(int)}, |
41 | 42 |
43 /* FreeBSD 5.0 */ | |
44 | |
42 {"kern.ipc.zero_copy.send", | 45 {"kern.ipc.zero_copy.send", |
43 &ngx_freebsd_kern_ipc_zero_copy_send, | 46 &ngx_freebsd_kern_ipc_zero_copy_send, |
44 sizeof(int)}, | 47 sizeof(int)}, |
45 | 48 |
46 {NULL, NULL, 0} | 49 {NULL, NULL, 0} |
47 }; | 50 }; |
48 | 51 |
49 | 52 |
50 int ngx_os_init(ngx_log_t *log) | 53 int ngx_os_init(ngx_log_t *log) |
51 { | 54 { |
52 int i; | 55 int i, version; |
53 size_t size; | 56 size_t size; |
54 ngx_err_t err; | 57 ngx_err_t err; |
55 | 58 |
56 size = 20; | 59 size = 20; |
57 if (sysctlbyname("kern.ostype", | 60 if (sysctlbyname("kern.ostype", |
79 ngx_log_error(NGX_LOG_ALERT, log, errno, | 82 ngx_log_error(NGX_LOG_ALERT, log, errno, |
80 "sysctlbyname(kern.osreldate) failed"); | 83 "sysctlbyname(kern.osreldate) failed"); |
81 return NGX_ERROR; | 84 return NGX_ERROR; |
82 } | 85 } |
83 | 86 |
87 version = ngx_freebsd_kern_osreldate; | |
88 | |
84 ngx_log_error(NGX_LOG_INFO, log, 0, | 89 ngx_log_error(NGX_LOG_INFO, log, 0, |
85 "kern.osreldate: %d, built on %d", | 90 "kern.osreldate: %d, built on %d", |
86 ngx_freebsd_kern_osreldate, __FreeBSD_version); | 91 version, __FreeBSD_version); |
87 | 92 |
88 | 93 |
89 #if (HAVE_FREEBSD_SENDFILE) | 94 #if (HAVE_FREEBSD_SENDFILE) |
90 | 95 |
91 /* The determination of the sendfile() nbytes bug is complex enough. | 96 /* The determination of the sendfile() nbytes bug is complex enough. |
92 There're two sendfile() syscalls: a new 393 has no bug while | 97 There're two sendfile() syscalls: a new 393 has no bug while |
93 an old 336 has the bug in some versions and has not in others. | 98 an old 336 has the bug in some versions and has not in others. |
94 libc_r wrapper also emulates the bug in some versions. | 99 Besides libc_r wrapper also emulates the bug in some versions. |
95 There's no way to say exactly if a given FreeBSD version has bug. | 100 There's no way to say exactly if a given FreeBSD version has bug. |
96 Here is the algorithm that work at least for RELEASEs | 101 Here is the algorithm that works at least for RELEASEs |
97 and for syscalls only (not libc_r wrapper). */ | 102 and for syscalls only (not libc_r wrapper). */ |
98 | 103 |
99 /* detect was the new sendfile() version available at the compile time | 104 /* detect the new sendfile() version available at the compile time |
100 to allow an old binary to run correctly on an updated FreeBSD system. */ | 105 to allow an old binary to run correctly on an updated FreeBSD system. */ |
101 | 106 |
102 #if (__FreeBSD__ == 4 && __FreeBSD_version >= 460102) \ | 107 #if (__FreeBSD__ == 4 && __FreeBSD_version >= 460102) \ |
103 || __FreeBSD_version == 460002 || __FreeBSD_version >= 500039 | 108 || __FreeBSD_version == 460002 || __FreeBSD_version >= 500039 |
104 | 109 |
111 ngx_freebsd_sendfile_nbytes_bug = 1; | 116 ngx_freebsd_sendfile_nbytes_bug = 1; |
112 | 117 |
113 #endif | 118 #endif |
114 | 119 |
115 #endif /* HAVE_FREEBSD_SENDFILE */ | 120 #endif /* HAVE_FREEBSD_SENDFILE */ |
121 | |
122 | |
123 if ((version < 500000 && version >= 440003) || version >= 500017) { | |
124 ngx_freebsd_tcp_nopush_flush = 1; | |
125 } | |
116 | 126 |
117 | 127 |
118 for (i = 0; sysctls[i].name; i++) { | 128 for (i = 0; sysctls[i].name; i++) { |
119 *sysctls[i].value = 0; | 129 *sysctls[i].value = 0; |
120 size = sysctls[i].size; | 130 size = sysctls[i].size; |