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