Mercurial > hg > nginx
annotate src/event/ngx_event_pipe.c @ 1388:92bc89c5ff0f
regex in valid_referers
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 12 Aug 2007 20:06:43 +0000 |
parents | 37c3b4e62b03 |
children | 4c43e25d11ea e2ab812358bd |
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 |
24 ngx_event_pipe(ngx_event_pipe_t *p, int 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 |
c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
188
diff
changeset
|
59 if (ngx_handle_read_event(rev, flags) == NGX_ERROR) { |
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; |
452 | 73 if (ngx_handle_write_event(wev, p->send_lowat) == NGX_ERROR) { |
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 |
509 | 195 } else if (!p->cachable |
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 |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
212 } else if (p->cachable |
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 |
168
ba5dbb949603
nginx-0.0.1-2003-10-31-10:10:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
400 if (p->free_bufs) { |
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 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
409 if (p->cachable && 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; |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
424 ngx_uint_t flush, prev_last_shadow; |
583 | 425 ngx_chain_t *out, **ll, *cl; |
426 ngx_connection_t *downstream; | |
427 | |
428 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
|
429 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
430 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
583 | 431 "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
|
432 |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
433 for ( ;; ) { |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
434 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
|
435 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
|
436 } |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
437 |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
438 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
|
439 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
440 /* 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
|
441 |
509 | 442 for (cl = p->busy; cl; cl = cl->next) { |
443 cl->buf->recycled = 0; | |
444 } | |
445 | |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
446 if (p->out) { |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
447 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
|
448 "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
|
449 |
509 | 450 for (cl = p->out; cl; cl = cl->next) { |
451 cl->buf->recycled = 0; | |
452 } | |
453 | |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
454 if (p->output_filter(p->output_ctx, p->out) == NGX_ERROR) { |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
455 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
|
456 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
|
457 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
458 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
459 p->out = NULL; |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
460 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
461 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
462 if (p->in) { |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
463 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
|
464 "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
|
465 |
509 | 466 for (cl = p->in; cl; cl = cl->next) { |
467 cl->buf->recycled = 0; | |
468 } | |
469 | |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
470 if (p->output_filter(p->output_ctx, p->in) == NGX_ERROR) { |
583 | 471 |
472 if (downstream->destroyed) { | |
473 return NGX_ABORT; | |
474 } | |
475 | |
293
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
476 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
|
477 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
|
478 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
479 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
480 p->in = NULL; |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
481 } |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
482 |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
483 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
484 "pipe write downstream done"); |
ec3c049681fd
nginx-0.0.3-2004-03-19-08:25:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
485 |
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
|
486 /* 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
|
487 |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
488 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
|
489 break; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
490 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
491 |
583 | 492 if (downstream->data != p->output_ctx |
493 || !downstream->write->ready | |
494 || downstream->write->delayed) | |
509 | 495 { |
150
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
496 break; |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
497 } |
146
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
498 |
479 | 499 /* 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
|
500 |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
501 prev = NULL; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
502 bsize = 0; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
503 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
504 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
|
505 |
479 | 506 if (cl->buf->recycled) { |
1102 | 507 if (prev == cl->buf->start) { |
508 continue; | |
509 } | |
510 | |
479 | 511 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
|
512 prev = cl->buf->start; |
479 | 513 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
514 } |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
515 |
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
516 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
479 | 517 "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
|
518 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
519 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
|
520 |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
521 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
|
522 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
|
523 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
|
524 } |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
525 |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
526 flush = 0; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
527 ll = NULL; |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
528 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
|
529 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
530 for ( ;; ) { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
531 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
|
532 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
|
533 |
479 | 534 if (cl->buf->recycled |
535 && bsize + cl->buf->last - cl->buf->pos > p->busy_size) | |
536 { | |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
537 flush = 1; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
538 break; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
539 } |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
540 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
541 p->out = p->out->next; |
479 | 542 |
543 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
|
544 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
545 } else if (!p->cachable && p->in) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
546 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
|
547 |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
548 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
|
549 "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
|
550 cl->buf->last_shadow, |
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
551 cl->buf->pos, |
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
859
diff
changeset
|
552 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
|
553 |
479 | 554 if (cl->buf->recycled |
840
3681cb9bde7d
fix FastCGI "zero size buf" alert
Igor Sysoev <igor@sysoev.ru>
parents:
613
diff
changeset
|
555 && cl->buf->last_shadow |
479 | 556 && bsize + cl->buf->last - cl->buf->pos > p->busy_size) |
557 { | |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
558 if (!prev_last_shadow) { |
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
559 p->in = p->in->next; |
1040
d536a2332385
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1039
diff
changeset
|
560 |
d536a2332385
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1039
diff
changeset
|
561 cl->next = NULL; |
d536a2332385
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1039
diff
changeset
|
562 |
d536a2332385
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1039
diff
changeset
|
563 if (out) { |
d536a2332385
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1039
diff
changeset
|
564 *ll = cl; |
d536a2332385
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1039
diff
changeset
|
565 } else { |
d536a2332385
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1039
diff
changeset
|
566 out = cl; |
d536a2332385
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1039
diff
changeset
|
567 } |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
568 } |
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
569 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
570 flush = 1; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
571 break; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
572 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
573 |
1039
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
574 prev_last_shadow = cl->buf->last_shadow; |
73f18b6ad6ba
fix FastCGI "zero size buf" alert,
Igor Sysoev <igor@sysoev.ru>
parents:
1030
diff
changeset
|
575 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
576 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
|
577 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
578 } else { |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
579 break; |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
580 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
581 |
479 | 582 if (cl->buf->recycled) { |
583 bsize += cl->buf->last - cl->buf->pos; | |
584 } | |
585 | |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
586 cl->next = NULL; |
501 | 587 |
588 if (out) { | |
589 *ll = cl; | |
590 } else { | |
591 out = cl; | |
592 } | |
593 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
|
594 } |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
595 |
1099
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
596 flush: |
04a8b485447d
fix segfault when a large FastCGI response was written to a temporary file
Igor Sysoev <igor@sysoev.ru>
parents:
1045
diff
changeset
|
597 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
598 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 599 "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
|
600 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
601 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
|
602 break; |
146
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
603 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
604 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
605 if (p->output_filter(p->output_ctx, out) == NGX_ERROR) { |
151
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
606 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
|
607 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
|
608 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
609 |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
610 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
|
611 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
612 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
|
613 |
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
|
614 if (cl->buf->temp_file) { |
175
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
615 if (p->cachable || !p->cyclic_temp_file) { |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
616 continue; |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
617 } |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
618 |
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
|
619 /* 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
|
620 |
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
|
621 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
|
622 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
|
623 } |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
624 } |
e92c2c647c57
nginx-0.0.1-2003-11-05-20:03:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
172
diff
changeset
|
625 |
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
|
626 /* 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
|
627 |
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
|
628 /* 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
|
629 |
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
|
630 if (cl->buf->last_shadow) { |
483 | 631 if (ngx_event_pipe_add_free_buf(p, cl->buf->shadow) != NGX_OK) { |
632 return NGX_ABORT; | |
633 } | |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
634 |
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
|
635 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
|
636 } |
154
eac26585476e
nginx-0.0.1-2003-10-22-11:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
637 |
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
|
638 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
|
639 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
640 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
641 |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
642 return NGX_OK; |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
643 } |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
644 |
5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
145
diff
changeset
|
645 |
577 | 646 static ngx_int_t |
647 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
|
648 { |
359
a3e622ab7ee7
nginx-0.0.7-2004-06-18-10:09:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
649 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
|
650 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
|
651 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
|
652 |
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
|
653 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
|
654 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
|
655 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
|
656 out = &fl; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
657 |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
658 } else { |
187
5a9bbe99008b
nginx-0.0.1-2003-11-17-19:15:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
659 out = p->in; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
660 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
661 |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
662 if (!p->cachable) { |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
663 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
664 size = 0; |
187
5a9bbe99008b
nginx-0.0.1-2003-11-17-19:15:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
665 cl = out; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
666 ll = NULL; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
667 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
668 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 669 "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
|
670 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
671 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
|
672 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
|
673 |
304
bcbe876f4262
nginx-0.0.3-2004-04-02-09:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
674 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, p->log, 0, |
461 | 675 "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
|
676 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
|
677 |
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
|
678 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
|
679 || (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
|
680 { |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
681 break; |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
682 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
683 |
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
|
684 size += bsize; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
685 ll = &cl->next; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
686 cl = cl->next; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
687 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
688 } while (cl); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
689 |
461 | 690 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
|
691 |
521 | 692 if (ll == NULL) { |
693 return NGX_BUSY; | |
694 } | |
695 | |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
696 if (cl) { |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
697 p->in = cl; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
698 *ll = NULL; |
151
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
699 |
2d9e4a8b6d11
nginx-0.0.1-2003-10-20-21:14:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
150
diff
changeset
|
700 } else { |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
701 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
|
702 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
|
703 } |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
704 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
705 } else { |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
706 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
|
707 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
|
708 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
709 |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
710 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
|
711 return NGX_ABORT; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
712 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
713 |
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
|
714 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
|
715 *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
|
716 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
|
717 { |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
718 /* void */ |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
719 } |
ad5f382c9e7d
nginx-0.0.1-2003-10-19-23:57:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
149
diff
changeset
|
720 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
304
diff
changeset
|
721 if (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
|
722 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
|
723 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
|
724 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
|
725 } |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
168
diff
changeset
|
726 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
727 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
|
728 next = cl->next; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
729 cl->next = NULL; |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
730 |
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
|
731 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
|
732 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
|
733 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
|
734 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
|
735 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
|
736 |
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
|
737 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
|
738 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
|
739 |
501 | 740 if (p->out) { |
741 *p->last_out = cl; | |
742 } else { | |
743 p->out = cl; | |
744 } | |
745 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
|
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 (b->last_shadow) { |
483 | 748 |
501 | 749 tl = ngx_alloc_chain_link(p->pool); |
750 if (tl == NULL) { | |
483 | 751 return NGX_ABORT; |
752 } | |
753 | |
754 tl->buf = b->shadow; | |
755 tl->next = NULL; | |
756 | |
757 *last_free = tl; | |
758 last_free = &tl->next; | |
759 | |
452 | 760 b->shadow->pos = b->shadow->start; |
761 b->shadow->last = b->shadow->start; | |
762 | |
483 | 763 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
|
764 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
765 } |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
766 |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
767 return NGX_OK; |
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
768 } |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
769 |
78
9f81437e0ad3
nginx-0.0.1-2003-04-21-18:55:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
770 |
76
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
771 /* 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
|
772 |
577 | 773 ngx_int_t |
774 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
|
775 { |
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
|
776 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
|
777 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
|
778 |
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
|
779 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
|
780 return NGX_OK; |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
781 } |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
782 |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
783 if (p->free) { |
507 | 784 cl = p->free; |
785 b = cl->buf; | |
786 p->free = cl->next; | |
787 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
|
788 |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
789 } else { |
501 | 790 b = ngx_alloc_buf(p->pool); |
791 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
|
792 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
|
793 } |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
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 |
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
|
796 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
|
797 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
|
798 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
|
799 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
|
800 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
|
801 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
|
802 |
501 | 803 cl = ngx_alloc_chain_link(p->pool); |
804 if (cl == NULL) { | |
483 | 805 return NGX_ERROR; |
806 } | |
807 | |
808 cl->buf = b; | |
809 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
|
810 |
479 | 811 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
|
812 |
501 | 813 if (p->in) { |
814 *p->last_in = cl; | |
815 } else { | |
816 p->in = cl; | |
817 } | |
818 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
|
819 |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
820 return NGX_OK; |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
821 } |
6127d7075471
nginx-0.0.1-2003-04-15-19:06:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
822 |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
823 |
577 | 824 static ngx_inline void |
825 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
|
826 { |
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
|
827 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
|
828 |
452 | 829 b = buf->shadow; |
830 | |
831 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
|
832 return; |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
833 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
834 |
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
|
835 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
|
836 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
|
837 |
452 | 838 b->temporary = 0; |
839 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
|
840 |
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
|
841 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
|
842 b = next; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
843 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
844 |
452 | 845 b->temporary = 0; |
846 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
|
847 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
|
848 |
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
304
diff
changeset
|
849 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
|
850 |
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
304
diff
changeset
|
851 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
|
852 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
853 |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
854 |
577 | 855 static ngx_inline void |
856 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
|
857 { |
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
|
858 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
|
859 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
|
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 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
|
862 return; |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
863 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
864 |
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
|
865 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
|
866 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
867 ll = free; |
147
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
868 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
869 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
|
870 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
|
871 *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
|
872 break; |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
873 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
874 |
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
|
875 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
|
876 break; |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
877 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
878 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
879 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
|
880 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
881 } |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
882 |
be71fca7f9d7
nginx-0.0.1-2003-10-14-19:06:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
146
diff
changeset
|
883 |
577 | 884 ngx_int_t |
885 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
|
886 { |
483 | 887 ngx_chain_t *cl; |
888 | |
501 | 889 cl = ngx_alloc_chain_link(p->pool); |
890 if (cl == NULL) { | |
483 | 891 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
|
892 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
147
diff
changeset
|
893 |
483 | 894 b->pos = b->start; |
895 b->last = b->start; | |
896 b->shadow = NULL; | |
897 | |
898 cl->buf = b; | |
899 | |
900 if (p->free_raw_bufs == NULL) { | |
901 p->free_raw_bufs = cl; | |
902 cl->next = NULL; | |
903 | |
904 return NGX_OK; | |
905 } | |
906 | |
907 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
|
908 |
483 | 909 /* add the free buf to the list start */ |
910 | |
911 cl->next = p->free_raw_bufs; | |
912 p->free_raw_bufs = cl; | |
913 | |
914 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
|
915 } |
483 | 916 |
917 /* the first free buf is partialy filled, thus add the free buf after it */ | |
918 | |
919 cl->next = p->free_raw_bufs->next; | |
920 p->free_raw_bufs->next = cl; | |
921 | |
922 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
|
923 } |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
924 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
925 |
577 | 926 static ngx_int_t |
927 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
|
928 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
929 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
|
930 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
931 for ( ;; ) { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
932 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
|
933 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
|
934 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
|
935 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
936 } 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
|
937 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
|
938 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
|
939 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
940 } 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
|
941 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
|
942 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
|
943 |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
944 } else { |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
945 return NGX_OK; |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
946 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
947 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
948 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
|
949 if (cl->buf->last_shadow) { |
483 | 950 if (ngx_event_pipe_add_free_buf(p, cl->buf->shadow) != NGX_OK) { |
479 | 951 return NGX_ABORT; |
952 } | |
953 | |
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
|
954 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
|
955 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
956 |
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
|
957 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
|
958 tl = cl->next; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
959 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
|
960 p->free = cl; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
961 cl = tl; |
152
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
962 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
963 } |
fb48bf4fea1c
nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
151
diff
changeset
|
964 } |