Mercurial > hg > nginx
comparison src/http/ngx_http_write_filter.c @ 396:6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 18 Jul 2004 19:11:20 +0000 |
parents | f8f0f1834266 |
children | 4e21d1291a14 |
comparison
equal
deleted
inserted
replaced
395:f8f0f1834266 | 396:6f3b20c1ac50 |
---|---|
43 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) | 43 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) |
44 { | 44 { |
45 int last; | 45 int last; |
46 off_t size, flush, sent; | 46 off_t size, flush, sent; |
47 ngx_chain_t *cl, *ln, **ll, *chain; | 47 ngx_chain_t *cl, *ln, **ll, *chain; |
48 ngx_connection_t *c; | |
48 ngx_http_core_loc_conf_t *clcf; | 49 ngx_http_core_loc_conf_t *clcf; |
49 ngx_http_write_filter_ctx_t *ctx; | 50 ngx_http_write_filter_ctx_t *ctx; |
50 | 51 |
51 ctx = ngx_http_get_module_ctx(r->main ? r->main : r, | 52 ctx = ngx_http_get_module_ctx(r->main ? r->main : r, |
52 ngx_http_write_filter_module); | 53 ngx_http_write_filter_module); |
93 if (cl->buf->last_buf) { | 94 if (cl->buf->last_buf) { |
94 last = 1; | 95 last = 1; |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 99 c = r->connection; |
100 | |
101 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
99 "http write filter: l:%d f:" OFF_T_FMT " s:" OFF_T_FMT, | 102 "http write filter: l:%d f:" OFF_T_FMT " s:" OFF_T_FMT, |
100 last, flush, size); | 103 last, flush, size); |
101 | 104 |
102 clcf = ngx_http_get_module_loc_conf(r->main ? r->main : r, | 105 clcf = ngx_http_get_module_loc_conf(r->main ? r->main : r, |
103 ngx_http_core_module); | 106 ngx_http_core_module); |
110 | 113 |
111 if (!last && flush == 0 && in && size < (off_t) clcf->postpone_output) { | 114 if (!last && flush == 0 && in && size < (off_t) clcf->postpone_output) { |
112 return NGX_OK; | 115 return NGX_OK; |
113 } | 116 } |
114 | 117 |
115 if (r->connection->write->delayed) { | 118 if (c->write->delayed) { |
116 return NGX_AGAIN; | 119 return NGX_AGAIN; |
117 } | 120 } |
118 | 121 |
119 if (size == 0 && !ctx->flush) { | 122 if (size == 0 && !ctx->flush) { |
120 if (!last) { | 123 if (!last) { |
122 "the http output chain is empty"); | 125 "the http output chain is empty"); |
123 } | 126 } |
124 return NGX_OK; | 127 return NGX_OK; |
125 } | 128 } |
126 | 129 |
127 sent = r->connection->sent; | 130 sent = c->sent; |
128 | 131 |
129 chain = r->send_chain(r->connection, ctx->out, | 132 chain = c->send_chain(c, ctx->out, |
130 clcf->limit_rate ? clcf->limit_rate: OFF_T_MAX_VALUE); | 133 clcf->limit_rate ? clcf->limit_rate: OFF_T_MAX_VALUE); |
131 | 134 |
132 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 135 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
133 "http write filter %X", chain); | 136 "http write filter %X", chain); |
134 | 137 |
135 if (clcf->limit_rate) { | 138 if (clcf->limit_rate) { |
136 sent = r->connection->sent - sent; | 139 sent = c->sent - sent; |
137 r->connection->write->delayed = 1; | 140 c->write->delayed = 1; |
138 ngx_add_timer(r->connection->write, | 141 ngx_add_timer(r->connection->write, |
139 (ngx_msec_t) (sent * 1000 / clcf->limit_rate)); | 142 (ngx_msec_t) (sent * 1000 / clcf->limit_rate)); |
140 } | 143 } |
141 | 144 |
142 if (chain == NGX_CHAIN_ERROR) { | 145 if (chain == NGX_CHAIN_ERROR) { |