comparison src/http/ngx_http_write_filter.c @ 48:6cfc63e68377 NGINX_0_1_24

nginx 0.1.24 *) Feature: the ngx_http_ssi_filter_module supports the QUERY_STRING and DOCUMENT_URI variables. *) Bugfix: the ngx_http_autoindex_module may some times return the 404 response for existent directory, if this directory was used in "alias" directive. *) Bugfix: the ngx_http_ssi_filter_module ran incorrectly for large responses. *) Bugfix: the lack of the "Referer" header line was always accounted as valid referrer.
author Igor Sysoev <http://sysoev.ru>
date Fri, 04 Mar 2005 00:00:00 +0300
parents 2879cd3a40cb
children
comparison
equal deleted inserted replaced
47:4ae32548452c 48:6cfc63e68377
42 }; 42 };
43 43
44 44
45 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) 45 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
46 { 46 {
47 int last; 47 off_t size, sent;
48 off_t size, flush, sent; 48 ngx_uint_t last, flush;
49 ngx_chain_t *cl, *ln, **ll, *chain; 49 ngx_chain_t *cl, *ln, **ll, *chain;
50 ngx_connection_t *c; 50 ngx_connection_t *c;
51 ngx_http_core_loc_conf_t *clcf; 51 ngx_http_core_loc_conf_t *clcf;
52 ngx_http_write_filter_ctx_t *ctx; 52 ngx_http_write_filter_ctx_t *ctx;
53 53
99 #endif 99 #endif
100 100
101 size += ngx_buf_size(cl->buf); 101 size += ngx_buf_size(cl->buf);
102 102
103 if (cl->buf->flush || cl->buf->recycled) { 103 if (cl->buf->flush || cl->buf->recycled) {
104 flush = size; 104 flush = 1;
105 } 105 }
106 106
107 if (cl->buf->last_buf) { 107 if (cl->buf->last_buf) {
108 last = 1; 108 last = 1;
109 } 109 }
150 #endif 150 #endif
151 151
152 size += ngx_buf_size(cl->buf); 152 size += ngx_buf_size(cl->buf);
153 153
154 if (cl->buf->flush || cl->buf->recycled) { 154 if (cl->buf->flush || cl->buf->recycled) {
155 flush = size; 155 flush = 1;
156 } 156 }
157 157
158 if (cl->buf->last_buf) { 158 if (cl->buf->last_buf) {
159 last = 1; 159 last = 1;
160 } 160 }
163 *ll = NULL; 163 *ll = NULL;
164 164
165 c = r->connection; 165 c = r->connection;
166 166
167 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, 167 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
168 "http write filter: l:%d f:%O s:%O", last, flush, size); 168 "http write filter: l:%d f:%d s:%O", last, flush, size);
169 169
170 clcf = ngx_http_get_module_loc_conf(r->main ? r->main : r, 170 clcf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
171 ngx_http_core_module); 171 ngx_http_core_module);
172 172
173 /* 173 /*
174 * avoid the output if there is no last buf, no flush point, 174 * avoid the output if there is no last buf, no flush point,
175 * there are the incoming bufs and the size of all bufs 175 * there are the incoming bufs and the size of all bufs
176 * is smaller than "postpone_output" directive 176 * is smaller than "postpone_output" directive
177 */ 177 */
178 178
179 if (!last && flush == 0 && in && size < (off_t) clcf->postpone_output) { 179 if (!last && !flush && in && size < (off_t) clcf->postpone_output) {
180 return NGX_OK; 180 return NGX_OK;
181 } 181 }
182 182
183 if (c->write->delayed) { 183 if (c->write->delayed) {
184 return NGX_AGAIN; 184 return NGX_AGAIN;
185 } 185 }
186 186
187 if (size == 0 && !c->buffered) { 187 if (size == 0 && !c->buffered) {
188 if (last) { 188 if (last) {
189 return NGX_OK;
190 }
191
192 if (flush) {
193 while ((ctx->out = ctx->out->next)) { /* void */ }
189 return NGX_OK; 194 return NGX_OK;
190 } 195 }
191 196
192 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 197 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
193 "the http output chain is empty"); 198 "the http output chain is empty");