comparison src/http/ngx_http_spdy_filter_module.c @ 5510:3ff29c30effb

SPDY: elimination of r->blocked counter usage for queuing frames. It was used to prevent destroying of request object when there are unsent frames in queue for the stream. Since it was incremented for each frame and is only 8 bits long, so it was not very hard to overflow the counter. Now the stream->queued counter is checked instead.
author Valentin Bartenev <vbart@nginx.com>
date Tue, 14 Jan 2014 16:24:45 +0400
parents 9053fdcea4b7
children dfb52d25cefb
comparison
equal deleted inserted replaced
5509:877a7bd72070 5510:3ff29c30effb
595 "spdy:%ui create SYN_REPLY frame %p: size:%uz", 595 "spdy:%ui create SYN_REPLY frame %p: size:%uz",
596 stream->id, frame, frame->size); 596 stream->id, frame, frame->size);
597 597
598 ngx_http_spdy_queue_blocked_frame(sc, frame); 598 ngx_http_spdy_queue_blocked_frame(sc, frame);
599 599
600 r->blocked++;
601
602 cln = ngx_http_cleanup_add(r, 0); 600 cln = ngx_http_cleanup_add(r, 0);
603 if (cln == NULL) { 601 if (cln == NULL) {
604 return NGX_ERROR; 602 return NGX_ERROR;
605 } 603 }
606 604
695 693
696 ngx_http_spdy_queue_frame(stream->connection, frame); 694 ngx_http_spdy_queue_frame(stream->connection, frame);
697 695
698 stream->queued++; 696 stream->queued++;
699 697
700 r->main->blocked++;
701
702 return ngx_http_spdy_filter_send(r->connection, stream); 698 return ngx_http_spdy_filter_send(r->connection, stream);
703 } 699 }
704 700
705 701
706 static ngx_http_spdy_out_frame_t * 702 static ngx_http_spdy_out_frame_t *
921 ngx_http_request_t *r; 917 ngx_http_request_t *r;
922 918
923 r = stream->request; 919 r = stream->request;
924 920
925 r->connection->sent += frame->size; 921 r->connection->sent += frame->size;
926 r->blocked--;
927 922
928 if (frame->fin) { 923 if (frame->fin) {
929 stream->out_closed = 1; 924 stream->out_closed = 1;
930 } 925 }
931 926
960 static void 955 static void
961 ngx_http_spdy_filter_cleanup(void *data) 956 ngx_http_spdy_filter_cleanup(void *data)
962 { 957 {
963 ngx_http_spdy_stream_t *stream = data; 958 ngx_http_spdy_stream_t *stream = data;
964 959
965 ngx_http_request_t *r;
966 ngx_http_spdy_out_frame_t *frame, **fn; 960 ngx_http_spdy_out_frame_t *frame, **fn;
967 961
968 if (stream->queued == 0) { 962 if (stream->queued == 0) {
969 return; 963 return;
970 } 964 }
971 965
972 r = stream->request;
973
974 fn = &stream->connection->last_out; 966 fn = &stream->connection->last_out;
975 967
976 for ( ;; ) { 968 for ( ;; ) {
977 frame = *fn; 969 frame = *fn;
978 970
979 if (frame == NULL) { 971 if (frame == NULL) {
980 break; 972 break;
981 } 973 }
982 974
983 if (frame->stream == stream && !frame->blocked) { 975 if (frame->stream == stream && !frame->blocked) {
984
985 stream->queued--; 976 stream->queued--;
986 r->blocked--;
987 977
988 *fn = frame->next; 978 *fn = frame->next;
989 continue; 979 continue;
990 } 980 }
991 981