Mercurial > hg > nginx
comparison src/http/ngx_http_spdy_filter_module.c @ 5495:97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
There is no need to pass FLAG_FIN as a separate argument since it can always be
detected from the last_buf flag of the last frame buffer.
No functional changes.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Thu, 26 Dec 2013 17:03:16 +0400 |
parents | 27f9d5f68c1c |
children | 9053fdcea4b7 |
comparison
equal
deleted
inserted
replaced
5494:27f9d5f68c1c | 5495:97f6cd787766 |
---|---|
31 | 31 |
32 static ngx_inline ngx_int_t ngx_http_spdy_filter_send( | 32 static ngx_inline ngx_int_t ngx_http_spdy_filter_send( |
33 ngx_connection_t *fc, ngx_http_spdy_stream_t *stream); | 33 ngx_connection_t *fc, ngx_http_spdy_stream_t *stream); |
34 | 34 |
35 static ngx_http_spdy_out_frame_t *ngx_http_spdy_filter_get_data_frame( | 35 static ngx_http_spdy_out_frame_t *ngx_http_spdy_filter_get_data_frame( |
36 ngx_http_spdy_stream_t *stream, size_t len, ngx_uint_t flags, | 36 ngx_http_spdy_stream_t *stream, size_t len, ngx_chain_t *first, |
37 ngx_chain_t *first, ngx_chain_t *last); | 37 ngx_chain_t *last); |
38 | 38 |
39 static ngx_int_t ngx_http_spdy_syn_frame_handler( | 39 static ngx_int_t ngx_http_spdy_syn_frame_handler( |
40 ngx_http_spdy_connection_t *sc, ngx_http_spdy_out_frame_t *frame); | 40 ngx_http_spdy_connection_t *sc, ngx_http_spdy_out_frame_t *frame); |
41 static ngx_int_t ngx_http_spdy_data_frame_handler( | 41 static ngx_int_t ngx_http_spdy_data_frame_handler( |
42 ngx_http_spdy_connection_t *sc, ngx_http_spdy_out_frame_t *frame); | 42 ngx_http_spdy_connection_t *sc, ngx_http_spdy_out_frame_t *frame); |
686 "FIXME: chain too big in spdy filter: %O", size); | 686 "FIXME: chain too big in spdy filter: %O", size); |
687 return NGX_ERROR; | 687 return NGX_ERROR; |
688 } | 688 } |
689 | 689 |
690 frame = ngx_http_spdy_filter_get_data_frame(stream, (size_t) size, | 690 frame = ngx_http_spdy_filter_get_data_frame(stream, (size_t) size, |
691 b->last_buf, out, cl); | 691 out, cl); |
692 if (frame == NULL) { | 692 if (frame == NULL) { |
693 return NGX_ERROR; | 693 return NGX_ERROR; |
694 } | 694 } |
695 | 695 |
696 ngx_http_spdy_queue_frame(stream->connection, frame); | 696 ngx_http_spdy_queue_frame(stream->connection, frame); |
703 } | 703 } |
704 | 704 |
705 | 705 |
706 static ngx_http_spdy_out_frame_t * | 706 static ngx_http_spdy_out_frame_t * |
707 ngx_http_spdy_filter_get_data_frame(ngx_http_spdy_stream_t *stream, | 707 ngx_http_spdy_filter_get_data_frame(ngx_http_spdy_stream_t *stream, |
708 size_t len, ngx_uint_t fin, ngx_chain_t *first, ngx_chain_t *last) | 708 size_t len, ngx_chain_t *first, ngx_chain_t *last) |
709 { | 709 { |
710 u_char *p; | 710 u_char *p; |
711 ngx_buf_t *buf; | 711 ngx_buf_t *buf; |
712 ngx_uint_t flags; | 712 ngx_uint_t flags; |
713 ngx_chain_t *cl; | 713 ngx_chain_t *cl; |
725 if (frame == NULL) { | 725 if (frame == NULL) { |
726 return NULL; | 726 return NULL; |
727 } | 727 } |
728 } | 728 } |
729 | 729 |
730 flags = last->buf->last_buf ? NGX_SPDY_FLAG_FIN : 0; | |
731 | |
730 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, stream->request->connection->log, 0, | 732 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, stream->request->connection->log, 0, |
731 "spdy:%ui create DATA frame %p: len:%uz fin:%ui", | 733 "spdy:%ui create DATA frame %p: len:%uz flags:%ui", |
732 stream->id, frame, len, fin); | 734 stream->id, frame, len, flags); |
733 | 735 |
734 if (len || fin) { | 736 if (len || flags) { |
735 | |
736 flags = fin ? NGX_SPDY_FLAG_FIN : 0; | |
737 | 737 |
738 cl = ngx_chain_get_free_buf(stream->request->pool, | 738 cl = ngx_chain_get_free_buf(stream->request->pool, |
739 &stream->free_data_headers); | 739 &stream->free_data_headers); |
740 if (cl == NULL) { | 740 if (cl == NULL) { |
741 return NULL; | 741 return NULL; |
780 frame->free = NULL; | 780 frame->free = NULL; |
781 frame->stream = stream; | 781 frame->stream = stream; |
782 frame->size = NGX_SPDY_FRAME_HEADER_SIZE + len; | 782 frame->size = NGX_SPDY_FRAME_HEADER_SIZE + len; |
783 frame->priority = stream->priority; | 783 frame->priority = stream->priority; |
784 frame->blocked = 0; | 784 frame->blocked = 0; |
785 frame->fin = fin; | 785 frame->fin = last->buf->last_buf; |
786 | 786 |
787 return frame; | 787 return frame; |
788 } | 788 } |
789 | 789 |
790 | 790 |