Mercurial > hg > nginx
annotate src/os/unix/ngx_linux_sendfile_chain.c @ 4645:f329a1d2127b
Fixed compilation with -DNGX_DEBUG_MALLOC on FreeBSD 10.
After jemalloc 3.0.0 import there is no _malloc_options symbol, it has
been replaced with the malloc_conf one with a different syntax.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 23 May 2012 15:07:01 +0000 |
parents | 089cc5154c1e |
children | 23a186e8ca45 |
rev | line source |
---|---|
272
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
1 |
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
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:
262
diff
changeset
|
5 */ |
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
6 |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
10 #include <ngx_event.h> |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
199
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
13 /* |
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
14 * On Linux up to 2.4.21 sendfile() (syscall #187) works with 32-bit |
479 | 15 * offsets only, and the including <sys/sendfile.h> breaks the compiling, |
16 * if off_t is 64 bit wide. So we use own sendfile() definition, where offset | |
17 * parameter is int32_t, and use sendfile() for the file parts below 2G only, | |
18 * see src/os/unix/ngx_linux_config.h | |
199
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
19 * |
687
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
20 * Linux 2.4.21 has the new sendfile64() syscall #239. |
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
21 * |
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
22 * On Linux up to 2.6.16 sendfile() does not allow to pass the count parameter |
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
23 * more than 2G-1 bytes even on 64-bit platforms: it returns EINVAL, |
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
24 * so we limit it to 2G-1 bytes. |
199
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
25 */ |
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
26 |
687
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
27 #define NGX_SENDFILE_LIMIT 2147483647L |
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
28 |
199
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
29 |
597 | 30 #if (IOV_MAX > 64) |
31 #define NGX_HEADERS 64 | |
32 #else | |
33 #define NGX_HEADERS IOV_MAX | |
34 #endif | |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
35 |
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
36 |
585 | 37 ngx_chain_t * |
38 ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) | |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 { |
589 | 40 int rc, tcp_nodelay; |
41 off_t size, send, prev_send, aligned, sent, fprev; | |
42 u_char *prev; | |
43 size_t file_size; | |
44 ngx_err_t err; | |
45 ngx_buf_t *file; | |
46 ngx_uint_t eintr, complete; | |
47 ngx_array_t header; | |
48 ngx_event_t *wev; | |
49 ngx_chain_t *cl; | |
50 struct iovec *iov, headers[NGX_HEADERS]; | |
455 | 51 #if (NGX_HAVE_SENDFILE64) |
589 | 52 off_t offset; |
198
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
53 #else |
589 | 54 int32_t offset; |
198
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
55 #endif |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
56 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
57 wev = c->write; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
59 if (!wev->ready) { |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
60 return in; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
61 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
62 |
473 | 63 |
687
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
64 /* the maximum limit size is 2G-1 - the page size */ |
473 | 65 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1198
diff
changeset
|
66 if (limit == 0 || limit > (off_t) (NGX_SENDFILE_LIMIT - ngx_pagesize)) { |
687
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
67 limit = NGX_SENDFILE_LIMIT - ngx_pagesize; |
473 | 68 } |
69 | |
70 | |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
71 send = 0; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
72 |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
73 header.elts = headers; |
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
74 header.size = sizeof(struct iovec); |
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
75 header.nalloc = NGX_HEADERS; |
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
76 header.pool = c->pool; |
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
77 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
78 for ( ;; ) { |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
79 file = NULL; |
473 | 80 file_size = 0; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
81 eintr = 0; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
82 complete = 0; |
473 | 83 prev_send = send; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
84 |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
85 header.nelts = 0; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 prev = NULL; |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
88 iov = NULL; |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
89 |
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:
290
diff
changeset
|
90 /* create the iovec and coalesce the neighbouring bufs */ |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
91 |
4596
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
92 for (cl = in; cl && send < limit; cl = cl->next) { |
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
93 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
94 if (ngx_buf_special(cl->buf)) { |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
95 continue; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
96 } |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 |
479 | 98 #if 1 |
99 if (!ngx_buf_in_memory(cl->buf) && !cl->buf->in_file) { | |
100 ngx_log_error(NGX_LOG_ALERT, c->log, 0, | |
483 | 101 "zero size buf in sendfile " |
102 "t:%d r:%d f:%d %p %p-%p %p %O-%O", | |
103 cl->buf->temporary, | |
104 cl->buf->recycled, | |
105 cl->buf->in_file, | |
106 cl->buf->start, | |
107 cl->buf->pos, | |
108 cl->buf->last, | |
109 cl->buf->file, | |
110 cl->buf->file_pos, | |
111 cl->buf->file_last); | |
112 | |
479 | 113 ngx_debug_point(); |
489 | 114 |
115 return NGX_CHAIN_ERROR; | |
479 | 116 } |
117 #endif | |
118 | |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
119 if (!ngx_buf_in_memory_only(cl->buf)) { |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
120 break; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
121 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
122 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
123 size = cl->buf->last - cl->buf->pos; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
124 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
125 if (send + size > limit) { |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
126 size = limit - send; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
127 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
128 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
129 if (prev == cl->buf->pos) { |
473 | 130 iov->iov_len += (size_t) size; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 } else { |
4596
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
133 if (header.nelts >= IOV_MAX) { |
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
134 break; |
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
135 } |
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
136 |
501 | 137 iov = ngx_array_push(&header); |
138 if (iov == NULL) { | |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
139 return NGX_CHAIN_ERROR; |
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
140 } |
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
141 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
142 iov->iov_base = (void *) cl->buf->pos; |
473 | 143 iov->iov_len = (size_t) size; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
144 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
145 |
473 | 146 prev = cl->buf->pos + (size_t) size; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
147 send += size; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
149 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
150 /* set TCP_CORK if there is a header before a file */ |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
151 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
152 if (c->tcp_nopush == NGX_TCP_NOPUSH_UNSET |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
153 && header.nelts != 0 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
154 && cl |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
155 && cl->buf->in_file) |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
156 { |
473 | 157 /* the TCP_CORK and TCP_NODELAY are mutually exclusive */ |
158 | |
483 | 159 if (c->tcp_nodelay == NGX_TCP_NODELAY_SET) { |
473 | 160 |
161 tcp_nodelay = 0; | |
162 | |
163 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, | |
164 (const void *) &tcp_nodelay, sizeof(int)) == -1) | |
165 { | |
166 err = ngx_errno; | |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 |
473 | 168 /* |
479 | 169 * there is a tiny chance to be interrupted, however, |
473 | 170 * we continue a processing with the TCP_NODELAY |
171 * and without the TCP_CORK | |
172 */ | |
173 | |
577 | 174 if (err != NGX_EINTR) { |
473 | 175 wev->error = 1; |
483 | 176 ngx_connection_error(c, err, |
473 | 177 "setsockopt(TCP_NODELAY) failed"); |
178 return NGX_CHAIN_ERROR; | |
179 } | |
180 | |
181 } else { | |
483 | 182 c->tcp_nodelay = NGX_TCP_NODELAY_UNSET; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
183 |
473 | 184 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
185 "no tcp_nodelay"); | |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
186 } |
473 | 187 } |
188 | |
483 | 189 if (c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) { |
473 | 190 |
191 if (ngx_tcp_nopush(c->fd) == NGX_ERROR) { | |
192 err = ngx_errno; | |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
193 |
473 | 194 /* |
479 | 195 * there is a tiny chance to be interrupted, however, |
473 | 196 * we continue a processing without the TCP_CORK |
197 */ | |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
198 |
577 | 199 if (err != NGX_EINTR) { |
473 | 200 wev->error = 1; |
201 ngx_connection_error(c, err, | |
202 ngx_tcp_nopush_n " failed"); | |
203 return NGX_CHAIN_ERROR; | |
204 } | |
205 | |
206 } else { | |
207 c->tcp_nopush = NGX_TCP_NOPUSH_SET; | |
577 | 208 |
473 | 209 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
210 "tcp_nopush"); | |
211 } | |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
212 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
213 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
214 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
215 /* get the file buf */ |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
217 if (header.nelts == 0 && cl && cl->buf->in_file && send < limit) { |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
218 file = cl->buf; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
219 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
220 /* coalesce the neighbouring file bufs */ |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
222 do { |
473 | 223 size = cl->buf->file_last - cl->buf->file_pos; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
224 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
225 if (send + size > limit) { |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
226 size = limit - send; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
227 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
228 aligned = (cl->buf->file_pos + size + ngx_pagesize - 1) |
1182
df449f4a8032
fix sendfile on 64-bit Linux and limit_rate on all 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
687
diff
changeset
|
229 & ~((off_t) ngx_pagesize - 1); |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
230 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
231 if (aligned <= cl->buf->file_last) { |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
232 size = aligned - cl->buf->file_pos; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
233 } |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
234 } |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
235 |
473 | 236 file_size += (size_t) size; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
237 send += size; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
238 fprev = cl->buf->file_pos + size; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
239 cl = cl->next; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
240 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
241 } while (cl |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
242 && cl->buf->in_file |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
243 && send < limit |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
244 && file->file->fd == cl->buf->file->fd |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
245 && fprev == cl->buf->file_pos); |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
246 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
247 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
248 if (file) { |
589 | 249 #if 1 |
250 if (file_size == 0) { | |
251 ngx_debug_point(); | |
252 return NGX_CHAIN_ERROR; | |
253 } | |
254 #endif | |
455 | 255 #if (NGX_HAVE_SENDFILE64) |
196
11fbd0fc041d
nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
256 offset = file->file_pos; |
198
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
257 #else |
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
258 offset = (int32_t) file->file_pos; |
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
259 #endif |
1198 | 260 |
261 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
262 "sendfile: @%O %uz", file->file_pos, file_size); | |
263 | |
473 | 264 rc = sendfile(c->fd, file->file->fd, &offset, file_size); |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
265 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
266 if (rc == -1) { |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
267 err = ngx_errno; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
268 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
269 switch (err) { |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
270 case NGX_EAGAIN: |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
271 break; |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
272 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
273 case NGX_EINTR: |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
274 eintr = 1; |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
275 break; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
276 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
277 default: |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
278 wev->error = 1; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
279 ngx_connection_error(c, err, "sendfile() failed"); |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
280 return NGX_CHAIN_ERROR; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
281 } |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
282 |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
283 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
284 "sendfile() is not ready"); |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
285 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
286 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
287 sent = rc > 0 ? rc : 0; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
288 |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
289 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
473 | 290 "sendfile: %d, @%O %O:%uz", |
291 rc, file->file_pos, sent, file_size); | |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
292 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
293 } else { |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
294 rc = writev(c->fd, header.elts, header.nelts); |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
296 if (rc == -1) { |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
297 err = ngx_errno; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
298 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
299 switch (err) { |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
300 case NGX_EAGAIN: |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
301 break; |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
302 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
303 case NGX_EINTR: |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
304 eintr = 1; |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
305 break; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
306 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
307 default: |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
308 wev->error = 1; |
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
309 ngx_connection_error(c, err, "writev() failed"); |
577 | 310 return NGX_CHAIN_ERROR; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
311 } |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
312 |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
313 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
314 "writev() not ready"); |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
315 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
316 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
317 sent = rc > 0 ? rc : 0; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
318 |
473 | 319 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "writev: %O", sent); |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
320 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
321 |
473 | 322 if (send - prev_send == sent) { |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
323 complete = 1; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
324 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
325 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
326 c->sent += sent; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
327 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
328 for (cl = in; cl; cl = cl->next) { |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
329 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
330 if (ngx_buf_special(cl->buf)) { |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
331 continue; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
332 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
333 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
334 if (sent == 0) { |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
335 break; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
336 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
337 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
338 size = ngx_buf_size(cl->buf); |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
339 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
340 if (sent >= size) { |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
341 sent -= size; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
342 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
343 if (ngx_buf_in_memory(cl->buf)) { |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
344 cl->buf->pos = cl->buf->last; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
345 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
346 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
347 if (cl->buf->in_file) { |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
348 cl->buf->file_pos = cl->buf->file_last; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
349 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
350 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
351 continue; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
352 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
353 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
354 if (ngx_buf_in_memory(cl->buf)) { |
473 | 355 cl->buf->pos += (size_t) sent; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
356 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
357 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
358 if (cl->buf->in_file) { |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
359 cl->buf->file_pos += sent; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
360 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
361 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
362 break; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
363 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
364 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
365 if (eintr) { |
577 | 366 continue; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
367 } |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
368 |
577 | 369 if (!complete) { |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
370 wev->ready = 0; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
371 return cl; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
372 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
373 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
374 if (send >= limit || cl == NULL) { |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
375 return cl; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
376 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
377 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
378 in = cl; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
379 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
380 } |