Mercurial > hg > nginx
annotate src/os/unix/ngx_freebsd_sendfile_chain.c @ 8535:eb5aa85294e9 quic
QUIC: discard unrecognized long packes.
While there, updated comment about discarded packets.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 02 Sep 2020 09:54:15 +0300 |
parents | 400a3412b1e3 |
children | 555533169506 |
rev | line source |
---|---|
272
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
265
diff
changeset
|
1 |
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
265
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. |
272
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
265
diff
changeset
|
5 */ |
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
265
diff
changeset
|
6 |
63
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
9 #include <ngx_core.h> |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
10 #include <ngx_event.h> |
63
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
12 |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
13 /* |
479 | 14 * Although FreeBSD sendfile() allows to pass a header and a trailer, |
4133
59b99f217c6d
Replaced "can not" with "cannot" and "could not" in a bunch of places.
Ruslan Ermilov <ru@nginx.com>
parents:
3081
diff
changeset
|
15 * it cannot send a header with a part of the file in one packet until |
479 | 16 * FreeBSD 5.3. Besides, over the fast ethernet connection sendfile() |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
17 * may send the partially filled packets, i.e. the 8 file pages may be sent |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
18 * as the 11 full 1460-bytes packets, then one incomplete 324-bytes packet, |
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
19 * and then again the 11 full 1460-bytes packets. |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
20 * |
4572
67653855682e
Fixed spelling in multiline C comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4499
diff
changeset
|
21 * Therefore we use the TCP_NOPUSH option (similar to Linux's TCP_CORK) |
479 | 22 * to postpone the sending - it not only sends a header and the first part of |
23 * the file in one packet, but also sends the file pages in the full packets. | |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
24 * |
501 | 25 * But until FreeBSD 4.5 turning TCP_NOPUSH off does not flush a pending |
26 * data that less than MSS, so that data may be sent with 5 second delay. | |
27 * So we do not use TCP_NOPUSH on FreeBSD prior to 4.5, although it can be used | |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
28 * for non-keepalive HTTP connections. |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
29 */ |
63
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 |
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 |
501 | 32 ngx_chain_t * |
33 ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) | |
63
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 { |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
35 int rc, flags; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
36 off_t send, prev_send, sent; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
37 size_t file_size; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
38 ssize_t n; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
39 ngx_uint_t eintr, eagain; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
40 ngx_err_t err; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
41 ngx_buf_t *file; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
42 ngx_event_t *wev; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
43 ngx_chain_t *cl; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
44 ngx_iovec_t header, trailer; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
45 struct sf_hdtr hdtr; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
46 struct iovec headers[NGX_IOVS_PREALLOCATE]; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
47 struct iovec trailers[NGX_IOVS_PREALLOCATE]; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
48 #if (NGX_HAVE_AIO_SENDFILE) |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
49 ngx_uint_t ebusy; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
50 ngx_event_aio_t *aio; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
51 #endif |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
52 |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
53 wev = c->write; |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
54 |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
55 if (!wev->ready) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
56 return in; |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
57 } |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
58 |
469 | 59 #if (NGX_HAVE_KQUEUE) |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
60 |
587 | 61 if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) { |
537 | 62 (void) ngx_connection_error(c, wev->kq_errno, |
63 "kevent() reported about an closed connection"); | |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
64 wev->error = 1; |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
65 return NGX_CHAIN_ERROR; |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
66 } |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
67 |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
68 #endif |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
69 |
473 | 70 /* the maximum limit size is the maximum size_t value - the page size */ |
71 | |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1182
diff
changeset
|
72 if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) { |
477 | 73 limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize; |
473 | 74 } |
75 | |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
76 send = 0; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
77 eagain = 0; |
3065 | 78 flags = 0; |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
79 |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
80 #if (NGX_HAVE_AIO_SENDFILE && NGX_SUPPRESS_WARN) |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
81 aio = NULL; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
82 file = NULL; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
83 #endif |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
84 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
85 header.iovs = headers; |
5854
b63e829621ab
Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
86 header.nalloc = NGX_IOVS_PREALLOCATE; |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
87 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
88 trailer.iovs = trailers; |
5854
b63e829621ab
Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
89 trailer.nalloc = NGX_IOVS_PREALLOCATE; |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
90 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
91 for ( ;; ) { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
92 eintr = 0; |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
93 #if (NGX_HAVE_AIO_SENDFILE) |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
94 ebusy = 0; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
95 #endif |
473 | 96 prev_send = send; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
97 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
98 /* create the header iovec and coalesce the neighbouring bufs */ |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
99 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
100 cl = ngx_output_chain_to_iovec(&header, in, limit - send, c->log); |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
101 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
102 if (cl == NGX_CHAIN_ERROR) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
103 return NGX_CHAIN_ERROR; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
104 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
105 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
106 send += header.size; |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
107 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
108 if (cl && cl->buf->in_file && send < limit) { |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
109 file = cl->buf; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
110 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
111 /* coalesce the neighbouring file bufs */ |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
112 |
5915
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
113 file_size = (size_t) ngx_chain_coalesce_file(&cl, limit - send); |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
114 |
5915
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
115 send += file_size; |
455 | 116 |
6874
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
117 if (send < limit) { |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
118 |
6874
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
119 /* |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
120 * create the trailer iovec and coalesce the neighbouring bufs |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
121 */ |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
122 |
6874
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
123 cl = ngx_output_chain_to_iovec(&trailer, cl, limit - send, |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
124 c->log); |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
125 if (cl == NGX_CHAIN_ERROR) { |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
126 return NGX_CHAIN_ERROR; |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
127 } |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
128 |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
129 send += trailer.size; |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
130 |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
131 } else { |
7cc2d3a96ea3
Fixed trailer construction with limit on FreeBSD and macOS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6422
diff
changeset
|
132 trailer.count = 0; |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
133 } |
4596
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
134 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
135 if (ngx_freebsd_use_tcp_nopush |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
136 && c->tcp_nopush == NGX_TCP_NOPUSH_UNSET) |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
137 { |
7239
400a3412b1e3
Fixed checking ngx_tcp_push() and ngx_tcp_nopush() return values.
Ruslan Ermilov <ru@nginx.com>
parents:
6874
diff
changeset
|
138 if (ngx_tcp_nopush(c->fd) == -1) { |
5557
188481078faf
Use ngx_socket_errno where appropriate.
Piotr Sikora <piotr@cloudflare.com>
parents:
5320
diff
changeset
|
139 err = ngx_socket_errno; |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
140 |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
141 /* |
479 | 142 * there is a tiny chance to be interrupted, however, |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
143 * we continue a processing without the TCP_NOPUSH |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
144 */ |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
145 |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
146 if (err != NGX_EINTR) { |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
147 wev->error = 1; |
537 | 148 (void) ngx_connection_error(c, err, |
149 ngx_tcp_nopush_n " failed"); | |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
150 return NGX_CHAIN_ERROR; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
151 } |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
152 |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
153 } else { |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
154 c->tcp_nopush = NGX_TCP_NOPUSH_SET; |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
155 |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
156 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
157 "tcp_nopush"); |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
158 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
159 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
160 |
4335
1003326eccc5
Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
161 /* |
1003326eccc5
Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
162 * sendfile() does unneeded work if sf_hdtr's count is 0, |
1003326eccc5
Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
163 * but corresponding pointer is not NULL |
1003326eccc5
Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
164 */ |
1003326eccc5
Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
165 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
166 hdtr.headers = header.count ? header.iovs : NULL; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
167 hdtr.hdr_cnt = header.count; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
168 hdtr.trailers = trailer.count ? trailer.iovs : NULL; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
169 hdtr.trl_cnt = trailer.count; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
170 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
171 /* |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
172 * the "nbytes bug" of the old sendfile() syscall: |
5727
675bda8dcfdb
FreeBSD has migrated to Bugzilla.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5557
diff
changeset
|
173 * http://bugs.freebsd.org/33771 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
174 */ |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
175 |
479 | 176 if (!ngx_freebsd_sendfile_nbytes_bug) { |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
177 header.size = 0; |
63
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 } |
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 |
203
c9da5900c79e
nginx-0.0.1-2003-12-02-08:47:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
180 sent = 0; |
c9da5900c79e
nginx-0.0.1-2003-12-02-08:47:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
181 |
3065 | 182 #if (NGX_HAVE_AIO_SENDFILE) |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
183 aio = file->file->aio; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
184 flags = (aio && aio->preload_handler) ? SF_NODISKIO : 0; |
3065 | 185 #endif |
186 | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
187 rc = sendfile(file->file->fd, c->fd, file->file_pos, |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
188 file_size + header.size, &hdtr, &sent, flags); |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
189 |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
190 if (rc == -1) { |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
191 err = ngx_errno; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
192 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
193 switch (err) { |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
194 case NGX_EAGAIN: |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
195 eagain = 1; |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
196 break; |
216
f1d0e5f09c1e
nginx-0.0.1-2003-12-25-23:26:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
214
diff
changeset
|
197 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
198 case NGX_EINTR: |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
199 eintr = 1; |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
200 break; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
201 |
3065 | 202 #if (NGX_HAVE_AIO_SENDFILE) |
203 case NGX_EBUSY: | |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
204 ebusy = 1; |
3065 | 205 break; |
206 #endif | |
207 | |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
208 default: |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
209 wev->error = 1; |
537 | 210 (void) ngx_connection_error(c, err, "sendfile() failed"); |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
211 return NGX_CHAIN_ERROR; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
212 } |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
213 |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
214 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err, |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
215 "sendfile() sent only %O bytes", sent); |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
216 |
483 | 217 /* |
218 * sendfile() in FreeBSD 3.x-4.x may return value >= 0 | |
219 * on success, although only 0 is documented | |
220 */ | |
221 | |
3080 | 222 } else if (rc >= 0 && sent == 0) { |
455 | 223 |
224 /* | |
483 | 225 * if rc is OK and sent equal to zero, then someone |
226 * has truncated the file, so the offset became beyond | |
227 * the end of the file | |
455 | 228 */ |
229 | |
230 ngx_log_error(NGX_LOG_ALERT, c->log, 0, | |
3081
10bfdd8d5eb9
log offset passed to sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
3080
diff
changeset
|
231 "sendfile() reported that \"%s\" was truncated at %O", |
10bfdd8d5eb9
log offset passed to sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
3080
diff
changeset
|
232 file->file->name.data, file->file_pos); |
455 | 233 |
234 return NGX_CHAIN_ERROR; | |
235 } | |
236 | |
214
e0c502f15852
nginx-0.0.1-2003-12-22-12:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
203
diff
changeset
|
237 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
461 | 238 "sendfile: %d, @%O %O:%uz", |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
239 rc, file->file_pos, sent, file_size + header.size); |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
240 |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
241 } else { |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5916
diff
changeset
|
242 n = ngx_writev(c, &header); |
216
f1d0e5f09c1e
nginx-0.0.1-2003-12-25-23:26:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
214
diff
changeset
|
243 |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5916
diff
changeset
|
244 if (n == NGX_ERROR) { |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5916
diff
changeset
|
245 return NGX_CHAIN_ERROR; |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
246 } |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
247 |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5916
diff
changeset
|
248 sent = (n == NGX_AGAIN) ? 0 : n; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
249 } |
63
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
251 c->sent += sent; |
63
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
252 |
5912
de68ed551bfb
Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
Valentin Bartenev <vbart@nginx.com>
parents:
5868
diff
changeset
|
253 in = ngx_chain_update_sent(in, sent); |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
254 |
3065 | 255 #if (NGX_HAVE_AIO_SENDFILE) |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
256 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
257 if (ebusy) { |
6422
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
258 if (aio->event.active) { |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
259 /* |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
260 * tolerate duplicate calls; they can happen due to subrequests |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
261 * or multiple calls of the next body filter from a filter |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
262 */ |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
263 |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
264 if (sent) { |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
265 c->busy_count = 0; |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
266 } |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
267 |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
268 return in; |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
269 } |
768e287a6f36
Fixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6066
diff
changeset
|
270 |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
271 if (sent == 0) { |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
272 c->busy_count++; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
273 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
274 if (c->busy_count > 2) { |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
275 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
276 "sendfile(%V) returned busy again", |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
277 &file->file->name); |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
278 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
279 c->busy_count = 0; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
280 aio->preload_handler = NULL; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
281 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
282 send = prev_send; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
283 continue; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
284 } |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
285 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
286 } else { |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
287 c->busy_count = 0; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
288 } |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
289 |
6066
657f6ec01da0
Used the correct type for the AIO preload handler return value.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
290 n = aio->preload_handler(file); |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
291 |
6066
657f6ec01da0
Used the correct type for the AIO preload handler return value.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
292 if (n > 0) { |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
293 send = prev_send + sent; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
294 continue; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
295 } |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
296 |
5320
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
4596
diff
changeset
|
297 return in; |
3065 | 298 } |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
299 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
300 if (flags == SF_NODISKIO) { |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
301 c->busy_count = 0; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
302 } |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
303 |
3065 | 304 #endif |
305 | |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
306 if (eagain) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
307 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
308 /* |
479 | 309 * sendfile() may return EAGAIN, even if it has sent a whole file |
310 * part, it indicates that the successive sendfile() call would | |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
311 * return EAGAIN right away and would not send anything. |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
312 * We use it as a hint. |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
313 */ |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
314 |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
315 wev->ready = 0; |
5320
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
4596
diff
changeset
|
316 return in; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
317 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
318 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
319 if (eintr) { |
5868
6bbad2e73245
Fixed counting of sent bytes in the send chain functions on EINTR.
Valentin Bartenev <vbart@nginx.com>
parents:
5854
diff
changeset
|
320 send = prev_send + sent; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
321 continue; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
322 } |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
323 |
5851
150df089fe47
Removed the "complete" variable from various send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5850
diff
changeset
|
324 if (send - prev_send != sent) { |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
325 wev->ready = 0; |
5320
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
4596
diff
changeset
|
326 return in; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
327 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
328 |
5320
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
4596
diff
changeset
|
329 if (send >= limit || in == NULL) { |
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
4596
diff
changeset
|
330 return in; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
331 } |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
332 } |
63
36d2c25cc9bb
nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
333 } |