Mercurial > hg > nginx
comparison src/os/unix/ngx_freebsd_sendfile_chain.c @ 290:87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 16 Mar 2004 07:10:12 +0000 |
parents | d4e65d74db9f |
children | ee394e997c77 |
comparison
equal
deleted
inserted
replaced
289:0750faf8d7e3 | 290:87e73f067470 |
---|---|
12 /* | 12 /* |
13 * Although FreeBSD sendfile() allows to pass a header and a trailer | 13 * Although FreeBSD sendfile() allows to pass a header and a trailer |
14 * it never sends a header with a part of the file in one packet until | 14 * it never sends a header with a part of the file in one packet until |
15 * FreeBSD 5.2-STABLE. Besides over the fast ethernet connection sendfile() | 15 * FreeBSD 5.2-STABLE. Besides over the fast ethernet connection sendfile() |
16 * can send the partially filled packets, i.e. the 8 file pages can be sent | 16 * can send the partially filled packets, i.e. the 8 file pages can be sent |
17 * as 11 full 1460-bytes packets, then one incomplete 324-bytes packet, and | 17 * as the 11 full 1460-bytes packets, then one incomplete 324-bytes packet, |
18 * then again 11 full 1460-bytes packets. | 18 * and then again the 11 full 1460-bytes packets. |
19 * | 19 * |
20 * So we use the TCP_NOPUSH option (similar to Linux's TCP_CORK) | 20 * So we use the TCP_NOPUSH option (similar to Linux's TCP_CORK) |
21 * to postpone the sending - it not only sends a header and the first part | 21 * to postpone the sending - it not only sends a header and the first part |
22 * of the file in one packet but also sends file pages in the full packets. | 22 * of the file in one packet but also sends file pages in the full packets. |
23 * | 23 * |
29 | 29 |
30 | 30 |
31 ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) | 31 ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) |
32 { | 32 { |
33 int rc; | 33 int rc; |
34 char *prev; | 34 u_char *prev; |
35 off_t sent, fprev; | 35 off_t sent, fprev; |
36 size_t hsize, fsize; | 36 size_t hsize, fsize; |
37 ssize_t size; | 37 ssize_t size; |
38 ngx_int_t eintr, eagain; | 38 ngx_int_t eintr, eagain; |
39 struct iovec *iov; | 39 struct iovec *iov; |
91 if (prev == cl->hunk->pos) { | 91 if (prev == cl->hunk->pos) { |
92 iov->iov_len += cl->hunk->last - cl->hunk->pos; | 92 iov->iov_len += cl->hunk->last - cl->hunk->pos; |
93 | 93 |
94 } else { | 94 } else { |
95 ngx_test_null(iov, ngx_push_array(&header), NGX_CHAIN_ERROR); | 95 ngx_test_null(iov, ngx_push_array(&header), NGX_CHAIN_ERROR); |
96 iov->iov_base = cl->hunk->pos; | 96 iov->iov_base = (void *) cl->hunk->pos; |
97 iov->iov_len = cl->hunk->last - cl->hunk->pos; | 97 iov->iov_len = cl->hunk->last - cl->hunk->pos; |
98 } | 98 } |
99 | 99 |
100 prev = cl->hunk->last; | 100 prev = cl->hunk->last; |
101 hsize += cl->hunk->last - cl->hunk->pos; | 101 hsize += cl->hunk->last - cl->hunk->pos; |
143 iov->iov_len += cl->hunk->last - cl->hunk->pos; | 143 iov->iov_len += cl->hunk->last - cl->hunk->pos; |
144 | 144 |
145 } else { | 145 } else { |
146 ngx_test_null(iov, ngx_push_array(&trailer), | 146 ngx_test_null(iov, ngx_push_array(&trailer), |
147 NGX_CHAIN_ERROR); | 147 NGX_CHAIN_ERROR); |
148 iov->iov_base = cl->hunk->pos; | 148 iov->iov_base = (void *) cl->hunk->pos; |
149 iov->iov_len = cl->hunk->last - cl->hunk->pos; | 149 iov->iov_len = cl->hunk->last - cl->hunk->pos; |
150 } | 150 } |
151 | 151 |
152 prev = cl->hunk->last; | 152 prev = cl->hunk->last; |
153 } | 153 } |