comparison src/event/ngx_event_pipe.c @ 4135:d8e24515176e

Fix of cpu hog in event pipe. If client closed connection in ngx_event_pipe_write_to_downstream(), buffers in the "out" chain were lost. This caused cpu hog if all available buffers were in the "out" chain. Fix is to call ngx_chain_update_chains() before checking return code of output filter to avoid loosing buffers in the "out" chain. Note that this situation (all available buffers in the "out" chain) isn't normal, it should be prevented by busy buffers limit. Though right now it may happen with complex protocols like fastcgi. This should be addressed separately.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 20 Sep 2011 09:55:27 +0000
parents b66712cde67d
children 6b9b7e7ac4a9
comparison
equal deleted inserted replaced
4134:a3203c4521c6 4135:d8e24515176e
654 } 654 }
655 } 655 }
656 656
657 rc = p->output_filter(p->output_ctx, out); 657 rc = p->output_filter(p->output_ctx, out);
658 658
659 ngx_chain_update_chains(p->pool, &p->free, &p->busy, &out, p->tag);
660
659 if (rc == NGX_ERROR) { 661 if (rc == NGX_ERROR) {
660 p->downstream_error = 1; 662 p->downstream_error = 1;
661 return ngx_event_pipe_drain_chains(p); 663 return ngx_event_pipe_drain_chains(p);
662 } 664 }
663
664 ngx_chain_update_chains(p->pool, &p->free, &p->busy, &out, p->tag);
665 665
666 for (cl = p->free; cl; cl = cl->next) { 666 for (cl = p->free; cl; cl = cl->next) {
667 667
668 if (cl->buf->temp_file) { 668 if (cl->buf->temp_file) {
669 if (p->cacheable || !p->cyclic_temp_file) { 669 if (p->cacheable || !p->cyclic_temp_file) {