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