Mercurial > hg > nginx
comparison src/http/ngx_http_write_filter.c @ 155:46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 22 Oct 2003 16:38:26 +0000 |
parents | eac26585476e |
children | 389d7ee9fa60 |
comparison
equal
deleted
inserted
replaced
154:eac26585476e | 155:46eb23d9471d |
---|---|
58 | 58 |
59 int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) | 59 int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) |
60 { | 60 { |
61 int last; | 61 int last; |
62 off_t size, flush; | 62 off_t size, flush; |
63 ngx_chain_t *ce, **le, *chain; | 63 ngx_chain_t *cl, **ll, *chain; |
64 ngx_http_write_filter_ctx_t *ctx; | 64 ngx_http_write_filter_ctx_t *ctx; |
65 ngx_http_write_filter_conf_t *conf; | 65 ngx_http_write_filter_conf_t *conf; |
66 | 66 |
67 ctx = ngx_http_get_module_ctx(r->main ? r->main : r, | 67 ctx = ngx_http_get_module_ctx(r->main ? r->main : r, |
68 ngx_http_write_filter_module); | 68 ngx_http_write_filter_module); |
72 sizeof(ngx_http_write_filter_ctx_t), NGX_ERROR); | 72 sizeof(ngx_http_write_filter_ctx_t), NGX_ERROR); |
73 } | 73 } |
74 | 74 |
75 size = flush = 0; | 75 size = flush = 0; |
76 last = 0; | 76 last = 0; |
77 le = &ctx->out; | 77 ll = &ctx->out; |
78 | 78 |
79 /* find the size, the flush point and the last entry of the saved chain */ | 79 /* find the size, the flush point and the last link of the saved chain */ |
80 | 80 |
81 for (ce = ctx->out; ce; ce = ce->next) { | 81 for (cl = ctx->out; cl; cl = cl->next) { |
82 le = &ce->next; | 82 ll = &cl->next; |
83 | 83 |
84 size += ngx_hunk_size(ce->hunk); | 84 size += ngx_hunk_size(cl->hunk); |
85 | 85 |
86 if (ce->hunk->type & (NGX_HUNK_FLUSH|NGX_HUNK_RECYCLED)) { | 86 if (cl->hunk->type & (NGX_HUNK_FLUSH|NGX_HUNK_RECYCLED)) { |
87 flush = size; | 87 flush = size; |
88 } | 88 } |
89 | 89 |
90 if (ce->hunk->type & NGX_HUNK_LAST) { | 90 if (cl->hunk->type & NGX_HUNK_LAST) { |
91 last = 1; | 91 last = 1; |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 /* add the new chain to the existent one */ | 95 /* add the new chain to the existent one */ |
96 | 96 |
97 for (/* void */; in; in = in->next) { | 97 for (/* void */; in; in = in->next) { |
98 ngx_test_null(ce, ngx_alloc_chain_entry(r->pool), NGX_ERROR); | 98 ngx_alloc_link_and_set_hunk(cl, in->hunk, r->pool, NGX_ERROR); |
99 *ll = cl; | |
100 ll = &cl->next; | |
99 | 101 |
100 ce->hunk = in->hunk; | 102 size += ngx_hunk_size(cl->hunk); |
101 ce->next = NULL; | |
102 *le = ce; | |
103 le = &ce->next; | |
104 | 103 |
105 size += ngx_hunk_size(ce->hunk); | 104 if (cl->hunk->type & (NGX_HUNK_FLUSH|NGX_HUNK_RECYCLED)) { |
106 | |
107 if (ce->hunk->type & (NGX_HUNK_FLUSH|NGX_HUNK_RECYCLED)) { | |
108 flush = size; | 105 flush = size; |
109 } | 106 } |
110 | 107 |
111 if (ce->hunk->type & NGX_HUNK_LAST) { | 108 if (cl->hunk->type & NGX_HUNK_LAST) { |
112 last = 1; | 109 last = 1; |
113 } | 110 } |
114 } | 111 } |
115 | 112 |
116 #if (NGX_DEBUG_WRITE_FILTER) | 113 #if (NGX_DEBUG_WRITE_FILTER) |
122 conf = ngx_http_get_module_loc_conf(r->main ? r->main : r, | 119 conf = ngx_http_get_module_loc_conf(r->main ? r->main : r, |
123 ngx_http_write_filter_module); | 120 ngx_http_write_filter_module); |
124 | 121 |
125 /* | 122 /* |
126 * avoid the output if there is no last hunk, no flush point and | 123 * avoid the output if there is no last hunk, no flush point and |
127 * size of the hunks is smaller then "buffer_output" | 124 * the size of the hunks is smaller than "buffer_output" directive |
128 */ | 125 */ |
129 | 126 |
130 if (!last && flush == 0 && size < conf->buffer_output) { | 127 if (!last && flush == 0 && size < conf->buffer_output) { |
131 return NGX_OK; | 128 return NGX_OK; |
132 } | 129 } |