| 1668 | } |
| 1669 | |
| 1670 | Http2Stream * |
| 1671 | Http2ConnectionState::create_initiating_stream(Http2Error &error) |
| 1672 | { |
| 1673 | // first check if we've hit the active connection limit |
| 1674 | if (!session->get_netvc()->add_to_active_queue()) { |
| 1675 | error = Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_NO_ERROR, |
| 1676 | "refused to create new stream, maxed out active connections"); |
| 1677 | return nullptr; |
| 1678 | } |
| 1679 | |
| 1680 | // In half_close state, TS doesn't create new stream. Because GOAWAY frame is sent to client |
| 1681 | if (session->get_half_close_local_flag()) { |
| 1682 | error = Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_STREAM, Http2ErrorCode::HTTP2_ERROR_REFUSED_STREAM, |
| 1683 | "refused to create new stream, because session is in half_close state"); |
| 1684 | return nullptr; |
| 1685 | } |
| 1686 | |
| 1687 | // Endpoints MUST NOT exceed the limit set by their peer. An endpoint |
| 1688 | // that receives a HEADERS frame that causes their advertised concurrent |
| 1689 | // stream limit to be exceeded MUST treat this as a stream error. |
| 1690 | int check_max_concurrent_limit; |
| 1691 | int check_count; |
| 1692 | check_count = peer_streams_count_in; |
| 1693 | // If this is an outbound client stream, must check against the peer's max_concurrent |
| 1694 | if (session->is_outbound()) { |
| 1695 | check_max_concurrent_limit = peer_settings.get(HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS); |
| 1696 | } else { // Inbound client streamm check against our own max_connecurent limits |
| 1697 | check_max_concurrent_limit = local_settings.get(HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS); |
| 1698 | } |
| 1699 | ink_release_assert(check_max_concurrent_limit != 0); |
| 1700 | |
| 1701 | // If we haven't got the peers settings yet, just hope for the best |
| 1702 | if (check_max_concurrent_limit >= 0) { |
| 1703 | if (session->is_outbound() && Http2ConnectionState::is_peer_concurrent_stream_ub()) { |
| 1704 | error = Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_STREAM, Http2ErrorCode::HTTP2_ERROR_REFUSED_STREAM, |
| 1705 | "recv headers creating stream beyond max_concurrent limit"); |
| 1706 | return nullptr; |
| 1707 | } else if (check_count >= check_max_concurrent_limit) { |
| 1708 | error = Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_STREAM, Http2ErrorCode::HTTP2_ERROR_REFUSED_STREAM, |
| 1709 | "recv headers creating stream beyond max_concurrent limit"); |
| 1710 | return nullptr; |
| 1711 | } |
| 1712 | } |
| 1713 | |
| 1714 | ink_assert(dynamic_cast<Http2CommonSession *>(this->session->get_proxy_session())); |
| 1715 | ink_assert(this->session->is_outbound() == true); |
| 1716 | uint32_t const initial_stream_window = this->acknowledged_local_settings.get(HTTP2_SETTINGS_INITIAL_WINDOW_SIZE); |
| 1717 | Http2Stream *new_stream = |
| 1718 | THREAD_ALLOC_INIT(http2StreamAllocator, this_ethread(), session->get_proxy_session(), -1, |
| 1719 | peer_settings.get(HTTP2_SETTINGS_INITIAL_WINDOW_SIZE), initial_stream_window, STREAM_IS_REGISTERED); |
| 1720 | |
| 1721 | ink_assert(nullptr != new_stream); |
| 1722 | ink_assert(!stream_list.in(new_stream)); |
| 1723 | |
| 1724 | stream_list.enqueue(new_stream); |
| 1725 | ink_assert(peer_streams_count_in < UINT32_MAX); |
| 1726 | ++peer_streams_count_in; |
| 1727 | ++total_peer_streams_count; |
no test coverage detected