comparison src/http/ngx_http_write_filter.c @ 361:446782c909b3

nginx-0.0.7-2004-06-20-23:54:15 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 20 Jun 2004 19:54:15 +0000
parents 2e3cbc1bbe3c
children 7650aea1816f
comparison
equal deleted inserted replaced
360:239e37d44a34 361:446782c909b3
67 67
68 68
69 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) 69 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
70 { 70 {
71 int last; 71 int last;
72 off_t size, flush; 72 off_t size, flush, sent;
73 ngx_chain_t *cl, *ln, **ll, *chain; 73 ngx_chain_t *cl, *ln, **ll, *chain;
74 ngx_http_write_filter_ctx_t *ctx; 74 ngx_http_write_filter_ctx_t *ctx;
75 ngx_http_write_filter_conf_t *conf; 75 ngx_http_write_filter_conf_t *conf;
76 76
77 ctx = ngx_http_get_module_ctx(r->main ? r->main : r, 77 ctx = ngx_http_get_module_ctx(r->main ? r->main : r,
136 136
137 if (!last && flush == 0 && in && size < (off_t) conf->postpone_output) { 137 if (!last && flush == 0 && in && size < (off_t) conf->postpone_output) {
138 return NGX_OK; 138 return NGX_OK;
139 } 139 }
140 140
141 if (r->connection->write->delayed) { 141 if (r->delayed) {
142 return NGX_AGAIN; 142 return NGX_AGAIN;
143 } 143 }
144 144
145 if (size == 0) { 145 if (size == 0) {
146 if (!last) { 146 if (!last) {
148 "the http output chain is empty"); 148 "the http output chain is empty");
149 } 149 }
150 return NGX_OK; 150 return NGX_OK;
151 } 151 }
152 152
153 sent = r->connection->sent;
154
153 chain = ngx_write_chain(r->connection, ctx->out); 155 chain = ngx_write_chain(r->connection, ctx->out);
154 156
155 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 157 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
156 "http write filter %X", chain); 158 "http write filter %X", chain);
159
160 #if 1
161 sent = r->connection->sent - sent;
162 r->delayed = 1;
163 ngx_add_timer(r->connection->write, sent * 1000 / (4 * 1024));
164 #endif
157 165
158 if (chain == NGX_CHAIN_ERROR) { 166 if (chain == NGX_CHAIN_ERROR) {
159 return NGX_ERROR; 167 return NGX_ERROR;
160 } 168 }
161 169