details: http://hg.nginx.org/nginx/rev/827e53c136b0 branches: changeset: 5530:827e53c136b0 user: Valentin Bartenev <vb...@nginx.com> date: Mon Jan 20 20:56:49 2014 +0400 description: SPDY: use ngx_queue_t to queue streams for post processing.
It simplifies the code and allows easy reuse the same queue pointer to store streams in various queues with different requirements. Future implementation of SPDY/3.1 will take advantage of this quality. diffstat: src/http/ngx_http_spdy.c | 38 ++++++++++++++------------------- src/http/ngx_http_spdy.h | 6 +++- src/http/ngx_http_spdy_filter_module.c | 4 +-- 3 files changed, 21 insertions(+), 27 deletions(-) diffs (121 lines): diff -r e4adaa47af65 -r 827e53c136b0 src/http/ngx_http_spdy.c --- a/src/http/ngx_http_spdy.c Wed Jan 22 04:58:19 2014 +0400 +++ b/src/http/ngx_http_spdy.c Mon Jan 20 20:56:49 2014 +0400 @@ -302,6 +302,8 @@ ngx_http_spdy_init(ngx_event_t *rev) return; } + ngx_queue_init(&sc->posted); + c->data = sc; rev->handler = ngx_http_spdy_read_handler; @@ -405,8 +407,9 @@ static void ngx_http_spdy_write_handler(ngx_event_t *wev) { ngx_int_t rc; + ngx_queue_t *q; ngx_connection_t *c; - ngx_http_spdy_stream_t *stream, *s, *sn; + ngx_http_spdy_stream_t *stream; ngx_http_spdy_connection_t *sc; c = wev->data; @@ -430,18 +433,13 @@ ngx_http_spdy_write_handler(ngx_event_t return; } - stream = NULL; - - for (s = sc->last_stream; s; s = sn) { - sn = s->next; - s->next = stream; - stream = s; - } - - sc->last_stream = NULL; - - for ( /* void */ ; stream; stream = sn) { - sn = stream->next; + while (!ngx_queue_empty(&sc->posted)) { + q = ngx_queue_head(&sc->posted); + + ngx_queue_remove(q); + + stream = ngx_queue_data(q, ngx_http_spdy_stream_t, queue); + stream->handled = 0; ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, @@ -2593,6 +2591,11 @@ ngx_http_spdy_close_stream(ngx_http_spdy "spdy close stream %ui, queued %ui, processing %ui", stream->id, stream->queued, sc->processing); + if (stream->handled) { + stream->handled = 0; + ngx_queue_remove(&stream->queue); + } + fc = stream->request->connection; if (stream->queued) { @@ -2614,15 +2617,6 @@ ngx_http_spdy_close_stream(ngx_http_spdy sc->stream = NULL; } - if (stream->handled) { - for (s = sc->last_stream; s; s = s->next) { - if (s->next == stream) { - s->next = stream->next; - break; - } - } - } - sscf = ngx_http_get_module_srv_conf(sc->http_connection->conf_ctx, ngx_http_spdy_module); diff -r e4adaa47af65 -r 827e53c136b0 src/http/ngx_http_spdy.h --- a/src/http/ngx_http_spdy.h Wed Jan 22 04:58:19 2014 +0400 +++ b/src/http/ngx_http_spdy.h Mon Jan 20 20:56:49 2014 +0400 @@ -96,7 +96,8 @@ struct ngx_http_spdy_connection_s { ngx_http_spdy_stream_t **streams_index; ngx_http_spdy_out_frame_t *last_out; - ngx_http_spdy_stream_t *last_stream; + + ngx_queue_t posted; ngx_http_spdy_stream_t *stream; @@ -116,7 +117,6 @@ struct ngx_http_spdy_stream_s { ngx_http_request_t *request; ngx_http_spdy_connection_t *connection; ngx_http_spdy_stream_t *index; - ngx_http_spdy_stream_t *next; ngx_uint_t header_buffers; ngx_uint_t queued; @@ -125,6 +125,8 @@ struct ngx_http_spdy_stream_s { ngx_chain_t *free_data_headers; ngx_chain_t *free_bufs; + ngx_queue_t queue; + unsigned priority:2; unsigned handled:1; unsigned blocked:1; diff -r e4adaa47af65 -r 827e53c136b0 src/http/ngx_http_spdy_filter_module.c --- a/src/http/ngx_http_spdy_filter_module.c Wed Jan 22 04:58:19 2014 +0400 +++ b/src/http/ngx_http_spdy_filter_module.c Mon Jan 20 20:56:49 2014 +0400 @@ -1073,9 +1073,7 @@ ngx_http_spdy_handle_stream(ngx_http_spd wev->delayed = 0; stream->handled = 1; - - stream->next = sc->last_stream; - sc->last_stream = stream; + ngx_queue_insert_tail(&sc->posted, &stream->queue); } } _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel