Mercurial > hg > nginx
annotate src/os/unix/ngx_linux_sendfile_chain.c @ 9202:e88cdaa0f1ff
AIO operations now add timers (ticket #2162).
Each AIO (thread IO) operation being run is now accompanied with 1-minute
timer. This timer prevents unexpected shutdown of the worker process while
an AIO operation is running, and logs an alert if the operation is running
for too long.
This fixes "open socket left" alerts during worker processes shutdown
due to pending AIO (or thread IO) operations while corresponding requests
have no timers. In particular, such errors were observed while reading
cache headers (ticket #2162), and with worker_shutdown_timeout.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 29 Jan 2024 10:31:37 +0300 |
parents | 555533169506 |
children |
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 |
5997
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
13 static ssize_t ngx_linux_sendfile(ngx_connection_t *c, ngx_buf_t *file, |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
14 size_t size); |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
15 |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
16 #if (NGX_THREADS) |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
17 #include <ngx_thread_pool.h> |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
18 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
19 #if !(NGX_HAVE_SENDFILE64) |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
20 #error sendfile64() is required! |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
21 #endif |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
22 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
23 static ssize_t ngx_linux_sendfile_thread(ngx_connection_t *c, ngx_buf_t *file, |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
24 size_t size); |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
25 static void ngx_linux_sendfile_thread_handler(void *data, ngx_log_t *log); |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
26 #endif |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
27 |
5997
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
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 /* |
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
30 * On Linux up to 2.4.21 sendfile() (syscall #187) works with 32-bit |
479 | 31 * offsets only, and the including <sys/sendfile.h> breaks the compiling, |
32 * if off_t is 64 bit wide. So we use own sendfile() definition, where offset | |
33 * parameter is int32_t, and use sendfile() for the file parts below 2G only, | |
34 * 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
|
35 * |
687
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
36 * 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
|
37 * |
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
38 * 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
|
39 * 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
|
40 * so we limit it to 2G-1 bytes. |
7948
a2613fc1bce5
Fixed sendfile() limit handling on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7239
diff
changeset
|
41 * |
a2613fc1bce5
Fixed sendfile() limit handling on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7239
diff
changeset
|
42 * On Linux 2.6.16 and later, sendfile() silently limits the count parameter |
a2613fc1bce5
Fixed sendfile() limit handling on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7239
diff
changeset
|
43 * to 2G minus the page size, even on 64-bit platforms. |
199
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
44 */ |
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
45 |
5322
bdb3588681c9
Unbreak building on Linux without sendfile64() support.
Valentin Bartenev <vbart@nginx.com>
parents:
5320
diff
changeset
|
46 #define NGX_SENDFILE_MAXSIZE 2147483647L |
687
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
47 |
199
a65b630b3a66
nginx-0.0.1-2003-11-28-11:40:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
48 |
585 | 49 ngx_chain_t * |
50 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
|
51 { |
5918
c50b5ed3cd4b
Fixed type of sendfile() return value on Linux.
Valentin Bartenev <vbart@nginx.com>
parents:
5917
diff
changeset
|
52 int tcp_nodelay; |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
53 off_t send, prev_send; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
54 size_t file_size, sent; |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5916
diff
changeset
|
55 ssize_t n; |
589 | 56 ngx_err_t err; |
57 ngx_buf_t *file; | |
58 ngx_event_t *wev; | |
59 ngx_chain_t *cl; | |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
60 ngx_iovec_t header; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
61 struct iovec headers[NGX_IOVS_PREALLOCATE]; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
62 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
63 wev = c->write; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
64 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
65 if (!wev->ready) { |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
66 return in; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
67 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
68 |
473 | 69 |
687
8e446a2daf48
workaround of 2G+ file bug in 64-bit Linux sendfile()
Igor Sysoev <igor@sysoev.ru>
parents:
597
diff
changeset
|
70 /* the maximum limit size is 2G-1 - the page size */ |
473 | 71 |
5322
bdb3588681c9
Unbreak building on Linux without sendfile64() support.
Valentin Bartenev <vbart@nginx.com>
parents:
5320
diff
changeset
|
72 if (limit == 0 || limit > (off_t) (NGX_SENDFILE_MAXSIZE - ngx_pagesize)) { |
bdb3588681c9
Unbreak building on Linux without sendfile64() support.
Valentin Bartenev <vbart@nginx.com>
parents:
5320
diff
changeset
|
73 limit = NGX_SENDFILE_MAXSIZE - ngx_pagesize; |
473 | 74 } |
75 | |
76 | |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
77 send = 0; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
78 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
79 header.iovs = headers; |
5854
b63e829621ab
Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
80 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
|
81 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
82 for ( ;; ) { |
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 |
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
|
85 /* 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
|
86 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
87 cl = ngx_output_chain_to_iovec(&header, in, limit - send, c->log); |
479 | 88 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
89 if (cl == NGX_CHAIN_ERROR) { |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
90 return NGX_CHAIN_ERROR; |
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
91 } |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
92 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
93 send += header.size; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
94 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
95 /* 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
|
96 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
97 if (c->tcp_nopush == NGX_TCP_NOPUSH_UNSET |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
98 && header.count != 0 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
99 && cl |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
100 && 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
|
101 { |
473 | 102 /* the TCP_CORK and TCP_NODELAY are mutually exclusive */ |
103 | |
483 | 104 if (c->tcp_nodelay == NGX_TCP_NODELAY_SET) { |
473 | 105 |
106 tcp_nodelay = 0; | |
107 | |
108 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, | |
109 (const void *) &tcp_nodelay, sizeof(int)) == -1) | |
110 { | |
5557
188481078faf
Use ngx_socket_errno where appropriate.
Piotr Sikora <piotr@cloudflare.com>
parents:
5322
diff
changeset
|
111 err = ngx_socket_errno; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
112 |
473 | 113 /* |
479 | 114 * there is a tiny chance to be interrupted, however, |
473 | 115 * we continue a processing with the TCP_NODELAY |
116 * and without the TCP_CORK | |
117 */ | |
118 | |
577 | 119 if (err != NGX_EINTR) { |
473 | 120 wev->error = 1; |
483 | 121 ngx_connection_error(c, err, |
473 | 122 "setsockopt(TCP_NODELAY) failed"); |
123 return NGX_CHAIN_ERROR; | |
124 } | |
125 | |
126 } else { | |
483 | 127 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
|
128 |
5222
23a186e8ca45
Style: remove unnecessary references to HTTP from non-HTTP modules.
Piotr Sikora <piotr@cloudflare.com>
parents:
4596
diff
changeset
|
129 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
473 | 130 "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
|
131 } |
473 | 132 } |
133 | |
483 | 134 if (c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) { |
473 | 135 |
7239
400a3412b1e3
Fixed checking ngx_tcp_push() and ngx_tcp_nopush() return values.
Ruslan Ermilov <ru@nginx.com>
parents:
6949
diff
changeset
|
136 if (ngx_tcp_nopush(c->fd) == -1) { |
5557
188481078faf
Use ngx_socket_errno where appropriate.
Piotr Sikora <piotr@cloudflare.com>
parents:
5322
diff
changeset
|
137 err = ngx_socket_errno; |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
138 |
473 | 139 /* |
479 | 140 * there is a tiny chance to be interrupted, however, |
473 | 141 * we continue a processing without the TCP_CORK |
142 */ | |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
143 |
577 | 144 if (err != NGX_EINTR) { |
473 | 145 wev->error = 1; |
146 ngx_connection_error(c, err, | |
147 ngx_tcp_nopush_n " failed"); | |
148 return NGX_CHAIN_ERROR; | |
149 } | |
150 | |
151 } else { | |
152 c->tcp_nopush = NGX_TCP_NOPUSH_SET; | |
577 | 153 |
473 | 154 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
155 "tcp_nopush"); | |
156 } | |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
159 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
160 /* 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
|
161 |
5913
8e903522c17a
Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
162 if (header.count == 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
|
163 file = cl->buf; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
165 /* 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
|
166 |
5915
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
167 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:
344
diff
changeset
|
168 |
5915
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5913
diff
changeset
|
169 send += file_size; |
589 | 170 #if 1 |
171 if (file_size == 0) { | |
172 ngx_debug_point(); | |
173 return NGX_CHAIN_ERROR; | |
174 } | |
175 #endif | |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
176 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
177 n = ngx_linux_sendfile(c, file, file_size); |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
178 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
179 if (n == NGX_ERROR) { |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
180 return NGX_CHAIN_ERROR; |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
181 } |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
182 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
183 if (n == NGX_DONE) { |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
184 /* thread task posted */ |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
185 return in; |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
186 } |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
187 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
188 sent = (n == NGX_AGAIN) ? 0 : n; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
189 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
190 } else { |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5916
diff
changeset
|
191 n = ngx_writev(c, &header); |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
192 |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5916
diff
changeset
|
193 if (n == NGX_ERROR) { |
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5916
diff
changeset
|
194 return NGX_CHAIN_ERROR; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 |
5917
2c64b69daec5
Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5916
diff
changeset
|
197 sent = (n == NGX_AGAIN) ? 0 : n; |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
199 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
200 c->sent += sent; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
201 |
5912
de68ed551bfb
Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
Valentin Bartenev <vbart@nginx.com>
parents:
5868
diff
changeset
|
202 in = ngx_chain_update_sent(in, sent); |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
204 if (n == NGX_AGAIN) { |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
205 wev->ready = 0; |
5320
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
5222
diff
changeset
|
206 return in; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
207 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
208 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
209 if ((size_t) (send - prev_send) != sent) { |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
210 |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
211 /* |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
212 * sendfile() on Linux 4.3+ might be interrupted at any time, |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
213 * and provides no indication if it was interrupted or not, |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
214 * so we have to retry till an explicit EAGAIN |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
215 * |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
216 * sendfile() in threads can also report less bytes written |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
217 * than we are prepared to send now, since it was started in |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
218 * some point in the past, so we again have to retry |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
219 */ |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
220 |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
221 send = prev_send + sent; |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
222 } |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
223 |
5320
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
5222
diff
changeset
|
224 if (send >= limit || in == NULL) { |
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
5222
diff
changeset
|
225 return in; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
226 } |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 } |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 } |
5997
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
229 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
230 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
231 static ssize_t |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
232 ngx_linux_sendfile(ngx_connection_t *c, ngx_buf_t *file, size_t size) |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
233 { |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
234 #if (NGX_HAVE_SENDFILE64) |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
235 off_t offset; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
236 #else |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
237 int32_t offset; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
238 #endif |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
239 ssize_t n; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
240 ngx_err_t err; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
241 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
242 #if (NGX_THREADS) |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
243 |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
244 if (file->file->thread_handler) { |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
245 return ngx_linux_sendfile_thread(c, file, size); |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
246 } |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
247 |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
248 #endif |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
249 |
5997
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
250 #if (NGX_HAVE_SENDFILE64) |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
251 offset = file->file_pos; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
252 #else |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
253 offset = (int32_t) file->file_pos; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
254 #endif |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
255 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
256 eintr: |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
257 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
258 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
259 "sendfile: @%O %uz", file->file_pos, size); |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
260 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
261 n = sendfile(c->fd, file->file->fd, &offset, size); |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
262 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
263 if (n == -1) { |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
264 err = ngx_errno; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
265 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
266 switch (err) { |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
267 case NGX_EAGAIN: |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
268 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
269 "sendfile() is not ready"); |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
270 return NGX_AGAIN; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
271 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
272 case NGX_EINTR: |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
273 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
274 "sendfile() was interrupted"); |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
275 goto eintr; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
276 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
277 default: |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
278 c->write->error = 1; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
279 ngx_connection_error(c, err, "sendfile() failed"); |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
280 return NGX_ERROR; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
281 } |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
282 } |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
283 |
6437
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
284 if (n == 0) { |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
285 /* |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
286 * if sendfile returns zero, then someone has truncated the file, |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
287 * so the offset became beyond the end of the file |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
288 */ |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
289 |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
290 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
291 "sendfile() reported that \"%s\" was truncated at %O", |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
292 file->file->name.data, file->file_pos); |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
293 |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
294 return NGX_ERROR; |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
295 } |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
296 |
5997
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
297 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, "sendfile: %z of %uz @%O", |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
298 n, size, file->file_pos); |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
299 |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
300 return n; |
c901f2764c27
Refactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev <vbart@nginx.com>
parents:
5918
diff
changeset
|
301 } |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
302 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
303 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
304 #if (NGX_THREADS) |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
305 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
306 typedef struct { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
307 ngx_buf_t *file; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
308 ngx_socket_t socket; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
309 size_t size; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
310 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
311 size_t sent; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
312 ngx_err_t err; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
313 } ngx_linux_sendfile_ctx_t; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
314 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
315 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
316 static ssize_t |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
317 ngx_linux_sendfile_thread(ngx_connection_t *c, ngx_buf_t *file, size_t size) |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
318 { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
319 ngx_event_t *wev; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
320 ngx_thread_task_t *task; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
321 ngx_linux_sendfile_ctx_t *ctx; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
322 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
323 ngx_log_debug3(NGX_LOG_DEBUG_CORE, c->log, 0, |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
324 "linux sendfile thread: %d, %uz, %O", |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
325 file->file->fd, size, file->file_pos); |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
326 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
327 task = c->sendfile_task; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
328 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
329 if (task == NULL) { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
330 task = ngx_thread_task_alloc(c->pool, sizeof(ngx_linux_sendfile_ctx_t)); |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
331 if (task == NULL) { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
332 return NGX_ERROR; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
333 } |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
334 |
9202
e88cdaa0f1ff
AIO operations now add timers (ticket #2162).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7974
diff
changeset
|
335 task->event.log = c->log; |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
336 task->handler = ngx_linux_sendfile_thread_handler; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
337 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
338 c->sendfile_task = task; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
339 } |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
340 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
341 ctx = task->ctx; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
342 wev = c->write; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
343 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
344 if (task->event.complete) { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
345 task->event.complete = 0; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
346 |
6431
3b9c6b91d988
Fixed handling of EAGAIN with sendfile in threads.
Valentin Bartenev <vbart@nginx.com>
parents:
6422
diff
changeset
|
347 if (ctx->err == NGX_EAGAIN) { |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
348 /* |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
349 * if wev->complete is set, this means that a write event |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
350 * happened while we were waiting for the thread task, so |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
351 * we have to retry sending even on EAGAIN |
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
352 */ |
6440
248aa2757332
Fixed timeouts with threaded sendfile() and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6437
diff
changeset
|
353 |
248aa2757332
Fixed timeouts with threaded sendfile() and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6437
diff
changeset
|
354 if (wev->complete) { |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
355 return 0; |
6440
248aa2757332
Fixed timeouts with threaded sendfile() and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6437
diff
changeset
|
356 } |
248aa2757332
Fixed timeouts with threaded sendfile() and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6437
diff
changeset
|
357 |
6431
3b9c6b91d988
Fixed handling of EAGAIN with sendfile in threads.
Valentin Bartenev <vbart@nginx.com>
parents:
6422
diff
changeset
|
358 return NGX_AGAIN; |
3b9c6b91d988
Fixed handling of EAGAIN with sendfile in threads.
Valentin Bartenev <vbart@nginx.com>
parents:
6422
diff
changeset
|
359 } |
3b9c6b91d988
Fixed handling of EAGAIN with sendfile in threads.
Valentin Bartenev <vbart@nginx.com>
parents:
6422
diff
changeset
|
360 |
3b9c6b91d988
Fixed handling of EAGAIN with sendfile in threads.
Valentin Bartenev <vbart@nginx.com>
parents:
6422
diff
changeset
|
361 if (ctx->err) { |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
362 wev->error = 1; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
363 ngx_connection_error(c, ctx->err, "sendfile() failed"); |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
364 return NGX_ERROR; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
365 } |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
366 |
6437
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
367 if (ctx->sent == 0) { |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
368 /* |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
369 * if sendfile returns zero, then someone has truncated the file, |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
370 * so the offset became beyond the end of the file |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
371 */ |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
372 |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
373 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
374 "sendfile() reported that \"%s\" was truncated at %O", |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
375 file->file->name.data, file->file_pos); |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
376 |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
377 return NGX_ERROR; |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
378 } |
4df3d9fcdee8
Truncation detection in sendfile() on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6431
diff
changeset
|
379 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
380 return ctx->sent; |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
381 } |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
382 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
383 ctx->file = file; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
384 ctx->socket = c->fd; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
385 ctx->size = size; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
386 |
6440
248aa2757332
Fixed timeouts with threaded sendfile() and subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6437
diff
changeset
|
387 wev->complete = 0; |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
388 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
389 if (file->file->thread_handler(task, file->file) != NGX_OK) { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
390 return NGX_ERROR; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
391 } |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
392 |
6949
ff0c8e11edbc
Simplified and improved sendfile() code on Linux.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
393 return NGX_DONE; |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
394 } |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
395 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
396 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
397 static void |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
398 ngx_linux_sendfile_thread_handler(void *data, ngx_log_t *log) |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
399 { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
400 ngx_linux_sendfile_ctx_t *ctx = data; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
401 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
402 off_t offset; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
403 ssize_t n; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
404 ngx_buf_t *file; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
405 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
406 ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, 0, "linux sendfile thread handler"); |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
407 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
408 file = ctx->file; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
409 offset = file->file_pos; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
410 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
411 again: |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
412 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
413 n = sendfile(ctx->socket, file->file->fd, &offset, ctx->size); |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
414 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
415 if (n == -1) { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
416 ctx->err = ngx_errno; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
417 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
418 } else { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
419 ctx->sent = n; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
420 ctx->err = 0; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
421 } |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
422 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
423 #if 0 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
424 ngx_time_update(); |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
425 #endif |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
426 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
427 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, log, 0, |
6480 | 428 "sendfile: %z (err: %d) of %uz @%O", |
6023
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
429 n, ctx->err, ctx->size, file->file_pos); |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
430 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
431 if (ctx->err == NGX_EINTR) { |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
432 goto again; |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
433 } |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
434 } |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
435 |
b550563ef96e
Added support for offloading Linux sendfile() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5997
diff
changeset
|
436 #endif /* NGX_THREADS */ |