Mercurial > hg > nginx-quic
annotate src/event/ngx_event_pipe.c @ 8465:ec1071830799
Mail: max_errors directive.
Similarly to smtpd_hard_error_limit in Postfix and smtp_max_unknown_commands
in Exim, specifies the number of errors after which the connection is closed.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 19 May 2021 03:13:31 +0300 |
parents | bffcc5af1d72 |
children |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
375
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:
442
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
6 |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
139
54307053f185
nginx-0.0.1-2003-10-07-19:30:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
8 #include <ngx_config.h> |
54307053f185
nginx-0.0.1-2003-10-07-19:30:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
9 #include <ngx_core.h> |
54307053f185
nginx-0.0.1-2003-10-07-19:30:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
10 #include <ngx_event.h> |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
11 #include <ngx_event_pipe.h> |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
12 |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
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:
304
diff
changeset
|
14 static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p); |
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:
304
diff
changeset
|
15 static ngx_int_t ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p); |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
16 |
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:
304
diff
changeset
|
17 static ngx_int_t ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p); |
467 | 18 static ngx_inline void ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf); |
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:
304
diff
changeset
|
19 static ngx_int_t ngx_event_pipe_drain_chains(ngx_event_pipe_t *p); |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
20 |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
577 | 22 ngx_int_t |
1599 | 23 ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write) |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
24 { |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
25 ngx_int_t rc; |
6165
d811f22033ad
Event pipe: call ngx_handle_read_event() with a proper flags type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6044
diff
changeset
|
26 ngx_uint_t flags; |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
27 ngx_event_t *rev, *wev; |
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
28 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
29 for ( ;; ) { |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
30 if (do_write) { |
483 | 31 p->log->action = "sending to client"; |
32 | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
33 rc = ngx_event_pipe_write_to_downstream(p); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
34 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
35 if (rc == NGX_ABORT) { |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
36 return NGX_ABORT; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
37 } |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
38 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
39 if (rc == NGX_BUSY) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
40 return NGX_OK; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
41 } |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
42 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
43 |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
44 p->read = 0; |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
45 p->upstream_blocked = 0; |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
46 |
483 | 47 p->log->action = "reading upstream"; |
48 | |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
49 if (ngx_event_pipe_read_upstream(p) == NGX_ABORT) { |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
50 return NGX_ABORT; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
51 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
52 |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
53 if (!p->read && !p->upstream_blocked) { |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
54 break; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
55 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
56 |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
57 do_write = 1; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
58 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
59 |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5347
diff
changeset
|
60 if (p->upstream->fd != (ngx_socket_t) -1) { |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
61 rev = p->upstream->read; |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
62 |
189
c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
188
diff
changeset
|
63 flags = (rev->eof || rev->error) ? NGX_CLOSE_EVENT : 0; |
c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
188
diff
changeset
|
64 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
65 if (ngx_handle_read_event(rev, flags) != NGX_OK) { |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
66 return NGX_ABORT; |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
67 } |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
68 |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
69 if (!rev->delayed) { |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
70 if (rev->active && !rev->ready) { |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
71 ngx_add_timer(rev, p->read_timeout); |
613 | 72 |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
73 } else if (rev->timer_set) { |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
74 ngx_del_timer(rev); |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
75 } |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
76 } |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
77 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
78 |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5347
diff
changeset
|
79 if (p->downstream->fd != (ngx_socket_t) -1 |
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5347
diff
changeset
|
80 && p->downstream->data == p->output_ctx) |
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5347
diff
changeset
|
81 { |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
82 wev = p->downstream->write; |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
83 if (ngx_handle_write_event(wev, p->send_lowat) != NGX_OK) { |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
84 return NGX_ABORT; |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
85 } |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
86 |
613 | 87 if (!wev->delayed) { |
88 if (wev->active && !wev->ready) { | |
89 ngx_add_timer(wev, p->send_timeout); | |
90 | |
91 } else if (wev->timer_set) { | |
92 ngx_del_timer(wev); | |
93 } | |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
94 } |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
95 } |
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
96 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
97 return NGX_OK; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
98 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
99 |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
100 |
577 | 101 static ngx_int_t |
102 ngx_event_pipe_read_upstream(ngx_event_pipe_t *p) | |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 { |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
104 off_t limit; |
461 | 105 ssize_t n, size; |
106 ngx_int_t rc; | |
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:
304
diff
changeset
|
107 ngx_buf_t *b; |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
108 ngx_msec_t delay; |
507 | 109 ngx_chain_t *chain, *cl, *ln; |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
110 |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
111 if (p->upstream_eof || p->upstream_error || p->upstream_done) { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
112 return NGX_OK; |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
113 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
114 |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
115 #if (NGX_THREADS) |
6876
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
116 |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
117 if (p->aio) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
118 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
119 "pipe read upstream: aio"); |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
120 return NGX_AGAIN; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
121 } |
6876
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
122 |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
123 if (p->writing) { |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
124 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
125 "pipe read upstream: writing"); |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
126 |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
127 rc = ngx_event_pipe_write_chain_to_temp_file(p); |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
128 |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
129 if (rc != NGX_OK) { |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
130 return rc; |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
131 } |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
132 } |
a5d1b1383dea
Upstream: fixed cache corruption and socket leaks with aio_write.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6673
diff
changeset
|
133 |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
134 #endif |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
135 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
136 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
137 "pipe read upstream: %d", p->upstream->read->ready); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
139 for ( ;; ) { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
140 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
141 if (p->upstream_eof || p->upstream_error || p->upstream_done) { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
142 break; |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
143 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
144 |
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:
304
diff
changeset
|
145 if (p->preread_bufs == NULL && !p->upstream->read->ready) { |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
146 break; |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
147 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
148 |
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:
304
diff
changeset
|
149 if (p->preread_bufs) { |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
150 |
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:
304
diff
changeset
|
151 /* use the pre-read bufs if they exist */ |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
152 |
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:
304
diff
changeset
|
153 chain = p->preread_bufs; |
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:
304
diff
changeset
|
154 p->preread_bufs = NULL; |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
155 n = p->preread_size; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
157 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 158 "pipe preread: %z", n); |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
159 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
160 if (n) { |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
161 p->read = 1; |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
162 } |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
163 |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
164 } else { |
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
165 |
581 | 166 #if (NGX_HAVE_KQUEUE) |
167 | |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
168 /* |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
169 * kqueue notifies about the end of file or a pending error. |
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:
304
diff
changeset
|
170 * This test allows not to allocate a buf on these conditions |
577 | 171 * and not to call c->recv_chain(). |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
172 */ |
79
eacfdd1c31b9
nginx-0.0.1-2003-04-22-19:02:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
78
diff
changeset
|
173 |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
174 if (p->upstream->read->available == 0 |
7581
afceb32f3a8a
Event pipe: disabled c->read->available checking for SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6876
diff
changeset
|
175 && p->upstream->read->pending_eof |
afceb32f3a8a
Event pipe: disabled c->read->available checking for SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6876
diff
changeset
|
176 #if (NGX_SSL) |
afceb32f3a8a
Event pipe: disabled c->read->available checking for SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6876
diff
changeset
|
177 && !p->upstream->ssl |
afceb32f3a8a
Event pipe: disabled c->read->available checking for SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6876
diff
changeset
|
178 #endif |
afceb32f3a8a
Event pipe: disabled c->read->available checking for SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6876
diff
changeset
|
179 ) |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
180 { |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
181 p->upstream->read->ready = 0; |
4065
227a819b46db
Proper setting of read->eof in pipe code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3052
diff
changeset
|
182 p->upstream->read->eof = 1; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
183 p->upstream_eof = 1; |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
184 p->read = 1; |
163
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
185 |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
186 if (p->upstream->read->kq_errno) { |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
187 p->upstream->read->error = 1; |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
188 p->upstream_error = 1; |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
189 p->upstream_eof = 0; |
163
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
190 |
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
191 ngx_log_error(NGX_LOG_ERR, p->log, |
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
192 p->upstream->read->kq_errno, |
581 | 193 "kevent() reported that upstream " |
194 "closed connection"); | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
195 } |
163
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
196 |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
197 break; |
79
eacfdd1c31b9
nginx-0.0.1-2003-04-22-19:02:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
78
diff
changeset
|
198 } |
581 | 199 #endif |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
200 |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
201 if (p->limit_rate) { |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
202 if (p->upstream->read->delayed) { |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
203 break; |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
204 } |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
205 |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
206 limit = (off_t) p->limit_rate * (ngx_time() - p->start_sec + 1) |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
207 - p->read_length; |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
208 |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
209 if (limit <= 0) { |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
210 p->upstream->read->delayed = 1; |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
211 delay = (ngx_msec_t) (- limit * 1000 / p->limit_rate + 1); |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
212 ngx_add_timer(p->upstream->read, delay); |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
213 break; |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
214 } |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
215 |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
216 } else { |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
217 limit = 0; |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
218 } |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
219 |
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:
304
diff
changeset
|
220 if (p->free_raw_bufs) { |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
221 |
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:
304
diff
changeset
|
222 /* use the free bufs if they exist */ |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
223 |
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:
304
diff
changeset
|
224 chain = p->free_raw_bufs; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
225 if (p->single_buf) { |
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:
304
diff
changeset
|
226 p->free_raw_bufs = p->free_raw_bufs->next; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
227 chain->next = NULL; |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
228 } else { |
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:
304
diff
changeset
|
229 p->free_raw_bufs = NULL; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
230 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 |
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:
304
diff
changeset
|
232 } else if (p->allocated < p->bufs.num) { |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
233 |
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:
304
diff
changeset
|
234 /* allocate a new buf if it's still allowed */ |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
235 |
501 | 236 b = ngx_create_temp_buf(p->pool, p->bufs.size); |
237 if (b == NULL) { | |
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:
304
diff
changeset
|
238 return NGX_ABORT; |
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:
304
diff
changeset
|
239 } |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
240 |
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:
304
diff
changeset
|
241 p->allocated++; |
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:
304
diff
changeset
|
242 |
501 | 243 chain = ngx_alloc_chain_link(p->pool); |
244 if (chain == NULL) { | |
483 | 245 return NGX_ABORT; |
246 } | |
247 | |
248 chain->buf = b; | |
249 chain->next = NULL; | |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 |
1565 | 251 } else if (!p->cacheable |
509 | 252 && p->downstream->data == p->output_ctx |
527 | 253 && p->downstream->write->ready |
254 && !p->downstream->write->delayed) | |
509 | 255 { |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
256 /* |
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:
304
diff
changeset
|
257 * if the bufs are not needed to be saved in a cache and |
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:
304
diff
changeset
|
258 * a downstream is ready then write the bufs to a downstream |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
259 */ |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
260 |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
261 p->upstream_blocked = 1; |
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
262 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
263 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
264 "pipe downstream ready"); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
265 |
78
9f81437e0ad3
nginx-0.0.1-2003-04-21-18:55:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
266 break; |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
267 |
1565 | 268 } else if (p->cacheable |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
269 || p->temp_file->offset < p->max_temp_file_size) |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
270 { |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
271 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
272 /* |
5347 | 273 * if it is allowed, then save some bufs from p->in |
274 * to a temporary file, and add them to a p->out chain | |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
275 */ |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
276 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
277 rc = ngx_event_pipe_write_chain_to_temp_file(p); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
278 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
279 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 280 "pipe temp offset: %O", p->temp_file->offset); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
281 |
521 | 282 if (rc == NGX_BUSY) { |
283 break; | |
284 } | |
285 | |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
286 if (rc != NGX_OK) { |
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
287 return rc; |
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
288 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
289 |
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:
304
diff
changeset
|
290 chain = p->free_raw_bufs; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
291 if (p->single_buf) { |
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:
304
diff
changeset
|
292 p->free_raw_bufs = p->free_raw_bufs->next; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
293 chain->next = NULL; |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
294 } else { |
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:
304
diff
changeset
|
295 p->free_raw_bufs = NULL; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
296 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
297 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
298 } else { |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
299 |
483 | 300 /* there are no bufs to read in */ |
78
9f81437e0ad3
nginx-0.0.1-2003-04-21-18:55:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
301 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
302 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
303 "no pipe bufs to read in"); |
577 | 304 |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
305 break; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
306 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
307 |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
308 n = p->upstream->recv_chain(p->upstream, chain, limit); |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
309 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
310 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 311 "pipe recv chain: %z", n); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
312 |
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:
304
diff
changeset
|
313 if (p->free_raw_bufs) { |
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:
304
diff
changeset
|
314 chain->next = p->free_raw_bufs; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
315 } |
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:
304
diff
changeset
|
316 p->free_raw_bufs = chain; |
151
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
317 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
318 if (n == NGX_ERROR) { |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
319 p->upstream_error = 1; |
6672
0fa883e92895
Event pipe: process data after recv_chain() errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
320 break; |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
321 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
322 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
323 if (n == NGX_AGAIN) { |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
324 if (p->single_buf) { |
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:
304
diff
changeset
|
325 ngx_event_pipe_remove_shadow_links(chain->buf); |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
326 } |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
327 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
328 break; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
329 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
330 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
331 p->read = 1; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
332 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
333 if (n == 0) { |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
334 p->upstream_eof = 1; |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
335 break; |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
336 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
337 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
338 |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
339 delay = p->limit_rate ? (ngx_msec_t) n * 1000 / p->limit_rate : 0; |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
340 |
175
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
341 p->read_length += n; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
342 cl = chain; |
858
4766f61a8221
fix endless loop when too many FastCGI sent too many to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
840
diff
changeset
|
343 p->free_raw_bufs = NULL; |
151
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
344 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
345 while (cl && n > 0) { |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
346 |
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:
304
diff
changeset
|
347 ngx_event_pipe_remove_shadow_links(cl->buf); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
348 |
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:
304
diff
changeset
|
349 size = cl->buf->end - cl->buf->last; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
350 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
351 if (n >= size) { |
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:
304
diff
changeset
|
352 cl->buf->last = cl->buf->end; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
353 |
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:
304
diff
changeset
|
354 /* STUB */ cl->buf->num = p->num++; |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
355 |
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:
304
diff
changeset
|
356 if (p->input_filter(p, cl->buf) == NGX_ERROR) { |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
357 return NGX_ABORT; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
358 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
359 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
360 n -= size; |
507 | 361 ln = cl; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
362 cl = cl->next; |
507 | 363 ngx_free_chain(p->pool, ln); |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
364 |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
365 } else { |
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:
304
diff
changeset
|
366 cl->buf->last += n; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
367 n = 0; |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
368 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
369 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
370 |
858
4766f61a8221
fix endless loop when too many FastCGI sent too many to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
840
diff
changeset
|
371 if (cl) { |
859 | 372 for (ln = cl; ln->next; ln = ln->next) { /* void */ } |
858
4766f61a8221
fix endless loop when too many FastCGI sent too many to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
840
diff
changeset
|
373 |
859 | 374 ln->next = p->free_raw_bufs; |
858
4766f61a8221
fix endless loop when too many FastCGI sent too many to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
840
diff
changeset
|
375 p->free_raw_bufs = cl; |
4766f61a8221
fix endless loop when too many FastCGI sent too many to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
840
diff
changeset
|
376 } |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
377 |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
378 if (delay > 0) { |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
379 p->upstream->read->delayed = 1; |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
380 ngx_add_timer(p->upstream->read, delay); |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
381 break; |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5882
diff
changeset
|
382 } |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
383 } |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
384 |
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:
304
diff
changeset
|
385 #if (NGX_DEBUG) |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
386 |
452 | 387 for (cl = p->busy; cl; cl = cl->next) { |
483 | 388 ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0, |
389 "pipe buf busy s:%d t:%d f:%d " | |
390 "%p, pos %p, size: %z " | |
6044
b8926ba4d087
Format specifier fixed for file size of buffers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5883
diff
changeset
|
391 "file: %O, size: %O", |
483 | 392 (cl->buf->shadow ? 1 : 0), |
393 cl->buf->temporary, cl->buf->in_file, | |
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:
304
diff
changeset
|
394 cl->buf->start, cl->buf->pos, |
483 | 395 cl->buf->last - cl->buf->pos, |
396 cl->buf->file_pos, | |
397 cl->buf->file_last - cl->buf->file_pos); | |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
398 } |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
399 |
452 | 400 for (cl = p->out; cl; cl = cl->next) { |
483 | 401 ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0, |
402 "pipe buf out s:%d t:%d f:%d " | |
403 "%p, pos %p, size: %z " | |
6044
b8926ba4d087
Format specifier fixed for file size of buffers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5883
diff
changeset
|
404 "file: %O, size: %O", |
483 | 405 (cl->buf->shadow ? 1 : 0), |
406 cl->buf->temporary, cl->buf->in_file, | |
407 cl->buf->start, cl->buf->pos, | |
408 cl->buf->last - cl->buf->pos, | |
409 cl->buf->file_pos, | |
410 cl->buf->file_last - cl->buf->file_pos); | |
452 | 411 } |
412 | |
413 for (cl = p->in; cl; cl = cl->next) { | |
483 | 414 ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0, |
415 "pipe buf in s:%d t:%d f:%d " | |
416 "%p, pos %p, size: %z " | |
6044
b8926ba4d087
Format specifier fixed for file size of buffers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5883
diff
changeset
|
417 "file: %O, size: %O", |
483 | 418 (cl->buf->shadow ? 1 : 0), |
419 cl->buf->temporary, cl->buf->in_file, | |
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:
304
diff
changeset
|
420 cl->buf->start, cl->buf->pos, |
483 | 421 cl->buf->last - cl->buf->pos, |
422 cl->buf->file_pos, | |
423 cl->buf->file_last - cl->buf->file_pos); | |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
424 } |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
425 |
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:
304
diff
changeset
|
426 for (cl = p->free_raw_bufs; cl; cl = cl->next) { |
483 | 427 ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0, |
428 "pipe buf free s:%d t:%d f:%d " | |
429 "%p, pos %p, size: %z " | |
6044
b8926ba4d087
Format specifier fixed for file size of buffers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5883
diff
changeset
|
430 "file: %O, size: %O", |
483 | 431 (cl->buf->shadow ? 1 : 0), |
432 cl->buf->temporary, cl->buf->in_file, | |
433 cl->buf->start, cl->buf->pos, | |
434 cl->buf->last - cl->buf->pos, | |
435 cl->buf->file_pos, | |
436 cl->buf->file_last - cl->buf->file_pos); | |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
437 } |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
438 |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
439 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
440 "pipe length: %O", p->length); |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
441 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
442 #endif |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
443 |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
444 if (p->free_raw_bufs && p->length != -1) { |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
445 cl = p->free_raw_bufs; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
446 |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
447 if (cl->buf->last - cl->buf->pos >= p->length) { |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
448 |
4489
9806bf07d119
Event pipe: fixed buffer loss in p->length case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
449 p->free_raw_bufs = cl->next; |
9806bf07d119
Event pipe: fixed buffer loss in p->length case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
450 |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
451 /* STUB */ cl->buf->num = p->num++; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
452 |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
453 if (p->input_filter(p, cl->buf) == NGX_ERROR) { |
6474 | 454 return NGX_ABORT; |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
455 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
456 |
4137
6b9b7e7ac4a9
Fixed loss of chain links in ngx_event_pipe_read_upstream().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4135
diff
changeset
|
457 ngx_free_chain(p->pool, cl); |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
458 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
459 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
460 |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
461 if (p->length == 0) { |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
462 p->upstream_done = 1; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
463 p->read = 1; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
464 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
465 |
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:
304
diff
changeset
|
466 if ((p->upstream_eof || p->upstream_error) && p->free_raw_bufs) { |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
467 |
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:
304
diff
changeset
|
468 /* STUB */ p->free_raw_bufs->buf->num = p->num++; |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
469 |
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:
304
diff
changeset
|
470 if (p->input_filter(p, p->free_raw_bufs->buf) == NGX_ERROR) { |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
471 return NGX_ABORT; |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
472 } |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
473 |
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:
304
diff
changeset
|
474 p->free_raw_bufs = p->free_raw_bufs->next; |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
475 |
2797
90422d071d3f
do not free buffer with cache header before it would be written,
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
476 if (p->free_bufs && p->buf_to_file == NULL) { |
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:
304
diff
changeset
|
477 for (cl = p->free_raw_bufs; cl; cl = cl->next) { |
452 | 478 if (cl->buf->shadow == NULL) { |
577 | 479 ngx_pfree(p->pool, cl->buf->start); |
452 | 480 } |
168
ba5dbb949603
nginx-0.0.1-2003-10-31-10:10:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
481 } |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
482 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
483 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
484 |
5746
35990c69b3ac
Upstream: p->downstream_error instead of closing connection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5466
diff
changeset
|
485 if (p->cacheable && (p->in || p->buf_to_file)) { |
35990c69b3ac
Upstream: p->downstream_error instead of closing connection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5466
diff
changeset
|
486 |
35990c69b3ac
Upstream: p->downstream_error instead of closing connection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5466
diff
changeset
|
487 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
35990c69b3ac
Upstream: p->downstream_error instead of closing connection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5466
diff
changeset
|
488 "pipe write chain"); |
35990c69b3ac
Upstream: p->downstream_error instead of closing connection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5466
diff
changeset
|
489 |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
490 rc = ngx_event_pipe_write_chain_to_temp_file(p); |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
491 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
492 if (rc != NGX_OK) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
493 return rc; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
494 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
495 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
496 |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
497 return NGX_OK; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
498 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
499 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
500 |
577 | 501 static ngx_int_t |
502 ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p) | |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
503 { |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
504 u_char *prev; |
583 | 505 size_t bsize; |
1625 | 506 ngx_int_t rc; |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
507 ngx_uint_t flush, flushed, prev_last_shadow; |
5290
355779f81491
Event pipe: fixed writing cache header to a temp file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4895
diff
changeset
|
508 ngx_chain_t *out, **ll, *cl; |
583 | 509 ngx_connection_t *downstream; |
510 | |
511 downstream = p->downstream; | |
146
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
512 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
513 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
583 | 514 "pipe write downstream: %d", downstream->write->ready); |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
515 |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
516 #if (NGX_THREADS) |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
517 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
518 if (p->writing) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
519 rc = ngx_event_pipe_write_chain_to_temp_file(p); |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
520 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
521 if (rc == NGX_ABORT) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
522 return NGX_ABORT; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
523 } |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
524 } |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
525 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
526 #endif |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
527 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
528 flushed = 0; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
529 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
530 for ( ;; ) { |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
531 if (p->downstream_error) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
532 return ngx_event_pipe_drain_chains(p); |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
533 } |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
534 |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
535 if (p->upstream_eof || p->upstream_error || p->upstream_done) { |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
536 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
537 /* pass the p->out and p->in chains to the output filter */ |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
538 |
509 | 539 for (cl = p->busy; cl; cl = cl->next) { |
540 cl->buf->recycled = 0; | |
541 } | |
542 | |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
543 if (p->out) { |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
544 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
545 "pipe write downstream flush out"); |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
546 |
509 | 547 for (cl = p->out; cl; cl = cl->next) { |
548 cl->buf->recycled = 0; | |
549 } | |
550 | |
1625 | 551 rc = p->output_filter(p->output_ctx, p->out); |
552 | |
553 if (rc == NGX_ERROR) { | |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
554 p->downstream_error = 1; |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
555 return ngx_event_pipe_drain_chains(p); |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
556 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
557 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
558 p->out = NULL; |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
559 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
560 |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
561 if (p->writing) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
562 break; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
563 } |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
564 |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
565 if (p->in) { |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
566 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
567 "pipe write downstream flush in"); |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
568 |
509 | 569 for (cl = p->in; cl; cl = cl->next) { |
570 cl->buf->recycled = 0; | |
571 } | |
572 | |
1625 | 573 rc = p->output_filter(p->output_ctx, p->in); |
583 | 574 |
1625 | 575 if (rc == NGX_ERROR) { |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
576 p->downstream_error = 1; |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
577 return ngx_event_pipe_drain_chains(p); |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
578 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
579 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
580 p->in = NULL; |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
581 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
582 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
583 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
584 "pipe write downstream done"); |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
585 |
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:
304
diff
changeset
|
586 /* TODO: free unused bufs */ |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
587 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
588 p->downstream_done = 1; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
589 break; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
590 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
591 |
583 | 592 if (downstream->data != p->output_ctx |
593 || !downstream->write->ready | |
594 || downstream->write->delayed) | |
509 | 595 { |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
596 break; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
597 } |
146
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
598 |
479 | 599 /* bsize is the size of the busy recycled bufs */ |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
600 |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
601 prev = NULL; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
602 bsize = 0; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
603 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
604 for (cl = p->busy; cl; cl = cl->next) { |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
605 |
479 | 606 if (cl->buf->recycled) { |
1102 | 607 if (prev == cl->buf->start) { |
608 continue; | |
609 } | |
610 | |
479 | 611 bsize += cl->buf->end - cl->buf->start; |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
612 prev = cl->buf->start; |
479 | 613 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
614 } |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
615 |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
616 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
479 | 617 "pipe write busy: %uz", bsize); |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
618 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
619 out = NULL; |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
620 |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
621 if (bsize >= (size_t) p->busy_size) { |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
622 flush = 1; |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
623 goto flush; |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
624 } |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
625 |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
626 flush = 0; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
627 ll = NULL; |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
628 prev_last_shadow = 1; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
629 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
630 for ( ;; ) { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
631 if (p->out) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
632 cl = p->out; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
633 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
634 if (cl->buf->recycled) { |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
635 ngx_log_error(NGX_LOG_ALERT, p->log, 0, |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
636 "recycled buffer in pipe out chain"); |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
637 } |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
638 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
639 p->out = p->out->next; |
479 | 640 |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
641 } else if (!p->cacheable && !p->writing && p->in) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
642 cl = p->in; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
643 |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
644 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, p->log, 0, |
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
645 "pipe write buf ls:%d %p %z", |
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
646 cl->buf->last_shadow, |
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
647 cl->buf->pos, |
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
648 cl->buf->last - cl->buf->pos); |
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
649 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
650 if (cl->buf->recycled && prev_last_shadow) { |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
651 if (bsize + cl->buf->end - cl->buf->start > p->busy_size) { |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
652 flush = 1; |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
653 break; |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
654 } |
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
655 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
656 bsize += cl->buf->end - cl->buf->start; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
657 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
658 |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
659 prev_last_shadow = cl->buf->last_shadow; |
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
660 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
661 p->in = p->in->next; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
662 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
663 } else { |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
664 break; |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
665 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
666 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
667 cl->next = NULL; |
501 | 668 |
669 if (out) { | |
670 *ll = cl; | |
671 } else { | |
672 out = cl; | |
673 } | |
674 ll = &cl->next; | |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
675 } |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
676 |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
677 flush: |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
678 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
679 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
6480 | 680 "pipe write: out:%p, f:%ui", out, flush); |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
681 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
682 if (out == NULL) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
683 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
684 if (!flush) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
685 break; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
686 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
687 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
688 /* a workaround for AIO */ |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
689 if (flushed++ > 10) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
690 return NGX_BUSY; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
691 } |
146
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
692 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
693 |
1625 | 694 rc = p->output_filter(p->output_ctx, out); |
695 | |
4135
d8e24515176e
Fix of cpu hog in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4119
diff
changeset
|
696 ngx_chain_update_chains(p->pool, &p->free, &p->busy, &out, p->tag); |
d8e24515176e
Fix of cpu hog in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4119
diff
changeset
|
697 |
1625 | 698 if (rc == NGX_ERROR) { |
151
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
699 p->downstream_error = 1; |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
700 return ngx_event_pipe_drain_chains(p); |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
701 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
702 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
703 for (cl = p->free; cl; cl = cl->next) { |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
704 |
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:
304
diff
changeset
|
705 if (cl->buf->temp_file) { |
1565 | 706 if (p->cacheable || !p->cyclic_temp_file) { |
175
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
707 continue; |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
708 } |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
709 |
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:
304
diff
changeset
|
710 /* reset p->temp_offset if all bufs had been sent */ |
175
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
711 |
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:
304
diff
changeset
|
712 if (cl->buf->file_last == p->temp_file->offset) { |
175
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
713 p->temp_file->offset = 0; |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
714 } |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
715 } |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
716 |
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:
304
diff
changeset
|
717 /* TODO: free buf if p->free_bufs && upstream done */ |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
175
diff
changeset
|
718 |
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:
304
diff
changeset
|
719 /* add the free shadow raw buf to p->free_raw_bufs */ |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
720 |
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:
304
diff
changeset
|
721 if (cl->buf->last_shadow) { |
483 | 722 if (ngx_event_pipe_add_free_buf(p, cl->buf->shadow) != NGX_OK) { |
723 return NGX_ABORT; | |
724 } | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
725 |
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:
304
diff
changeset
|
726 cl->buf->last_shadow = 0; |
146
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
727 } |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
728 |
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:
304
diff
changeset
|
729 cl->buf->shadow = NULL; |
146
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
730 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
731 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
732 |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
733 return NGX_OK; |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
734 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
735 |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
736 |
577 | 737 static ngx_int_t |
738 ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p) | |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
739 { |
4233
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
740 ssize_t size, bsize, n; |
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:
304
diff
changeset
|
741 ngx_buf_t *b; |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
742 ngx_uint_t prev_last_shadow; |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
743 ngx_chain_t *cl, *tl, *next, *out, **ll, **last_out, **last_free; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
744 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
745 #if (NGX_THREADS) |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
746 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
747 if (p->writing) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
748 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
749 if (p->aio) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
750 return NGX_AGAIN; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
751 } |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
752 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
753 out = p->writing; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
754 p->writing = NULL; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
755 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
756 n = ngx_write_chain_to_temp_file(p->temp_file, NULL); |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
757 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
758 if (n == NGX_ERROR) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
759 return NGX_ABORT; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
760 } |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
761 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
762 goto done; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
763 } |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
764 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
765 #endif |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
766 |
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:
304
diff
changeset
|
767 if (p->buf_to_file) { |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
768 out = ngx_alloc_chain_link(p->pool); |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
769 if (out == NULL) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
770 return NGX_ABORT; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
771 } |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
772 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
773 out->buf = p->buf_to_file; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
774 out->next = p->in; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
775 |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
776 } else { |
187
5a9bbe99008b
nginx-0.0.1-2003-11-17-19:15:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
777 out = p->in; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
778 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
779 |
1565 | 780 if (!p->cacheable) { |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
781 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
782 size = 0; |
187
5a9bbe99008b
nginx-0.0.1-2003-11-17-19:15:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
783 cl = out; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
784 ll = NULL; |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
785 prev_last_shadow = 1; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
786 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
787 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 788 "pipe offset: %O", p->temp_file->offset); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
789 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
790 do { |
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:
304
diff
changeset
|
791 bsize = cl->buf->last - cl->buf->pos; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
792 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
793 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, p->log, 0, |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
794 "pipe buf ls:%d %p, pos %p, size: %z", |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
795 cl->buf->last_shadow, cl->buf->start, |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
796 cl->buf->pos, bsize); |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
797 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
798 if (prev_last_shadow |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
799 && ((size + bsize > p->temp_file_write_size) |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
800 || (p->temp_file->offset + size + bsize |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
801 > p->max_temp_file_size))) |
151
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
802 { |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
803 break; |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
804 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
805 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
806 prev_last_shadow = cl->buf->last_shadow; |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
807 |
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:
304
diff
changeset
|
808 size += bsize; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
809 ll = &cl->next; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
810 cl = cl->next; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
811 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
812 } while (cl); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
813 |
461 | 814 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "size: %z", size); |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
815 |
521 | 816 if (ll == NULL) { |
817 return NGX_BUSY; | |
818 } | |
819 | |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
820 if (cl) { |
6474 | 821 p->in = cl; |
822 *ll = NULL; | |
151
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
823 |
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
824 } else { |
6474 | 825 p->in = NULL; |
826 p->last_in = &p->in; | |
151
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
827 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
828 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
829 } else { |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
830 p->in = NULL; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
831 p->last_in = &p->in; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
832 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
833 |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
834 #if (NGX_THREADS) |
6673
e4c1f5b32868
Event pipe: do not set file's thread_handler if not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6672
diff
changeset
|
835 if (p->thread_handler) { |
e4c1f5b32868
Event pipe: do not set file's thread_handler if not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6672
diff
changeset
|
836 p->temp_file->thread_write = 1; |
e4c1f5b32868
Event pipe: do not set file's thread_handler if not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6672
diff
changeset
|
837 p->temp_file->file.thread_task = p->thread_task; |
e4c1f5b32868
Event pipe: do not set file's thread_handler if not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6672
diff
changeset
|
838 p->temp_file->file.thread_handler = p->thread_handler; |
e4c1f5b32868
Event pipe: do not set file's thread_handler if not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6672
diff
changeset
|
839 p->temp_file->file.thread_ctx = p->thread_ctx; |
e4c1f5b32868
Event pipe: do not set file's thread_handler if not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6672
diff
changeset
|
840 } |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
841 #endif |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
842 |
4233
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
843 n = ngx_write_chain_to_temp_file(p->temp_file, out); |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
844 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
845 if (n == NGX_ERROR) { |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
140
diff
changeset
|
846 return NGX_ABORT; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
847 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
848 |
6443
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
849 #if (NGX_THREADS) |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
850 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
851 if (n == NGX_AGAIN) { |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
852 p->writing = out; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
853 p->thread_task = p->temp_file->file.thread_task; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
854 return NGX_AGAIN; |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
855 } |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
856 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
857 done: |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
858 |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
859 #endif |
fc72784b1f52
Threads: writing via threads pools in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6165
diff
changeset
|
860 |
4233
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
861 if (p->buf_to_file) { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
862 p->temp_file->offset = p->buf_to_file->last - p->buf_to_file->pos; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
863 n -= p->buf_to_file->last - p->buf_to_file->pos; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
864 p->buf_to_file = NULL; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
865 out = out->next; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
866 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
867 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
868 if (n > 0) { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
869 /* update previous buffer or add new buffer */ |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
870 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
871 if (p->out) { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
872 for (cl = p->out; cl->next; cl = cl->next) { /* void */ } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
873 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
874 b = cl->buf; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
875 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
876 if (b->file_last == p->temp_file->offset) { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
877 p->temp_file->offset += n; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
878 b->file_last = p->temp_file->offset; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
879 goto free; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
880 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
881 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
882 last_out = &cl->next; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
883 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
884 } else { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
885 last_out = &p->out; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
886 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
887 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
888 cl = ngx_chain_get_free_buf(p->pool, &p->free); |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
889 if (cl == NULL) { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
890 return NGX_ABORT; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
891 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
892 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
893 b = cl->buf; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
894 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
895 ngx_memzero(b, sizeof(ngx_buf_t)); |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
896 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
897 b->tag = p->tag; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
898 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
899 b->file = &p->temp_file->file; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
900 b->file_pos = p->temp_file->offset; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
901 p->temp_file->offset += n; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
902 b->file_last = p->temp_file->offset; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
903 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
904 b->in_file = 1; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
905 b->temp_file = 1; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
906 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
907 *last_out = cl; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
908 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
909 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
910 free: |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
911 |
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:
304
diff
changeset
|
912 for (last_free = &p->free_raw_bufs; |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
913 *last_free != NULL; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
914 last_free = &(*last_free)->next) |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
915 { |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
916 /* void */ |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
917 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
918 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
919 for (cl = out; cl; cl = next) { |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
920 next = cl->next; |
4233
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
921 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
922 cl->next = p->free; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
923 p->free = cl; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
924 |
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:
304
diff
changeset
|
925 b = cl->buf; |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
926 |
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:
304
diff
changeset
|
927 if (b->last_shadow) { |
483 | 928 |
501 | 929 tl = ngx_alloc_chain_link(p->pool); |
930 if (tl == NULL) { | |
483 | 931 return NGX_ABORT; |
932 } | |
933 | |
934 tl->buf = b->shadow; | |
935 tl->next = NULL; | |
936 | |
937 *last_free = tl; | |
938 last_free = &tl->next; | |
939 | |
452 | 940 b->shadow->pos = b->shadow->start; |
941 b->shadow->last = b->shadow->start; | |
942 | |
483 | 943 ngx_event_pipe_remove_shadow_links(b->shadow); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
944 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
945 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
946 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
947 return NGX_OK; |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
948 } |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
949 |
78
9f81437e0ad3
nginx-0.0.1-2003-04-21-18:55:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
950 |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
951 /* the copy input filter */ |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
952 |
577 | 953 ngx_int_t |
954 ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) | |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
955 { |
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:
304
diff
changeset
|
956 ngx_buf_t *b; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
957 ngx_chain_t *cl; |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
958 |
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:
304
diff
changeset
|
959 if (buf->pos == buf->last) { |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
960 return NGX_OK; |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
961 } |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
962 |
7981
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
963 if (p->upstream_done) { |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
964 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
965 "input data after close"); |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
966 return NGX_OK; |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
967 } |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
968 |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
969 if (p->length == 0) { |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
970 p->upstream_done = 1; |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
971 |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
972 ngx_log_error(NGX_LOG_WARN, p->log, 0, |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
973 "upstream sent more data than specified in " |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
974 "\"Content-Length\" header"); |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
975 |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
976 return NGX_OK; |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
977 } |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
978 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5360
diff
changeset
|
979 cl = ngx_chain_get_free_buf(p->pool, &p->free); |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5360
diff
changeset
|
980 if (cl == NULL) { |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5360
diff
changeset
|
981 return NGX_ERROR; |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5360
diff
changeset
|
982 } |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
983 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5360
diff
changeset
|
984 b = cl->buf; |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
985 |
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:
304
diff
changeset
|
986 ngx_memcpy(b, buf, sizeof(ngx_buf_t)); |
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:
304
diff
changeset
|
987 b->shadow = buf; |
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:
304
diff
changeset
|
988 b->tag = p->tag; |
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:
304
diff
changeset
|
989 b->last_shadow = 1; |
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:
304
diff
changeset
|
990 b->recycled = 1; |
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:
304
diff
changeset
|
991 buf->shadow = b; |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
992 |
479 | 993 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num); |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
994 |
501 | 995 if (p->in) { |
996 *p->last_in = cl; | |
997 } else { | |
998 p->in = cl; | |
999 } | |
1000 p->last_in = &cl->next; | |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
1001 |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
1002 if (p->length == -1) { |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
1003 return NGX_OK; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
1004 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
1005 |
7981
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1006 if (b->last - b->pos > p->length) { |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1007 |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1008 ngx_log_error(NGX_LOG_WARN, p->log, 0, |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1009 "upstream sent more data than specified in " |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1010 "\"Content-Length\" header"); |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1011 |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1012 b->last = b->pos + p->length; |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1013 p->upstream_done = 1; |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1014 |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1015 return NGX_OK; |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1016 } |
bffcc5af1d72
Upstream: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7581
diff
changeset
|
1017 |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
1018 p->length -= b->last - b->pos; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
1019 |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
1020 return NGX_OK; |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
1021 } |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
1022 |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
1023 |
577 | 1024 static ngx_inline void |
1025 ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf) | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
1026 { |
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:
304
diff
changeset
|
1027 ngx_buf_t *b, *next; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
1028 |
452 | 1029 b = buf->shadow; |
1030 | |
1031 if (b == NULL) { | |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
1032 return; |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
1033 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
1034 |
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:
304
diff
changeset
|
1035 while (!b->last_shadow) { |
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:
304
diff
changeset
|
1036 next = b->shadow; |
442
464aaa791e2b
nginx-0.1.0-2004-09-28-19:44:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
1037 |
452 | 1038 b->temporary = 0; |
1039 b->recycled = 0; | |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
1040 |
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:
304
diff
changeset
|
1041 b->shadow = NULL; |
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:
304
diff
changeset
|
1042 b = next; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
1043 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
1044 |
452 | 1045 b->temporary = 0; |
1046 b->recycled = 0; | |
442
464aaa791e2b
nginx-0.1.0-2004-09-28-19:44:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
1047 b->last_shadow = 0; |
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:
304
diff
changeset
|
1048 |
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:
304
diff
changeset
|
1049 b->shadow = NULL; |
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:
304
diff
changeset
|
1050 |
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:
304
diff
changeset
|
1051 buf->shadow = NULL; |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
1052 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
1053 |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
1054 |
577 | 1055 ngx_int_t |
1056 ngx_event_pipe_add_free_buf(ngx_event_pipe_t *p, ngx_buf_t *b) | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
1057 { |
483 | 1058 ngx_chain_t *cl; |
1059 | |
501 | 1060 cl = ngx_alloc_chain_link(p->pool); |
1061 if (cl == NULL) { | |
483 | 1062 return NGX_ERROR; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
1063 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
1064 |
4895
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1065 if (p->buf_to_file && b->start == p->buf_to_file->start) { |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1066 b->pos = p->buf_to_file->last; |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1067 b->last = p->buf_to_file->last; |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1068 |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1069 } else { |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1070 b->pos = b->start; |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1071 b->last = b->start; |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1072 } |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1073 |
483 | 1074 b->shadow = NULL; |
1075 | |
1076 cl->buf = b; | |
1077 | |
1078 if (p->free_raw_bufs == NULL) { | |
1079 p->free_raw_bufs = cl; | |
1080 cl->next = NULL; | |
1081 | |
1082 return NGX_OK; | |
1083 } | |
1084 | |
1085 if (p->free_raw_bufs->buf->pos == p->free_raw_bufs->buf->last) { | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
1086 |
483 | 1087 /* add the free buf to the list start */ |
1088 | |
1089 cl->next = p->free_raw_bufs; | |
1090 p->free_raw_bufs = cl; | |
1091 | |
1092 return NGX_OK; | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
1093 } |
483 | 1094 |
4499
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4489
diff
changeset
|
1095 /* the first free buf is partially filled, thus add the free buf after it */ |
483 | 1096 |
1097 cl->next = p->free_raw_bufs->next; | |
1098 p->free_raw_bufs->next = cl; | |
1099 | |
1100 return NGX_OK; | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
1101 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1102 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1103 |
577 | 1104 static ngx_int_t |
1105 ngx_event_pipe_drain_chains(ngx_event_pipe_t *p) | |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1106 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1107 ngx_chain_t *cl, *tl; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1108 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1109 for ( ;; ) { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1110 if (p->busy) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1111 cl = p->busy; |
188
0061d1f0908d
nginx-0.0.1-2003-11-18-11:04:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
187
diff
changeset
|
1112 p->busy = NULL; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1113 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1114 } else if (p->out) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1115 cl = p->out; |
188
0061d1f0908d
nginx-0.0.1-2003-11-18-11:04:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
187
diff
changeset
|
1116 p->out = NULL; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1117 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1118 } else if (p->in) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1119 cl = p->in; |
188
0061d1f0908d
nginx-0.0.1-2003-11-18-11:04:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
187
diff
changeset
|
1120 p->in = NULL; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1121 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1122 } else { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1123 return NGX_OK; |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1124 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1125 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1126 while (cl) { |
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:
304
diff
changeset
|
1127 if (cl->buf->last_shadow) { |
483 | 1128 if (ngx_event_pipe_add_free_buf(p, cl->buf->shadow) != NGX_OK) { |
479 | 1129 return NGX_ABORT; |
1130 } | |
1131 | |
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:
304
diff
changeset
|
1132 cl->buf->last_shadow = 0; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1133 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1134 |
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:
304
diff
changeset
|
1135 cl->buf->shadow = NULL; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1136 tl = cl->next; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1137 cl->next = p->free; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1138 p->free = cl; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1139 cl = tl; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1140 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1141 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1142 } |