Mercurial > hg > nginx
comparison src/http/ngx_http_spdy_filter_module.c @ 5511:dfb52d25cefb
SPDY: refactored ngx_http_spdy_body_filter().
A local pointer to fake connection is introduced
to slightly reduce further patches.
No functional changes.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Tue, 14 Jan 2014 16:24:45 +0400 |
parents | 3ff29c30effb |
children | 9fffc0c46e5c |
comparison
equal
deleted
inserted
replaced
5510:3ff29c30effb | 5511:dfb52d25cefb |
---|---|
615 ngx_http_spdy_body_filter(ngx_http_request_t *r, ngx_chain_t *in) | 615 ngx_http_spdy_body_filter(ngx_http_request_t *r, ngx_chain_t *in) |
616 { | 616 { |
617 off_t size; | 617 off_t size; |
618 ngx_buf_t *b; | 618 ngx_buf_t *b; |
619 ngx_chain_t *cl, *out, **ln; | 619 ngx_chain_t *cl, *out, **ln; |
620 ngx_connection_t *fc; | |
620 ngx_http_spdy_stream_t *stream; | 621 ngx_http_spdy_stream_t *stream; |
621 ngx_http_spdy_out_frame_t *frame; | 622 ngx_http_spdy_out_frame_t *frame; |
622 | 623 |
623 stream = r->spdy_stream; | 624 stream = r->spdy_stream; |
624 | 625 |
625 if (stream == NULL) { | 626 if (stream == NULL) { |
626 return ngx_http_next_body_filter(r, in); | 627 return ngx_http_next_body_filter(r, in); |
627 } | 628 } |
628 | 629 |
629 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 630 fc = r->connection; |
631 | |
632 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, fc->log, 0, | |
630 "spdy body filter \"%V?%V\"", &r->uri, &r->args); | 633 "spdy body filter \"%V?%V\"", &r->uri, &r->args); |
631 | 634 |
632 if (in == NULL || r->header_only) { | 635 if (in == NULL || r->header_only) { |
633 | 636 |
634 if (stream->queued) { | 637 if (stream->queued) { |
635 return NGX_AGAIN; | 638 return NGX_AGAIN; |
636 } | 639 } |
637 | 640 |
638 r->connection->buffered &= ~NGX_SPDY_WRITE_BUFFERED; | 641 fc->buffered &= ~NGX_SPDY_WRITE_BUFFERED; |
639 | 642 |
640 return NGX_OK; | 643 return NGX_OK; |
641 } | 644 } |
642 | 645 |
643 size = 0; | 646 size = 0; |
645 | 648 |
646 do { | 649 do { |
647 b = in->buf; | 650 b = in->buf; |
648 #if 1 | 651 #if 1 |
649 if (ngx_buf_size(b) == 0 && !ngx_buf_special(b)) { | 652 if (ngx_buf_size(b) == 0 && !ngx_buf_special(b)) { |
650 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | 653 ngx_log_error(NGX_LOG_ALERT, fc->log, 0, |
651 "zero size buf in spdy body filter " | 654 "zero size buf in spdy body filter " |
652 "t:%d r:%d f:%d %p %p-%p %p %O-%O", | 655 "t:%d r:%d f:%d %p %p-%p %p %O-%O", |
653 b->temporary, | 656 b->temporary, |
654 b->recycled, | 657 b->recycled, |
655 b->in_file, | 658 b->in_file, |
678 in = in->next; | 681 in = in->next; |
679 | 682 |
680 } while (in); | 683 } while (in); |
681 | 684 |
682 if (size > NGX_SPDY_MAX_FRAME_SIZE) { | 685 if (size > NGX_SPDY_MAX_FRAME_SIZE) { |
683 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | 686 ngx_log_error(NGX_LOG_ALERT, fc->log, 0, |
684 "FIXME: chain too big in spdy filter: %O", size); | 687 "FIXME: chain too big in spdy filter: %O", size); |
685 return NGX_ERROR; | 688 return NGX_ERROR; |
686 } | 689 } |
687 | 690 |
688 frame = ngx_http_spdy_filter_get_data_frame(stream, (size_t) size, | 691 frame = ngx_http_spdy_filter_get_data_frame(stream, (size_t) size, |
693 | 696 |
694 ngx_http_spdy_queue_frame(stream->connection, frame); | 697 ngx_http_spdy_queue_frame(stream->connection, frame); |
695 | 698 |
696 stream->queued++; | 699 stream->queued++; |
697 | 700 |
698 return ngx_http_spdy_filter_send(r->connection, stream); | 701 return ngx_http_spdy_filter_send(fc, stream); |
699 } | 702 } |
700 | 703 |
701 | 704 |
702 static ngx_http_spdy_out_frame_t * | 705 static ngx_http_spdy_out_frame_t * |
703 ngx_http_spdy_filter_get_data_frame(ngx_http_spdy_stream_t *stream, | 706 ngx_http_spdy_filter_get_data_frame(ngx_http_spdy_stream_t *stream, |