Mercurial > hg > nginx
comparison src/http/ngx_http_spdy.c @ 5530:827e53c136b0
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.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Mon, 20 Jan 2014 20:56:49 +0400 |
parents | e4adaa47af65 |
children | 39d7eef2e332 |
comparison
equal
deleted
inserted
replaced
5529:e4adaa47af65 | 5530:827e53c136b0 |
---|---|
300 if (ngx_http_spdy_send_settings(sc) == NGX_ERROR) { | 300 if (ngx_http_spdy_send_settings(sc) == NGX_ERROR) { |
301 ngx_http_close_connection(c); | 301 ngx_http_close_connection(c); |
302 return; | 302 return; |
303 } | 303 } |
304 | 304 |
305 ngx_queue_init(&sc->posted); | |
306 | |
305 c->data = sc; | 307 c->data = sc; |
306 | 308 |
307 rev->handler = ngx_http_spdy_read_handler; | 309 rev->handler = ngx_http_spdy_read_handler; |
308 c->write->handler = ngx_http_spdy_write_handler; | 310 c->write->handler = ngx_http_spdy_write_handler; |
309 | 311 |
403 | 405 |
404 static void | 406 static void |
405 ngx_http_spdy_write_handler(ngx_event_t *wev) | 407 ngx_http_spdy_write_handler(ngx_event_t *wev) |
406 { | 408 { |
407 ngx_int_t rc; | 409 ngx_int_t rc; |
410 ngx_queue_t *q; | |
408 ngx_connection_t *c; | 411 ngx_connection_t *c; |
409 ngx_http_spdy_stream_t *stream, *s, *sn; | 412 ngx_http_spdy_stream_t *stream; |
410 ngx_http_spdy_connection_t *sc; | 413 ngx_http_spdy_connection_t *sc; |
411 | 414 |
412 c = wev->data; | 415 c = wev->data; |
413 sc = c->data; | 416 sc = c->data; |
414 | 417 |
428 if (rc == NGX_ERROR) { | 431 if (rc == NGX_ERROR) { |
429 ngx_http_spdy_finalize_connection(sc, NGX_HTTP_CLIENT_CLOSED_REQUEST); | 432 ngx_http_spdy_finalize_connection(sc, NGX_HTTP_CLIENT_CLOSED_REQUEST); |
430 return; | 433 return; |
431 } | 434 } |
432 | 435 |
433 stream = NULL; | 436 while (!ngx_queue_empty(&sc->posted)) { |
434 | 437 q = ngx_queue_head(&sc->posted); |
435 for (s = sc->last_stream; s; s = sn) { | 438 |
436 sn = s->next; | 439 ngx_queue_remove(q); |
437 s->next = stream; | 440 |
438 stream = s; | 441 stream = ngx_queue_data(q, ngx_http_spdy_stream_t, queue); |
439 } | 442 |
440 | |
441 sc->last_stream = NULL; | |
442 | |
443 for ( /* void */ ; stream; stream = sn) { | |
444 sn = stream->next; | |
445 stream->handled = 0; | 443 stream->handled = 0; |
446 | 444 |
447 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 445 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
448 "spdy run stream %ui", stream->id); | 446 "spdy run stream %ui", stream->id); |
449 | 447 |
2591 | 2589 |
2592 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, sc->connection->log, 0, | 2590 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, sc->connection->log, 0, |
2593 "spdy close stream %ui, queued %ui, processing %ui", | 2591 "spdy close stream %ui, queued %ui, processing %ui", |
2594 stream->id, stream->queued, sc->processing); | 2592 stream->id, stream->queued, sc->processing); |
2595 | 2593 |
2594 if (stream->handled) { | |
2595 stream->handled = 0; | |
2596 ngx_queue_remove(&stream->queue); | |
2597 } | |
2598 | |
2596 fc = stream->request->connection; | 2599 fc = stream->request->connection; |
2597 | 2600 |
2598 if (stream->queued) { | 2601 if (stream->queued) { |
2599 fc->write->handler = ngx_http_spdy_close_stream_handler; | 2602 fc->write->handler = ngx_http_spdy_close_stream_handler; |
2600 return; | 2603 return; |
2610 } | 2613 } |
2611 } | 2614 } |
2612 | 2615 |
2613 if (sc->stream == stream) { | 2616 if (sc->stream == stream) { |
2614 sc->stream = NULL; | 2617 sc->stream = NULL; |
2615 } | |
2616 | |
2617 if (stream->handled) { | |
2618 for (s = sc->last_stream; s; s = s->next) { | |
2619 if (s->next == stream) { | |
2620 s->next = stream->next; | |
2621 break; | |
2622 } | |
2623 } | |
2624 } | 2618 } |
2625 | 2619 |
2626 sscf = ngx_http_get_module_srv_conf(sc->http_connection->conf_ctx, | 2620 sscf = ngx_http_get_module_srv_conf(sc->http_connection->conf_ctx, |
2627 ngx_http_spdy_module); | 2621 ngx_http_spdy_module); |
2628 | 2622 |