comparison src/http/ngx_http_write_filter.c @ 332:159dd60d257a

nginx-0.0.3-2004-05-10-23:53:35 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 10 May 2004 19:53:35 +0000
parents 7a8ebba985a9
children be40e9893a19
comparison
equal deleted inserted replaced
331:f168a88e93f7 332:159dd60d257a
68 68
69 int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) 69 int 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;
73 ngx_chain_t *cl, **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,
78 ngx_http_write_filter_module); 78 ngx_http_write_filter_module);
103 } 103 }
104 } 104 }
105 105
106 /* add the new chain to the existent one */ 106 /* add the new chain to the existent one */
107 107
108 for (/* void */; in; in = in->next) { 108 for (ln = in; ln; ln = ln->next) {
109 ngx_alloc_link_and_set_hunk(cl, in->hunk, r->pool, NGX_ERROR); 109 ngx_alloc_link_and_set_hunk(cl, ln->hunk, r->pool, NGX_ERROR);
110 *ll = cl; 110 *ll = cl;
111 ll = &cl->next; 111 ll = &cl->next;
112 112
113 size += ngx_hunk_size(cl->hunk); 113 size += ngx_hunk_size(cl->hunk);
114 114
127 127
128 conf = ngx_http_get_module_loc_conf(r->main ? r->main : r, 128 conf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
129 ngx_http_write_filter_module); 129 ngx_http_write_filter_module);
130 130
131 /* 131 /*
132 * avoid the output if there is no last hunk, no flush point and 132 * avoid the output if there is no last hunk, no flush point,
133 * the size of the hunks is smaller than "postpone_output" directive 133 * there are the incoming hunks and the size of all hunks
134 * is smaller than "postpone_output" directive
134 */ 135 */
135 136
136 if (!last && flush == 0 && size < (off_t) conf->postpone_output) { 137 if (!last && flush == 0 && in && size < (off_t) conf->postpone_output) {
137 return NGX_OK; 138 return NGX_OK;
138 } 139 }
139 140
140 if (r->connection->write->delayed) { 141 if (r->connection->write->delayed) {
141 return NGX_AGAIN; 142 return NGX_AGAIN;
142 } 143 }
143 144
144 if (size == 0) { 145 if (size == 0) {
146 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
147 "the http output chain is empty");
145 return NGX_OK; 148 return NGX_OK;
146 } 149 }
147 150
148 chain = ngx_write_chain(r->connection, ctx->out); 151 chain = ngx_write_chain(r->connection, ctx->out);
149 152