Mercurial > hg > nginx
comparison src/http/ngx_http_spdy.c @ 5529:e4adaa47af65
SPDY: store the length of frame instead of its whole size.
The "length" value better corresponds with the specification and reduces
confusion about whether frame's header is included in "size" or not.
Also this change simplifies some parts of code, since in more cases the
length of frame is more useful than its actual size, especially considering
that the size of frame header is constant.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 22 Jan 2014 04:58:19 +0400 |
parents | d5de6c25b759 |
children | 827e53c136b0 |
comparison
equal
deleted
inserted
replaced
5528:d5de6c25b759 | 5529:e4adaa47af65 |
---|---|
492 fn = frame->next; | 492 fn = frame->next; |
493 frame->next = out; | 493 frame->next = out; |
494 out = frame; | 494 out = frame; |
495 | 495 |
496 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0, | 496 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0, |
497 "spdy frame out: %p sid:%ui prio:%ui bl:%d size:%uz", | 497 "spdy frame out: %p sid:%ui prio:%ui bl:%d len:%uz", |
498 out, out->stream ? out->stream->id : 0, out->priority, | 498 out, out->stream ? out->stream->id : 0, out->priority, |
499 out->blocked, out->size); | 499 out->blocked, out->length); |
500 } | 500 } |
501 | 501 |
502 cl = c->send_chain(c, cl, 0); | 502 cl = c->send_chain(c, cl, 0); |
503 | 503 |
504 if (cl == NGX_CHAIN_ERROR) { | 504 if (cl == NGX_CHAIN_ERROR) { |
535 out->priority = NGX_SPDY_HIGHEST_PRIORITY; | 535 out->priority = NGX_SPDY_HIGHEST_PRIORITY; |
536 break; | 536 break; |
537 } | 537 } |
538 | 538 |
539 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, | 539 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, |
540 "spdy frame sent: %p sid:%ui bl:%d size:%uz", | 540 "spdy frame sent: %p sid:%ui bl:%d len:%uz", |
541 out, out->stream ? out->stream->id : 0, | 541 out, out->stream ? out->stream->id : 0, |
542 out->blocked, out->size); | 542 out->blocked, out->length); |
543 } | 543 } |
544 | 544 |
545 frame = NULL; | 545 frame = NULL; |
546 | 546 |
547 for ( /* void */ ; out; out = fn) { | 547 for ( /* void */ ; out; out = fn) { |
1585 frame->first = cl; | 1585 frame->first = cl; |
1586 frame->last = cl; | 1586 frame->last = cl; |
1587 frame->handler = ngx_http_spdy_settings_frame_handler; | 1587 frame->handler = ngx_http_spdy_settings_frame_handler; |
1588 frame->stream = NULL; | 1588 frame->stream = NULL; |
1589 #if (NGX_DEBUG) | 1589 #if (NGX_DEBUG) |
1590 frame->size = NGX_SPDY_FRAME_HEADER_SIZE | 1590 frame->length = NGX_SPDY_SETTINGS_NUM_SIZE + NGX_SPDY_SETTINGS_PAIR_SIZE; |
1591 + NGX_SPDY_SETTINGS_NUM_SIZE | |
1592 + NGX_SPDY_SETTINGS_PAIR_SIZE; | |
1593 #endif | 1591 #endif |
1594 frame->priority = NGX_SPDY_HIGHEST_PRIORITY; | 1592 frame->priority = NGX_SPDY_HIGHEST_PRIORITY; |
1595 frame->blocked = 0; | 1593 frame->blocked = 0; |
1596 | 1594 |
1597 p = buf->pos; | 1595 p = buf->pos; |
1635 return NGX_OK; | 1633 return NGX_OK; |
1636 } | 1634 } |
1637 | 1635 |
1638 | 1636 |
1639 static ngx_http_spdy_out_frame_t * | 1637 static ngx_http_spdy_out_frame_t * |
1640 ngx_http_spdy_get_ctl_frame(ngx_http_spdy_connection_t *sc, size_t size, | 1638 ngx_http_spdy_get_ctl_frame(ngx_http_spdy_connection_t *sc, size_t length, |
1641 ngx_uint_t priority) | 1639 ngx_uint_t priority) |
1642 { | 1640 { |
1643 ngx_chain_t *cl; | 1641 ngx_chain_t *cl; |
1644 ngx_http_spdy_out_frame_t *frame; | 1642 ngx_http_spdy_out_frame_t *frame; |
1645 | 1643 |
1675 frame->handler = ngx_http_spdy_ctl_frame_handler; | 1673 frame->handler = ngx_http_spdy_ctl_frame_handler; |
1676 frame->stream = NULL; | 1674 frame->stream = NULL; |
1677 } | 1675 } |
1678 | 1676 |
1679 #if (NGX_DEBUG) | 1677 #if (NGX_DEBUG) |
1680 if (size > NGX_SPDY_CTL_FRAME_BUFFER_SIZE - NGX_SPDY_FRAME_HEADER_SIZE) { | 1678 if (length > NGX_SPDY_CTL_FRAME_BUFFER_SIZE - NGX_SPDY_FRAME_HEADER_SIZE) { |
1681 ngx_log_error(NGX_LOG_ALERT, sc->pool->log, 0, | 1679 ngx_log_error(NGX_LOG_ALERT, sc->pool->log, 0, |
1682 "requested control frame is too big: %uz", size); | 1680 "requested control frame is too big: %uz", length); |
1683 return NULL; | 1681 return NULL; |
1684 } | 1682 } |
1685 | 1683 |
1686 frame->size = size; | 1684 frame->length = length; |
1687 #endif | 1685 #endif |
1688 | 1686 |
1689 frame->priority = priority; | 1687 frame->priority = priority; |
1690 frame->blocked = 0; | 1688 frame->blocked = 0; |
1691 | 1689 |