Mercurial > hg > nginx-quic
annotate src/event/ngx_event_pipe.c @ 5361:7094d6da2806
Win32: $request_time fixed.
On win32, time_t is 64 bits wide by default, and passing an ngx_msec_int_t
argument for %T format specifier doesn't work. This doesn't manifest itself
on other platforms as time_t and ngx_msec_int_t are usually of the same size.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 04 Sep 2013 20:48:30 +0400 |
parents | 3d2d3e1cf427 |
children | e7b3b9855be8 |
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 { |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
189
diff
changeset
|
25 u_int flags; |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
26 ngx_int_t rc; |
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 |
613 | 69 if (rev->active && !rev->ready) { |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
70 ngx_add_timer(rev, p->read_timeout); |
613 | 71 |
72 } else if (rev->timer_set) { | |
73 ngx_del_timer(rev); | |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
74 } |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
75 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
76 |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5347
diff
changeset
|
77 if (p->downstream->fd != (ngx_socket_t) -1 |
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5347
diff
changeset
|
78 && p->downstream->data == p->output_ctx) |
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5347
diff
changeset
|
79 { |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
80 wev = p->downstream->write; |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
81 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
|
82 return NGX_ABORT; |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
83 } |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
84 |
613 | 85 if (!wev->delayed) { |
86 if (wev->active && !wev->ready) { | |
87 ngx_add_timer(wev, p->send_timeout); | |
88 | |
89 } else if (wev->timer_set) { | |
90 ngx_del_timer(wev); | |
91 } | |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
92 } |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
93 } |
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
163
diff
changeset
|
94 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
95 return NGX_OK; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
96 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
97 |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
98 |
577 | 99 static ngx_int_t |
100 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
|
101 { |
461 | 102 ssize_t n, size; |
103 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
|
104 ngx_buf_t *b; |
507 | 105 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
|
106 |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
107 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
|
108 return NGX_OK; |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
109 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
110 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
111 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
|
112 "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
|
113 |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
114 for ( ;; ) { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
115 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
116 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
|
117 break; |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
118 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
119 |
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
|
120 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
|
121 break; |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
122 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
123 |
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
|
124 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
|
125 |
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
|
126 /* 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
|
127 |
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
|
128 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
|
129 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
|
130 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
|
131 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
132 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 133 "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
|
134 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
135 if (n) { |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
136 p->read = 1; |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
137 } |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
138 |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
139 } else { |
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
140 |
581 | 141 #if (NGX_HAVE_KQUEUE) |
142 | |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
143 /* |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
144 * 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
|
145 * This test allows not to allocate a buf on these conditions |
577 | 146 * 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
|
147 */ |
79
eacfdd1c31b9
nginx-0.0.1-2003-04-22-19:02:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
78
diff
changeset
|
148 |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
149 if (p->upstream->read->available == 0 |
587 | 150 && p->upstream->read->pending_eof) |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
151 { |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
152 p->upstream->read->ready = 0; |
4065
227a819b46db
Proper setting of read->eof in pipe code.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3052
diff
changeset
|
153 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
|
154 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
|
155 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
|
156 |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
157 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
|
158 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
|
159 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
|
160 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
|
161 |
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
162 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
|
163 p->upstream->read->kq_errno, |
581 | 164 "kevent() reported that upstream " |
165 "closed connection"); | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
166 } |
163
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
167 |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
168 break; |
79
eacfdd1c31b9
nginx-0.0.1-2003-04-22-19:02:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
78
diff
changeset
|
169 } |
581 | 170 #endif |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
171 |
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
|
172 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
|
173 |
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
|
174 /* 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
|
175 |
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
|
176 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
|
177 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
|
178 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
|
179 chain->next = NULL; |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
180 } 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
|
181 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
|
182 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
183 |
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
|
184 } 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
|
185 |
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
|
186 /* 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
|
187 |
501 | 188 b = ngx_create_temp_buf(p->pool, p->bufs.size); |
189 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
|
190 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
|
191 } |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
192 |
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
|
193 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
|
194 |
501 | 195 chain = ngx_alloc_chain_link(p->pool); |
196 if (chain == NULL) { | |
483 | 197 return NGX_ABORT; |
198 } | |
199 | |
200 chain->buf = b; | |
201 chain->next = NULL; | |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
202 |
1565 | 203 } else if (!p->cacheable |
509 | 204 && p->downstream->data == p->output_ctx |
527 | 205 && p->downstream->write->ready |
206 && !p->downstream->write->delayed) | |
509 | 207 { |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
208 /* |
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
|
209 * 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
|
210 * 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
|
211 */ |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
212 |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
213 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
|
214 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
215 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
|
216 "pipe downstream ready"); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 |
78
9f81437e0ad3
nginx-0.0.1-2003-04-21-18:55:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
218 break; |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
219 |
1565 | 220 } 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
|
221 || 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
|
222 { |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
223 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
224 /* |
5347 | 225 * if it is allowed, then save some bufs from p->in |
226 * 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
|
227 */ |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
228 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
229 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
|
230 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
231 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 232 "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
|
233 |
521 | 234 if (rc == NGX_BUSY) { |
235 break; | |
236 } | |
237 | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
238 if (rc == NGX_AGAIN) { |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
239 if (ngx_event_flags & NGX_USE_LEVEL_EVENT |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
240 && p->upstream->read->active |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
241 && p->upstream->read->ready) |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
242 { |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
243 if (ngx_del_event(p->upstream->read, NGX_READ_EVENT, 0) |
577 | 244 == NGX_ERROR) |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
245 { |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
246 return NGX_ABORT; |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
247 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
248 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
249 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
250 |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
251 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
|
252 return rc; |
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
253 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
254 |
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
|
255 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
|
256 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
|
257 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
|
258 chain->next = NULL; |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
259 } 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
|
260 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
|
261 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
262 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
263 } else { |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
264 |
483 | 265 /* 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
|
266 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
267 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
|
268 "no pipe bufs to read in"); |
577 | 269 |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
270 break; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
271 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
272 |
577 | 273 n = p->upstream->recv_chain(p->upstream, chain); |
77
57c2e18d3572
nginx-0.0.1-2003-04-17-21:59:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
274 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
275 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 276 "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
|
277 |
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
|
278 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
|
279 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
|
280 } |
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
|
281 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
|
282 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
283 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
|
284 p->upstream_error = 1; |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
285 return NGX_ERROR; |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
286 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
287 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 } |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
292 |
145
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
293 break; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
294 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
296 p->read = 1; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
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 if (n == 0) { |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
299 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
|
300 break; |
58557d0cccd1
nginx-0.0.1-2003-10-13-20:32:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
301 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
303 |
175
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
304 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
|
305 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
|
306 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
|
307 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
308 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
|
309 |
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
|
310 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
|
311 |
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
|
312 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
|
313 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
314 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
|
315 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
|
316 |
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
|
317 /* 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
|
318 |
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
|
319 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
|
320 return NGX_ABORT; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
321 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
322 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
323 n -= size; |
507 | 324 ln = cl; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
325 cl = cl->next; |
507 | 326 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
|
327 |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
328 } 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
|
329 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
|
330 n = 0; |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
331 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
332 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
333 |
858
4766f61a8221
fix endless loop when too many FastCGI sent too many to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
840
diff
changeset
|
334 if (cl) { |
859 | 335 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
|
336 |
859 | 337 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
|
338 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
|
339 } |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
340 } |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
341 |
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
|
342 #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
|
343 |
452 | 344 for (cl = p->busy; cl; cl = cl->next) { |
483 | 345 ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0, |
346 "pipe buf busy s:%d t:%d f:%d " | |
347 "%p, pos %p, size: %z " | |
348 "file: %O, size: %z", | |
349 (cl->buf->shadow ? 1 : 0), | |
350 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
|
351 cl->buf->start, cl->buf->pos, |
483 | 352 cl->buf->last - cl->buf->pos, |
353 cl->buf->file_pos, | |
354 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
|
355 } |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
356 |
452 | 357 for (cl = p->out; cl; cl = cl->next) { |
483 | 358 ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0, |
359 "pipe buf out s:%d t:%d f:%d " | |
360 "%p, pos %p, size: %z " | |
361 "file: %O, size: %z", | |
362 (cl->buf->shadow ? 1 : 0), | |
363 cl->buf->temporary, cl->buf->in_file, | |
364 cl->buf->start, cl->buf->pos, | |
365 cl->buf->last - cl->buf->pos, | |
366 cl->buf->file_pos, | |
367 cl->buf->file_last - cl->buf->file_pos); | |
452 | 368 } |
369 | |
370 for (cl = p->in; cl; cl = cl->next) { | |
483 | 371 ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0, |
372 "pipe buf in s:%d t:%d f:%d " | |
373 "%p, pos %p, size: %z " | |
374 "file: %O, size: %z", | |
375 (cl->buf->shadow ? 1 : 0), | |
376 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
|
377 cl->buf->start, cl->buf->pos, |
483 | 378 cl->buf->last - cl->buf->pos, |
379 cl->buf->file_pos, | |
380 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
|
381 } |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
382 |
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
|
383 for (cl = p->free_raw_bufs; cl; cl = cl->next) { |
483 | 384 ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0, |
385 "pipe buf free s:%d t:%d f:%d " | |
386 "%p, pos %p, size: %z " | |
387 "file: %O, size: %z", | |
388 (cl->buf->shadow ? 1 : 0), | |
389 cl->buf->temporary, cl->buf->in_file, | |
390 cl->buf->start, cl->buf->pos, | |
391 cl->buf->last - cl->buf->pos, | |
392 cl->buf->file_pos, | |
393 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
|
394 } |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
395 |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
396 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
|
397 "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
|
398 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
399 #endif |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
400 |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
401 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
|
402 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
|
403 |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
404 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
|
405 |
4489
9806bf07d119
Event pipe: fixed buffer loss in p->length case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
406 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
|
407 |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
408 /* 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
|
409 |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
410 if (p->input_filter(p, cl->buf) == NGX_ERROR) { |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
411 return NGX_ABORT; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
412 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
413 |
4137
6b9b7e7ac4a9
Fixed loss of chain links in ngx_event_pipe_read_upstream().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4135
diff
changeset
|
414 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
|
415 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
416 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
417 |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
418 if (p->length == 0) { |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
419 p->upstream_done = 1; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
420 p->read = 1; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
421 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
422 |
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
|
423 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
|
424 |
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
|
425 /* 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
|
426 |
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
|
427 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
|
428 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
|
429 } |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
430 |
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
|
431 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
|
432 |
2797
90422d071d3f
do not free buffer with cache header before it would be written,
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
433 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
|
434 for (cl = p->free_raw_bufs; cl; cl = cl->next) { |
452 | 435 if (cl->buf->shadow == NULL) { |
577 | 436 ngx_pfree(p->pool, cl->buf->start); |
452 | 437 } |
168
ba5dbb949603
nginx-0.0.1-2003-10-31-10:10:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
438 } |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
439 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
440 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
441 |
1565 | 442 if (p->cacheable && p->in) { |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
443 if (ngx_event_pipe_write_chain_to_temp_file(p) == NGX_ABORT) { |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
140
diff
changeset
|
444 return NGX_ABORT; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
445 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
446 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
447 |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
448 return NGX_OK; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
449 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
450 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
451 |
577 | 452 static ngx_int_t |
453 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
|
454 { |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
455 u_char *prev; |
583 | 456 size_t bsize; |
1625 | 457 ngx_int_t rc; |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
458 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
|
459 ngx_chain_t *out, **ll, *cl; |
583 | 460 ngx_connection_t *downstream; |
461 | |
462 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
|
463 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
464 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
583 | 465 "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
|
466 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
467 flushed = 0; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
468 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
469 for ( ;; ) { |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
470 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
|
471 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
|
472 } |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
473 |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
474 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
|
475 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
476 /* 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
|
477 |
509 | 478 for (cl = p->busy; cl; cl = cl->next) { |
479 cl->buf->recycled = 0; | |
480 } | |
481 | |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
482 if (p->out) { |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
483 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
|
484 "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
|
485 |
509 | 486 for (cl = p->out; cl; cl = cl->next) { |
487 cl->buf->recycled = 0; | |
488 } | |
489 | |
1625 | 490 rc = p->output_filter(p->output_ctx, p->out); |
491 | |
492 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
|
493 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
|
494 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
|
495 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
496 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
497 p->out = NULL; |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
498 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
499 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
500 if (p->in) { |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
501 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
|
502 "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
|
503 |
509 | 504 for (cl = p->in; cl; cl = cl->next) { |
505 cl->buf->recycled = 0; | |
506 } | |
507 | |
1625 | 508 rc = p->output_filter(p->output_ctx, p->in); |
583 | 509 |
1625 | 510 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
|
511 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
|
512 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
|
513 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
514 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
515 p->in = NULL; |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
516 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
517 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
518 if (p->cacheable && p->buf_to_file) { |
5290
355779f81491
Event pipe: fixed writing cache header to a temp file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4895
diff
changeset
|
519 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
355779f81491
Event pipe: fixed writing cache header to a temp file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4895
diff
changeset
|
520 "pipe write chain"); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
521 |
5290
355779f81491
Event pipe: fixed writing cache header to a temp file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4895
diff
changeset
|
522 if (ngx_event_pipe_write_chain_to_temp_file(p) == NGX_ABORT) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
523 return NGX_ABORT; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
524 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
525 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
526 |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
527 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
|
528 "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
|
529 |
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
|
530 /* 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
|
531 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
532 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
|
533 break; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
534 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
535 |
583 | 536 if (downstream->data != p->output_ctx |
537 || !downstream->write->ready | |
538 || downstream->write->delayed) | |
509 | 539 { |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
540 break; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
541 } |
146
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
542 |
479 | 543 /* 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
|
544 |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
545 prev = NULL; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
546 bsize = 0; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
547 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
548 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
|
549 |
479 | 550 if (cl->buf->recycled) { |
1102 | 551 if (prev == cl->buf->start) { |
552 continue; | |
553 } | |
554 | |
479 | 555 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
|
556 prev = cl->buf->start; |
479 | 557 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
558 } |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
559 |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
560 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
479 | 561 "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
|
562 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
563 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
|
564 |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
565 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
|
566 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
|
567 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
|
568 } |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
569 |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
570 flush = 0; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
571 ll = NULL; |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
572 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
|
573 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
574 for ( ;; ) { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
575 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
|
576 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
|
577 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
578 if (cl->buf->recycled) { |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
579 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
|
580 "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
|
581 } |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
582 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
583 p->out = p->out->next; |
479 | 584 |
1565 | 585 } else if (!p->cacheable && p->in) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
586 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
|
587 |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
588 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
|
589 "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
|
590 cl->buf->last_shadow, |
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
591 cl->buf->pos, |
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
592 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
|
593 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
594 if (cl->buf->recycled && prev_last_shadow) { |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
595 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
|
596 flush = 1; |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
597 break; |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
598 } |
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
599 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
600 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
|
601 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
602 |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
603 prev_last_shadow = cl->buf->last_shadow; |
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
604 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
605 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
|
606 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
607 } else { |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
608 break; |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
609 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
610 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
611 cl->next = NULL; |
501 | 612 |
613 if (out) { | |
614 *ll = cl; | |
615 } else { | |
616 out = cl; | |
617 } | |
618 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
|
619 } |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
620 |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
621 flush: |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
622 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
623 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 624 "pipe write: out:%p, f:%d", out, flush); |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
625 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
626 if (out == NULL) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
627 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
628 if (!flush) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
629 break; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
630 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
631 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
632 /* a workaround for AIO */ |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
633 if (flushed++ > 10) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
634 return NGX_BUSY; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
635 } |
146
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
636 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
637 |
1625 | 638 rc = p->output_filter(p->output_ctx, out); |
639 | |
4135
d8e24515176e
Fix of cpu hog in event pipe.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4119
diff
changeset
|
640 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
|
641 |
1625 | 642 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
|
643 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
|
644 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
|
645 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
646 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
647 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
|
648 |
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
|
649 if (cl->buf->temp_file) { |
1565 | 650 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
|
651 continue; |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
652 } |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
653 |
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
|
654 /* 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
|
655 |
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
|
656 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
|
657 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
|
658 } |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
659 } |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
660 |
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
|
661 /* 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
|
662 |
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
|
663 /* 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
|
664 |
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
|
665 if (cl->buf->last_shadow) { |
483 | 666 if (ngx_event_pipe_add_free_buf(p, cl->buf->shadow) != NGX_OK) { |
667 return NGX_ABORT; | |
668 } | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
669 |
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
|
670 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
|
671 } |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
672 |
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
|
673 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
|
674 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
675 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
676 |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
677 return NGX_OK; |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
678 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
679 |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
680 |
577 | 681 static ngx_int_t |
682 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
|
683 { |
4233
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
684 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
|
685 ngx_buf_t *b; |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
686 ngx_uint_t prev_last_shadow; |
4233
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
687 ngx_chain_t *cl, *tl, *next, *out, **ll, **last_out, **last_free, fl; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
688 |
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
|
689 if (p->buf_to_file) { |
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
|
690 fl.buf = p->buf_to_file; |
187
5a9bbe99008b
nginx-0.0.1-2003-11-17-19:15:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
691 fl.next = p->in; |
5a9bbe99008b
nginx-0.0.1-2003-11-17-19:15:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
692 out = &fl; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
693 |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
694 } else { |
187
5a9bbe99008b
nginx-0.0.1-2003-11-17-19:15:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
695 out = p->in; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
696 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
697 |
1565 | 698 if (!p->cacheable) { |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
699 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
700 size = 0; |
187
5a9bbe99008b
nginx-0.0.1-2003-11-17-19:15:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
701 cl = out; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
702 ll = NULL; |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
703 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
|
704 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
705 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 706 "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
|
707 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
708 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
|
709 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
|
710 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
711 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
|
712 "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
|
713 cl->buf->last_shadow, cl->buf->start, |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
714 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
|
715 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
716 if (prev_last_shadow |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
717 && ((size + bsize > p->temp_file_write_size) |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
718 || (p->temp_file->offset + size + bsize |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
719 > 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
|
720 { |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
721 break; |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
722 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
723 |
4232
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
diff
changeset
|
724 prev_last_shadow = cl->buf->last_shadow; |
487ab473f393
Event pipe: fixes for complex protocols.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4137
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 size += bsize; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
727 ll = &cl->next; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
728 cl = cl->next; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
729 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
730 } while (cl); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
731 |
461 | 732 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
|
733 |
521 | 734 if (ll == NULL) { |
735 return NGX_BUSY; | |
736 } | |
737 | |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
738 if (cl) { |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
739 p->in = cl; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
740 *ll = NULL; |
151
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
741 |
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
742 } else { |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
743 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
|
744 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
|
745 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
746 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
747 } else { |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
748 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
|
749 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
|
750 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
751 |
4233
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
752 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
|
753 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
754 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
|
755 return NGX_ABORT; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
756 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
757 |
4233
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
758 if (p->buf_to_file) { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
759 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
|
760 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
|
761 p->buf_to_file = NULL; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
762 out = out->next; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
763 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
764 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
765 if (n > 0) { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
766 /* 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
|
767 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
768 if (p->out) { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
769 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
|
770 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
771 b = cl->buf; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
772 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
773 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
|
774 p->temp_file->offset += n; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
775 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
|
776 goto free; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
777 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
778 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
779 last_out = &cl->next; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
780 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
781 } else { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
782 last_out = &p->out; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
783 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
784 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
785 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
|
786 if (cl == NULL) { |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
787 return NGX_ABORT; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
788 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
789 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
790 b = cl->buf; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
791 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
792 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
|
793 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
794 b->tag = p->tag; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
795 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
796 b->file = &p->temp_file->file; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
797 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
|
798 p->temp_file->offset += n; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
799 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
|
800 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
801 b->in_file = 1; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
802 b->temp_file = 1; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
803 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
804 *last_out = cl; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
805 } |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
806 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
807 free: |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
808 |
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
|
809 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
|
810 *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
|
811 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
|
812 { |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
813 /* void */ |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
814 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
815 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
816 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
|
817 next = cl->next; |
4233
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
818 |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
819 cl->next = p->free; |
aae172db7ac8
Event pipe: reduced number of file buffers used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4232
diff
changeset
|
820 p->free = cl; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
821 |
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
|
822 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
|
823 |
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
|
824 if (b->last_shadow) { |
483 | 825 |
501 | 826 tl = ngx_alloc_chain_link(p->pool); |
827 if (tl == NULL) { | |
483 | 828 return NGX_ABORT; |
829 } | |
830 | |
831 tl->buf = b->shadow; | |
832 tl->next = NULL; | |
833 | |
834 *last_free = tl; | |
835 last_free = &tl->next; | |
836 | |
452 | 837 b->shadow->pos = b->shadow->start; |
838 b->shadow->last = b->shadow->start; | |
839 | |
483 | 840 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
|
841 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
842 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
843 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
844 return NGX_OK; |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
845 } |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
846 |
78
9f81437e0ad3
nginx-0.0.1-2003-04-21-18:55:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
847 |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
848 /* 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
|
849 |
577 | 850 ngx_int_t |
851 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
|
852 { |
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
|
853 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
|
854 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
|
855 |
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
|
856 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
|
857 return NGX_OK; |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
858 } |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
859 |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
860 if (p->free) { |
507 | 861 cl = p->free; |
862 b = cl->buf; | |
863 p->free = cl->next; | |
864 ngx_free_chain(p->pool, cl); | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
865 |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
866 } else { |
501 | 867 b = ngx_alloc_buf(p->pool); |
868 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
|
869 return NGX_ERROR; |
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
|
870 } |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
871 } |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
872 |
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
|
873 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
|
874 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
|
875 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
|
876 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
|
877 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
|
878 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
|
879 |
501 | 880 cl = ngx_alloc_chain_link(p->pool); |
881 if (cl == NULL) { | |
483 | 882 return NGX_ERROR; |
883 } | |
884 | |
885 cl->buf = b; | |
886 cl->next = NULL; | |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
887 |
479 | 888 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
|
889 |
501 | 890 if (p->in) { |
891 *p->last_in = cl; | |
892 } else { | |
893 p->in = cl; | |
894 } | |
895 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
|
896 |
4119
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
897 if (p->length == -1) { |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
898 return NGX_OK; |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
899 } |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
900 |
b66712cde67d
Upstream: pipe length and input_filter_init in buffered mode.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4114
diff
changeset
|
901 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
|
902 |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
903 return NGX_OK; |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
904 } |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
905 |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
906 |
577 | 907 static ngx_inline void |
908 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
|
909 { |
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
|
910 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
|
911 |
452 | 912 b = buf->shadow; |
913 | |
914 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
|
915 return; |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
916 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
917 |
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
|
918 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
|
919 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
|
920 |
452 | 921 b->temporary = 0; |
922 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
|
923 |
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
|
924 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
|
925 b = next; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
926 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
927 |
452 | 928 b->temporary = 0; |
929 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
|
930 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
|
931 |
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
|
932 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
|
933 |
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
|
934 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
|
935 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
936 |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
937 |
577 | 938 ngx_int_t |
939 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
|
940 { |
483 | 941 ngx_chain_t *cl; |
942 | |
501 | 943 cl = ngx_alloc_chain_link(p->pool); |
944 if (cl == NULL) { | |
483 | 945 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
|
946 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
947 |
4895
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
948 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
|
949 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
|
950 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
|
951 |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
952 } else { |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
953 b->pos = b->start; |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
954 b->last = b->start; |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
955 } |
508e61393b6c
Event pipe: fixed handling of buf_to_file data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
956 |
483 | 957 b->shadow = NULL; |
958 | |
959 cl->buf = b; | |
960 | |
961 if (p->free_raw_bufs == NULL) { | |
962 p->free_raw_bufs = cl; | |
963 cl->next = NULL; | |
964 | |
965 return NGX_OK; | |
966 } | |
967 | |
968 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
|
969 |
483 | 970 /* add the free buf to the list start */ |
971 | |
972 cl->next = p->free_raw_bufs; | |
973 p->free_raw_bufs = cl; | |
974 | |
975 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
|
976 } |
483 | 977 |
4499
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4489
diff
changeset
|
978 /* the first free buf is partially filled, thus add the free buf after it */ |
483 | 979 |
980 cl->next = p->free_raw_bufs->next; | |
981 p->free_raw_bufs->next = cl; | |
982 | |
983 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
|
984 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
985 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
986 |
577 | 987 static ngx_int_t |
988 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
|
989 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
990 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
|
991 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
992 for ( ;; ) { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
993 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
|
994 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
|
995 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
|
996 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
997 } 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
|
998 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
|
999 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
|
1000 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1001 } 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
|
1002 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
|
1003 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
|
1004 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1005 } else { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1006 return NGX_OK; |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1007 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1008 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1009 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
|
1010 if (cl->buf->last_shadow) { |
483 | 1011 if (ngx_event_pipe_add_free_buf(p, cl->buf->shadow) != NGX_OK) { |
479 | 1012 return NGX_ABORT; |
1013 } | |
1014 | |
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
|
1015 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
|
1016 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1017 |
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
|
1018 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
|
1019 tl = cl->next; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1020 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
|
1021 p->free = cl; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
1022 cl = tl; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1023 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1024 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
1025 } |