comparison src/http/ngx_http_write_filter_module.c @ 5926:08bfc7188a41

Write filter: fixed handling of sync bufs (ticket #132).
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 28 Nov 2014 16:58:39 +0300
parents 8486205d10db
children b8926ba4d087
comparison
equal deleted inserted replaced
5925:c76d851c5e7a 5926:08bfc7188a41
46 46
47 ngx_int_t 47 ngx_int_t
48 ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) 48 ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
49 { 49 {
50 off_t size, sent, nsent, limit; 50 off_t size, sent, nsent, limit;
51 ngx_uint_t last, flush; 51 ngx_uint_t last, flush, sync;
52 ngx_msec_t delay; 52 ngx_msec_t delay;
53 ngx_chain_t *cl, *ln, **ll, *chain; 53 ngx_chain_t *cl, *ln, **ll, *chain;
54 ngx_connection_t *c; 54 ngx_connection_t *c;
55 ngx_http_core_loc_conf_t *clcf; 55 ngx_http_core_loc_conf_t *clcf;
56 56
60 return NGX_ERROR; 60 return NGX_ERROR;
61 } 61 }
62 62
63 size = 0; 63 size = 0;
64 flush = 0; 64 flush = 0;
65 sync = 0;
65 last = 0; 66 last = 0;
66 ll = &r->out; 67 ll = &r->out;
67 68
68 /* find the size, the flush point and the last link of the saved chain */ 69 /* find the size, the flush point and the last link of the saved chain */
69 70
103 104
104 if (cl->buf->flush || cl->buf->recycled) { 105 if (cl->buf->flush || cl->buf->recycled) {
105 flush = 1; 106 flush = 1;
106 } 107 }
107 108
109 if (cl->buf->sync) {
110 sync = 1;
111 }
112
108 if (cl->buf->last_buf) { 113 if (cl->buf->last_buf) {
109 last = 1; 114 last = 1;
110 } 115 }
111 } 116 }
112 117
155 160
156 if (cl->buf->flush || cl->buf->recycled) { 161 if (cl->buf->flush || cl->buf->recycled) {
157 flush = 1; 162 flush = 1;
158 } 163 }
159 164
165 if (cl->buf->sync) {
166 sync = 1;
167 }
168
160 if (cl->buf->last_buf) { 169 if (cl->buf->last_buf) {
161 last = 1; 170 last = 1;
162 } 171 }
163 } 172 }
164 173
186 195
187 if (size == 0 196 if (size == 0
188 && !(c->buffered & NGX_LOWLEVEL_BUFFERED) 197 && !(c->buffered & NGX_LOWLEVEL_BUFFERED)
189 && !(last && c->need_last_buf)) 198 && !(last && c->need_last_buf))
190 { 199 {
191 if (last || flush) { 200 if (last || flush || sync) {
192 for (cl = r->out; cl; /* void */) { 201 for (cl = r->out; cl; /* void */) {
193 ln = cl; 202 ln = cl;
194 cl = cl->next; 203 cl = cl->next;
195 ngx_free_chain(r->pool, ln); 204 ngx_free_chain(r->pool, ln);
196 } 205 }