Lines Matching refs:stream
95 nghttp2_stream *stream,
97 if (!stream || frame->hd.type != NGHTTP2_HEADERS) {
105 (stream->http_flags & NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE) == 0;
108 /* Returns nonzero if the |stream| is in reserved(remote) state */
110 nghttp2_stream *stream) {
111 return stream->state == NGHTTP2_STREAM_RESERVED &&
112 !nghttp2_session_is_my_stream_id(session, stream->stream_id);
115 /* Returns nonzero if the |stream| is in reserved(local) state */
117 nghttp2_stream *stream) {
118 return stream->state == NGHTTP2_STREAM_RESERVED &&
119 nghttp2_session_is_my_stream_id(session, stream->stream_id);
135 /* Assume that stream object with stream_id does not exist */
288 nghttp2_stream *stream;
290 stream = (nghttp2_stream *)nghttp2_map_find(&session->streams, stream_id);
292 if (stream == NULL || (stream->flags & NGHTTP2_STREAM_FLAG_CLOSED) ||
293 stream->state == NGHTTP2_STREAM_IDLE) {
297 return stream;
733 nghttp2_stream *stream;
739 stream = (nghttp2_stream *)entry;
740 item = stream->item;
747 nghttp2_stream_free(stream);
748 nghttp2_mem_free(mem, stream);
820 stream->item->queued */
837 nghttp2_session *session, nghttp2_stream *stream,
846 assert(pri_spec->stream_id != stream->stream_id);
848 if (!nghttp2_stream_in_dep_tree(stream)) {
875 } else if (nghttp2_stream_dep_find_ancestor(dep_stream, stream)) {
876 DEBUGF("stream: cycle detected, dep_stream(%p)=%d stream(%p)=%d\n",
877 dep_stream, dep_stream->stream_id, stream, stream->stream_id);
880 rv = nghttp2_stream_dep_add_subtree(stream->dep_prev, dep_stream);
888 if (dep_stream == stream->dep_prev && !pri_spec->exclusive) {
890 nghttp2_stream_change_weight(stream, pri_spec->weight);
895 nghttp2_stream_dep_remove_subtree(stream);
897 /* We have to update weight after removing stream from tree */
898 stream->weight = pri_spec->weight;
901 rv = nghttp2_stream_dep_insert_subtree(dep_stream, stream);
903 rv = nghttp2_stream_dep_add_subtree(dep_stream, stream);
914 nghttp2_stream *stream;
920 stream = nghttp2_struct_of(nghttp2_pq_top(pq), nghttp2_stream, pq_entry);
921 return stream->cycle;
925 nghttp2_stream *stream) {
931 assert(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES);
932 assert(stream->queued == 0);
934 urgency = nghttp2_extpri_uint8_urgency(stream->extpri);
935 inc = nghttp2_extpri_uint8_inc(stream->extpri);
941 stream->cycle = pq_get_first_cycle(pq);
943 stream->cycle += stream->last_writelen;
946 rv = nghttp2_pq_push(pq, &stream->pq_entry);
951 stream->queued = 1;
957 nghttp2_stream *stream) {
960 assert(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES);
961 assert(stream->queued == 1);
963 urgency = nghttp2_extpri_uint8_urgency(stream->extpri);
967 nghttp2_pq_remove(&session->sched[urgency].ob_data, &stream->pq_entry);
969 stream->queued = 0;
973 nghttp2_stream *stream,
977 rv = nghttp2_stream_attach_item(stream, item);
982 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES)) {
986 return session_ob_data_push(session, stream);
990 nghttp2_stream *stream) {
991 nghttp2_stream_detach_item(stream);
993 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) ||
994 !stream->queued) {
998 session_ob_data_remove(session, stream);
1002 nghttp2_stream *stream, uint8_t flags) {
1003 nghttp2_stream_defer_item(stream, flags);
1005 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) ||
1006 !stream->queued) {
1010 session_ob_data_remove(session, stream);
1014 nghttp2_stream *stream,
1018 rv = nghttp2_stream_resume_deferred_item(stream, flags);
1023 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) ||
1024 (stream->flags & NGHTTP2_STREAM_FLAG_DEFERRED_ALL)) {
1028 return session_ob_data_push(session, stream);
1035 nghttp2_stream *stream;
1043 stream = nghttp2_struct_of(ent, nghttp2_stream, pq_entry);
1044 return stream->item;
1063 nghttp2_stream *stream) {
1065 uint32_t urgency = nghttp2_extpri_uint8_urgency(stream->extpri);
1066 int inc = nghttp2_extpri_uint8_inc(stream->extpri);
1067 uint64_t penalty = (uint64_t)stream->last_writelen;
1080 nghttp2_pq_remove(pq, &stream->pq_entry);
1082 stream->cycle += penalty;
1084 rv = nghttp2_pq_push(pq, &stream->pq_entry);
1090 nghttp2_stream *stream,
1092 if (stream->extpri == u8extpri) {
1096 if (stream->queued) {
1097 session_ob_data_remove(session, stream);
1099 stream->extpri = u8extpri;
1101 return session_ob_data_push(session, stream);
1104 stream->extpri = u8extpri;
1111 /* TODO Return error if stream is not found for the frame requiring
1112 stream presence. */
1114 nghttp2_stream *stream;
1118 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
1122 if (!stream) {
1126 if (stream->item) {
1130 rv = session_attach_stream_item(session, stream, item);
1141 /* TODO If 2 HEADERS are submitted for reserved stream, then
1145 (stream && stream->state == NGHTTP2_STREAM_RESERVED)) {
1161 if (stream) {
1162 stream->state = NGHTTP2_STREAM_CLOSING;
1173 if (!stream) {
1177 nghttp2_priority_spec_init(&pri_spec, stream->stream_id,
1188 here, since stream->stream_id is local stream_id, and it does
1189 not affect closed stream count. */
1197 if (stream) {
1198 stream->window_update_queued = 1;
1217 nghttp2_stream *stream;
1221 stream = nghttp2_session_get_stream(session, stream_id);
1222 if (stream && stream->state == NGHTTP2_STREAM_CLOSING) {
1226 /* Sending RST_STREAM to an idle stream is subject to protocol
1239 refers to that stream. */
1296 nghttp2_stream *stream;
1304 stream = nghttp2_session_get_stream_raw(session, stream_id);
1311 if (stream) {
1312 assert(stream->state == NGHTTP2_STREAM_IDLE);
1313 assert((stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) ||
1314 nghttp2_stream_in_dep_tree(stream));
1316 if (nghttp2_stream_in_dep_tree(stream)) {
1317 assert(!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES));
1318 nghttp2_session_detach_idle_stream(session, stream);
1319 rv = nghttp2_stream_dep_remove(stream);
1325 stream->flags |= NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES;
1329 stream = nghttp2_mem_malloc(mem, sizeof(nghttp2_stream));
1330 if (stream == NULL) {
1356 /* Depends on idle stream, which does not exist in memory.
1366 nghttp2_mem_free(mem, stream);
1372 /* If dep_stream is not part of dependency tree, stream will get
1375 don't check pri_spec->stream_id against new stream ID in
1377 stream created by PRIORITY frame was opened. Somehow we
1378 first remove the idle stream from dependency tree. This is
1391 nghttp2_stream_init(stream, stream_id, flags, initial_state,
1398 stream->seq = session->stream_seq++;
1401 rv = nghttp2_map_insert(&session->streams, stream_id, stream);
1403 nghttp2_stream_free(stream);
1404 nghttp2_mem_free(mem, stream);
1408 stream->flags = flags;
1409 stream->state = initial_state;
1410 stream->weight = pri_spec->weight;
1411 stream->stream_user_data = stream_user_data;
1418 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
1421 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
1424 /* Reserved stream does not count in the concurrent streams
1428 /* Idle stream does not count toward the concurrent streams limit.
1430 nghttp2_session_keep_idle_stream(session, stream);
1440 if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) {
1441 return stream;
1451 rv = nghttp2_stream_dep_insert(dep_stream, stream);
1456 nghttp2_stream_dep_add(dep_stream, stream);
1459 return stream;
1465 nghttp2_stream *stream;
1470 stream = nghttp2_session_get_stream(session, stream_id);
1472 if (!stream) {
1476 DEBUGF("stream: stream(%p)=%d close\n", stream, stream->stream_id);
1478 if (stream->item) {
1481 item = stream->item;
1483 session_detach_stream_item(session, stream);
1495 /* We call on_stream_close_callback even if stream->state is
1497 HEADERS, a local endpoint receives RST_STREAM for that stream. It
1498 may be PROTOCOL_ERROR, but without notifying stream closure will
1499 hang the stream in a local endpoint.
1514 if ((stream->flags & NGHTTP2_STREAM_FLAG_PUSH)) {
1527 stream->flags |= NGHTTP2_STREAM_FLAG_CLOSED;
1530 return nghttp2_session_destroy_stream(session, stream);
1535 nghttp2_stream_in_dep_tree(stream)) {
1536 /* On server side, retain stream at most MAX_CONCURRENT_STREAMS
1539 nghttp2_session_keep_closed_stream(session, stream);
1541 rv = nghttp2_session_destroy_stream(session, stream);
1551 nghttp2_stream *stream) {
1555 DEBUGF("stream: destroy closed stream(%p)=%d\n", stream, stream->stream_id);
1559 if (nghttp2_stream_in_dep_tree(stream)) {
1560 rv = nghttp2_stream_dep_remove(stream);
1566 nghttp2_map_remove(&session->streams, stream->stream_id);
1567 nghttp2_stream_free(stream);
1568 nghttp2_mem_free(mem, stream);
1574 nghttp2_stream *stream) {
1575 DEBUGF("stream: keep closed stream(%p)=%d, state=%d\n", stream,
1576 stream->stream_id, stream->state);
1579 session->closed_stream_tail->closed_next = stream;
1580 stream->closed_prev = session->closed_stream_tail;
1582 session->closed_stream_head = stream;
1584 session->closed_stream_tail = stream;
1590 nghttp2_stream *stream) {
1591 DEBUGF("stream: keep idle stream(%p)=%d, state=%d\n", stream,
1592 stream->stream_id, stream->state);
1595 session->idle_stream_tail->closed_next = stream;
1596 stream->closed_prev = session->idle_stream_tail;
1598 session->idle_stream_head = stream;
1600 session->idle_stream_tail = stream;
1606 nghttp2_stream *stream) {
1609 DEBUGF("stream: detach idle stream(%p)=%d, state=%d\n", stream,
1610 stream->stream_id, stream->state);
1612 prev_stream = stream->closed_prev;
1613 next_stream = stream->closed_next;
1627 stream->closed_prev = NULL;
1628 stream->closed_next = NULL;
1644 DEBUGF("stream: adjusting kept closed streams num_closed_streams=%zu, "
1693 DEBUGF("stream: adjusting kept idle streams num_idle_streams=%zu, max=%zu\n",
1727 * Closes stream with stream ID |stream_id| if both transmission and
1728 * reception of the stream were disallowed. The |error_code| indicates
1735 * The stream is not found.
1740 nghttp2_stream *stream) {
1741 if ((stream->shut_flags & NGHTTP2_SHUT_RDWR) == NGHTTP2_SHUT_RDWR) {
1742 return nghttp2_session_close_stream(session, stream->stream_id,
1749 * Returns nonzero if local endpoint allows reception of new stream
1767 * Check that we can send a frame to the |stream|. This function
1772 * The stream is already closed.
1774 * The stream is half-closed for transmission.
1779 nghttp2_stream *stream) {
1780 if (stream == NULL) {
1786 if (stream->shut_flags & NGHTTP2_SHUT_WR) {
1799 * This function checks request HEADERS frame, which opens stream, can
1806 * New stream cannot be created because of GOAWAY: session is
1829 * server, with the |stream| can be sent at this time. The |stream|
1836 * The stream is already closed or does not exist.
1838 * The transmission is not allowed for this stream (e.g., a frame
1841 * The stream ID is invalid.
1843 * RST_STREAM was queued for this stream.
1845 * The state of the stream is not valid.
1852 nghttp2_stream *stream) {
1854 rv = session_predicate_for_stream_send(session, stream);
1858 assert(stream);
1862 if (nghttp2_session_is_my_stream_id(session, stream->stream_id)) {
1865 switch (stream->state) {
1876 * This function checks HEADERS for reserved stream can be sent. The
1877 * |stream| must be reserved state and the |session| is server side.
1878 * The |stream| can be NULL.
1884 * The stream is already closed.
1886 * The stream is half-closed for transmission.
1888 * The stream is not reserved state
1890 * RST_STREAM was queued for this stream.
1894 * New stream cannot be created because GOAWAY is already sent or
1901 nghttp2_stream *stream) {
1904 rv = session_predicate_for_stream_send(session, stream);
1908 assert(stream);
1912 if (stream->state != NGHTTP2_STREAM_RESERVED) {
1922 * This function checks HEADERS, which is neither stream-opening nor
1923 * first response header, with the |stream| can be sent at this time.
1924 * The |stream| can be NULL.
1930 * The stream is already closed or does not exist.
1932 * The transmission is not allowed for this stream (e.g., a frame
1935 * RST_STREAM was queued for this stream.
1937 * The state of the stream is not valid.
1942 nghttp2_stream *stream) {
1944 rv = session_predicate_for_stream_send(session, stream);
1948 assert(stream);
1950 switch (stream->state) {
1956 if (nghttp2_session_is_my_stream_id(session, stream->stream_id)) {
1964 * This function checks PUSH_PROMISE frame |frame| with the |stream|
1965 * can be sent at this time. The |stream| can be NULL.
1971 * New stream cannot be created because GOAWAY is already sent or
1975 * sends PUSH_PROMISE for the stream not initiated by the client.
1977 * The stream is already closed or does not exist.
1979 * RST_STREAM was queued for this stream.
1981 * The transmission is not allowed for this stream (e.g., a frame
1989 nghttp2_stream *stream) {
1996 rv = session_predicate_for_stream_send(session, stream);
2001 assert(stream);
2006 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2016 * This function checks WINDOW_UPDATE with the stream ID |stream_id|
2024 * The stream is already closed or does not exist.
2026 * RST_STREAM was queued for this stream.
2028 * The state of the stream is not valid.
2034 nghttp2_stream *stream;
2044 stream = nghttp2_session_get_stream(session, stream_id);
2045 if (stream == NULL) {
2048 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2051 if (state_reserved_local(session, stream)) {
2059 nghttp2_stream *stream;
2069 stream = nghttp2_session_get_stream(session, stream_id);
2070 if (stream == NULL) {
2073 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2089 nghttp2_stream *stream;
2095 stream = nghttp2_session_get_stream(session, stream_id);
2096 if (stream == NULL) {
2099 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2102 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
2113 nghttp2_stream *stream,
2116 "stream(id %d)=%d\n",
2118 stream->stream_id, stream->remote_window_size);
2121 stream->remote_window_size),
2128 * connection-level and/or stream-wise flow control are enabled, the
2133 nghttp2_stream *stream) {
2137 session, stream, NGHTTP2_DATA_PAYLOADLEN);
2145 * This function checks DATA with the |stream| can be sent at this
2146 * time. The |stream| can be NULL.
2152 * The stream is already closed or does not exist.
2154 * The transmission is not allowed for this stream (e.g., a frame
2157 * RST_STREAM was queued for this stream.
2159 * The state of the stream is not valid.
2164 nghttp2_stream *stream) {
2166 rv = session_predicate_for_stream_send(session, stream);
2170 assert(stream);
2171 if (nghttp2_session_is_my_stream_id(session, stream->stream_id)) {
2173 /* If stream->state is NGHTTP2_STREAM_CLOSING, RST_STREAM was
2176 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2179 if (stream->state == NGHTTP2_STREAM_RESERVED) {
2185 if (stream->state == NGHTTP2_STREAM_OPENED) {
2188 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2316 nghttp2_stream *stream;
2318 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2320 if (stream) {
2321 assert(stream->item == item);
2324 rv = nghttp2_session_predicate_data_send(session, stream);
2326 // If stream was already closed, nghttp2_session_get_stream()
2327 // returns NULL, but item is still attached to the stream.
2328 // Search stream including closed again.
2329 stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id);
2330 if (stream) {
2331 session_detach_stream_item(session, stream);
2336 /* Assuming stream is not NULL */
2337 assert(stream);
2338 next_readmax = nghttp2_session_next_data_read(session, stream);
2346 session_defer_stream_item(session, stream,
2356 stream);
2361 session_defer_stream_item(session, stream,
2369 session_detach_stream_item(session, stream);
2379 session_detach_stream_item(session, stream);
2392 /* initial HEADERS, which opens stream */
2393 nghttp2_stream *stream;
2395 stream = nghttp2_session_open_stream(
2400 if (stream == NULL) {
2405 since we don't keep closed stream in client side */
2413 nghttp2_http_record_request_method(stream, frame);
2416 nghttp2_stream *stream;
2418 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2420 if (stream && stream->state == NGHTTP2_STREAM_RESERVED) {
2421 rv = session_predicate_push_response_headers_send(session, stream);
2426 stream->stream_user_data = aux_data->stream_user_data;
2429 } else if (session_predicate_response_headers_send(session, stream) ==
2436 rv = session_predicate_headers_send(session, stream);
2482 /* PRIORITY frame can be sent at any time and to any stream
2486 /* Peer can send PRIORITY frame against idle stream to create
2489 or idle) streams in memory, so we don't open stream here. */
2518 nghttp2_stream *stream;
2521 /* stream could be NULL if associated stream was already
2523 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2525 /* predicate should fail if stream is NULL. */
2526 rv = session_predicate_push_promise_send(session, stream);
2531 assert(stream);
2747 nghttp2_stream *stream;
2750 stream = (nghttp2_stream *)entry;
2752 if (nghttp2_session_is_my_stream_id(arg->session, stream->stream_id)) {
2760 if (stream->state != NGHTTP2_STREAM_IDLE &&
2761 (stream->flags & NGHTTP2_STREAM_FLAG_CLOSED) == 0 &&
2762 stream->stream_id > arg->last_stream_id) {
2766 assert(stream->closed_next == NULL);
2767 assert(stream->closed_prev == NULL);
2770 stream->closed_next = arg->head;
2771 arg->head = stream;
2773 arg->head = stream;
2780 /* Closes non-idle and non-closed streams whose stream ID >
2787 nghttp2_stream *stream, *next_stream;
2794 stream = arg.head;
2795 while (stream) {
2796 next_stream = stream->closed_next;
2797 stream->closed_next = NULL;
2798 rv = nghttp2_session_close_stream(session, stream->stream_id,
2801 /* stream may be deleted here */
2803 stream = next_stream;
2807 while (stream) {
2808 next_stream = stream->closed_next;
2809 stream->closed_next = NULL;
2810 stream = next_stream;
2820 nghttp2_stream *stream) {
2821 stream->last_writelen = stream->item->frame.hd.length;
2823 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES)) {
2824 nghttp2_stream_reschedule(stream);
2832 session_sched_reschedule_stream(session, stream);
2836 nghttp2_stream *stream,
2844 * on_frame_send_callback and handles stream closure upon END_STREAM
2862 nghttp2_stream *stream;
2871 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2876 if (stream) {
2877 stream->remote_window_size -= (int32_t)frame->hd.length;
2880 if (stream && aux_data->eof) {
2881 session_detach_stream_item(session, stream);
2897 (stream->shut_flags & NGHTTP2_SHUT_RDWR) == NGHTTP2_SHUT_RDWR;
2899 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
2901 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
2905 /* stream may be NULL if it was closed */
2907 stream = NULL;
2940 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2941 if (!stream) {
2947 stream->state = NGHTTP2_STREAM_OPENING;
2949 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
2951 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
2964 /* TODO nghttp2_submit_data() may fail if stream has already
2970 stream->flags = (uint8_t)(stream->flags & ~NGHTTP2_STREAM_FLAG_PUSH);
2974 stream->state = NGHTTP2_STREAM_OPENED;
2978 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
2980 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
2992 /* TODO nghttp2_submit_data() may fail if stream has already
3007 stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id);
3009 if (!stream) {
3014 stream = nghttp2_session_open_stream(
3017 if (!stream) {
3021 rv = nghttp2_session_reprioritize_stream(session, stream,
3081 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
3082 if (!stream) {
3086 stream->window_update_queued = 0;
3090 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
3095 rv = session_update_stream_consumed_size(session, stream, 0);
3098 nghttp2_session_update_recv_stream_window_size(session, stream, 0, 1);
3121 nghttp2_stream *stream;
3154 which attach data to stream. We don't want to detach it. */
3164 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
3168 if (nghttp2_session_predicate_data_send(session, stream) != 0) {
3169 if (stream) {
3170 session_detach_stream_item(session, stream);
3276 /* We have to close stream opened by failed request HEADERS
3351 /* We have to close stream opened by canceled request
3436 nghttp2_stream *stream;
3444 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
3445 if (stream == NULL) {
3446 DEBUGF("send: no copy DATA cancelled because stream was closed\n");
3459 session_detach_stream_item(session, stream);
3529 /* We have to call session_after_frame_sent1 here to handle stream
3867 * stream should be RST_STREAMed.
3882 nghttp2_stream *stream;
3887 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
3893 subject_stream = stream;
3894 trailer = session_trailer_headers(session, stream, frame);
3909 from invoking subsequent callbacks for the same stream
3960 "%u, stream: %d, name: [%.*s], value: [%.*s]",
3978 "%u, stream: %d, name: [%.*s], value: [%.*s]",
4029 nghttp2_stream *stream) {
4036 (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) &&
4037 !(stream->flags & NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES) &&
4038 (stream->http_flags & NGHTTP2_HTTP_FLAG_PRIORITY)) {
4039 rv = session_update_stream_priority(session, stream, stream->http_extpri);
4050 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
4051 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
4062 nghttp2_stream *stream;
4064 /* We don't call on_frame_recv_callback if stream has been closed
4066 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
4067 if (!stream || stream->state == NGHTTP2_STREAM_CLOSING) {
4084 rv = nghttp2_http_on_request_headers(stream, frame);
4088 rv = nghttp2_http_on_response_headers(stream);
4091 if (stream->http_flags & NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE) {
4093 rv = nghttp2_http_on_response_headers(stream);
4095 rv = nghttp2_http_on_trailer_headers(stream, frame);
4102 rv = nghttp2_http_on_remote_end_stream(stream);
4122 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
4139 return session_end_stream_headers_received(session, frame, stream);
4145 nghttp2_stream *stream;
4151 /* If client receives idle stream from server, it is invalid
4152 regardless stream ID is even or odd. This is because client is
4175 * stream ID (e.g, numerically smaller than previous), it MUST
4182 * share the complete picture of open/closed stream status. For
4183 * example, after server sends RST_STREAM for a stream, client may
4184 * send trailer HEADERS for that stream. If naive server detects
4190 * connection error if stream ID refers idle stream, or we are
4191 * sure that stream is half-closed(remote) or closed. Otherwise
4194 stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id);
4195 if (stream && (stream->shut_flags & NGHTTP2_SHUT_RD)) {
4197 session, frame, NGHTTP2_ERR_STREAM_CLOSED, "HEADERS: stream closed");
4211 /* We just ignore stream after GOAWAY was sent */
4225 stream = nghttp2_session_open_stream(
4228 if (!stream) {
4248 nghttp2_stream *stream) {
4250 /* This function is only called if stream->state ==
4252 assert(stream->state == NGHTTP2_STREAM_OPENING &&
4258 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
4261 If an endpoint receives additional frames for a stream that is
4262 in this state it MUST respond with a stream error (Section
4268 session, frame, NGHTTP2_ERR_STREAM_CLOSED, "HEADERS: stream closed");
4270 stream->state = NGHTTP2_STREAM_OPENED;
4280 nghttp2_stream *stream) {
4282 assert(stream->state == NGHTTP2_STREAM_RESERVED);
4302 /* We don't accept new stream after GOAWAY was sent. */
4311 nghttp2_stream_promise_fulfilled(stream);
4312 if (!nghttp2_session_is_my_stream_id(session, stream->stream_id)) {
4325 nghttp2_stream *stream) {
4331 if ((stream->shut_flags & NGHTTP2_SHUT_RD)) {
4334 If an endpoint receives additional frames for a stream that is
4335 in this state it MUST respond with a stream error (Section
4341 session, frame, NGHTTP2_ERR_STREAM_CLOSED, "HEADERS: stream closed");
4344 if (stream->state == NGHTTP2_STREAM_OPENED) {
4354 /* If this is remote peer initiated stream, it is OK unless it
4355 has sent END_STREAM frame already. But if stream is in
4358 if (stream->state != NGHTTP2_STREAM_CLOSING) {
4371 nghttp2_stream *stream;
4375 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
4376 if (!stream) {
4381 if (stream->state == NGHTTP2_STREAM_RESERVED) {
4384 stream);
4387 if (stream->state == NGHTTP2_STREAM_OPENING &&
4390 return nghttp2_session_on_response_headers_received(session, frame, stream);
4394 return nghttp2_session_on_headers_received(session, frame, stream);
4400 nghttp2_stream *stream;
4419 stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id);
4421 if (!stream) {
4422 /* PRIORITY against idle stream can create anchor node in
4428 stream = nghttp2_session_open_stream(
4432 if (stream == NULL) {
4441 rv = nghttp2_session_reprioritize_stream(session, stream,
4488 nghttp2_stream *stream;
4496 "RST_STREAM: stream in idle");
4499 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
4500 if (stream) {
4501 /* We may use stream->shut_flags for strict error checking. */
4502 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
4530 nghttp2_stream *stream;
4533 stream = (nghttp2_stream *)entry;
4536 stream, arg->new_window_size, arg->old_window_size);
4538 return nghttp2_session_add_rst_stream(arg->session, stream->stream_id,
4544 if (stream->remote_window_size > 0 &&
4545 nghttp2_stream_check_deferred_by_flow_control(stream)) {
4548 arg->session, stream, NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL);
4583 nghttp2_stream *stream;
4585 stream = (nghttp2_stream *)entry;
4587 stream, arg->new_window_size, arg->old_window_size);
4589 return nghttp2_session_add_rst_stream(arg->session, stream->stream_id,
4593 if (stream->window_update_queued) {
4598 return session_update_stream_consumed_size(arg->session, stream, 0);
4601 if (nghttp2_should_send_window_update(stream->local_window_size,
4602 stream->recv_window_size)) {
4605 stream->stream_id,
4606 stream->recv_window_size);
4611 stream->recv_window_size = 0;
4971 nghttp2_stream *stream;
4997 illegal stream ID is subject to a connection error of type
5006 session, frame, NGHTTP2_ERR_PROTO, "PUSH_PROMISE: stream in idle");
5010 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
5011 if (!stream || stream->state == NGHTTP2_STREAM_CLOSING ||
5015 /* Currently, client does not retain closed stream, so we don't
5026 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
5029 "PUSH_PROMISE: stream closed");
5032 nghttp2_priority_spec_init(&pri_spec, stream->stream_id,
5044 don't keep closed stream in client side */
5102 last stream identifier. */
5161 nghttp2_stream *stream;
5165 "WINDOW_UPDATE to idle stream");
5168 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
5169 if (!stream) {
5172 if (state_reserved_remote(session, stream)) {
5174 session, frame, NGHTTP2_ERR_PROTO, "WINDOW_UPADATE to reserved stream");
5182 stream->remote_window_size) {
5186 stream->remote_window_size += frame->window_update.window_size_increment;
5188 if (stream->remote_window_size > 0 &&
5189 nghttp2_stream_check_deferred_by_flow_control(stream)) {
5192 session, stream, NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL);
5223 nghttp2_stream *stream;
5240 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
5241 if (!stream) {
5245 if (stream->state == NGHTTP2_STREAM_CLOSING) {
5266 nghttp2_stream *stream;
5287 /* TODO Ignore priority signal to a push stream for now */
5291 stream = nghttp2_session_get_stream_raw(session, priority_update->stream_id);
5292 if (stream) {
5294 if (stream->flags & NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES) {
5306 stream = nghttp2_session_open_stream(session, priority_update->stream_id,
5309 if (!stream) {
5326 rv = session_update_stream_priority(session, stream,
5402 nghttp2_stream *stream;
5404 /* We don't call on_frame_recv_callback if stream has been closed
5406 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
5407 if (!stream || stream->state == NGHTTP2_STREAM_CLOSING) {
5408 /* This should be treated as stream error, but it results in lots
5409 of RST_STREAM. So just ignore frame against nonexistent stream
5416 if (nghttp2_http_on_remote_end_stream(stream) != 0) {
5417 rv = nghttp2_session_add_rst_stream(session, stream->stream_id,
5423 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
5436 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
5437 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
5477 nghttp2_stream *stream,
5481 rv = adjust_recv_window_size(&stream->recv_window_size, delta_size,
5482 stream->local_window_size);
5484 return nghttp2_session_add_rst_stream(session, stream->stream_id,
5488 last chunk in the incoming stream. */
5493 stream->window_update_queued == 0 &&
5494 nghttp2_should_send_window_update(stream->local_window_size,
5495 stream->recv_window_size)) {
5497 stream->stream_id,
5498 stream->recv_window_size);
5503 stream->recv_window_size = 0;
5521 /* Use stream ID 0 to update connection-level flow control
5573 nghttp2_stream *stream,
5576 session, &stream->consumed_size, &stream->recv_window_size,
5577 stream->window_update_queued, stream->stream_id, delta_size,
5578 stream->local_window_size);
5589 * Checks that we can receive the DATA frame for stream, which is
5607 nghttp2_stream *stream;
5617 /* The spec says that if a DATA frame is received whose stream ID
5625 failure_reason = "DATA: stream in idle";
5630 stream = nghttp2_session_get_stream(session, stream_id);
5631 if (!stream) {
5632 stream = nghttp2_session_get_stream_raw(session, stream_id);
5633 if (stream && (stream->shut_flags & NGHTTP2_SHUT_RD)) {
5634 failure_reason = "DATA: stream closed";
5641 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
5642 failure_reason = "DATA: stream in half-closed(remote)";
5648 if (stream->state == NGHTTP2_STREAM_CLOSING) {
5651 if (stream->state != NGHTTP2_STREAM_OPENED) {
5652 failure_reason = "DATA: stream not opened";
5657 if (stream->state == NGHTTP2_STREAM_RESERVED) {
5658 failure_reason = "DATA: stream in reserved";
5661 if (stream->state == NGHTTP2_STREAM_CLOSING) {
5823 nghttp2_stream *stream;
5946 /* Check stream is open. If it is not open or closing,
6513 if (padlen < 0 || (size_t)padlen + 4 /* promised stream id */
6585 /* 8 is Last-stream-ID + Error Code */
6730 /* Use promised stream ID for PUSH_PROMISE */
7000 stream = nghttp2_session_get_stream(session, iframe->frame.hd.stream_id);
7001 if (stream) {
7003 session, stream, readlen,
7029 stream = nghttp2_session_get_stream(session, iframe->frame.hd.stream_id);
7031 if (!stream) {
7060 session, stream, readlen,
7095 if (nghttp2_http_on_data_chunk(stream, (size_t)data_readlen) != 0) {
7372 * response HEADERS and concurrent stream limit is reached, we don't
7617 here. We use it to refuse the incoming stream and PUSH_PROMISE
7653 nghttp2_stream *stream) {
7668 session, frame->hd.type, stream->stream_id, session->remote_window_size,
7669 stream->remote_window_size, session->remote_settings.max_frame_size,
7674 payloadlen = nghttp2_session_enforce_flow_control_limits(session, stream,
7772 session_reschedule_stream(session, stream);
7787 nghttp2_stream *stream;
7788 stream = nghttp2_session_get_stream(session, stream_id);
7789 if (stream) {
7790 return stream->stream_user_data;
7799 nghttp2_stream *stream;
7803 stream = nghttp2_session_get_stream(session, stream_id);
7804 if (stream) {
7805 stream->stream_user_data = stream_user_data;
7840 nghttp2_stream *stream;
7841 stream = nghttp2_session_get_stream(session, stream_id);
7842 if (stream == NULL || !nghttp2_stream_check_deferred_item(stream)) {
7846 rv = session_resume_deferred_stream_item(session, stream,
7860 /* TODO account for item attached to stream */
7866 nghttp2_stream *stream;
7867 stream = nghttp2_session_get_stream(session, stream_id);
7868 if (stream == NULL) {
7871 return stream->recv_window_size < 0 ? 0 : stream->recv_window_size;
7877 nghttp2_stream *stream;
7878 stream = nghttp2_session_get_stream(session, stream_id);
7879 if (stream == NULL) {
7882 return stream->local_window_size;
7887 nghttp2_stream *stream;
7889 stream = nghttp2_session_get_stream(session, stream_id);
7890 if (stream == NULL) {
7894 size = stream->local_window_size - stream->recv_window_size;
7921 nghttp2_stream *stream;
7923 stream = nghttp2_session_get_stream(session, stream_id);
7924 if (stream == NULL) {
7928 /* stream->remote_window_size can be negative when
7930 return nghttp2_max(0, stream->remote_window_size);
7991 nghttp2_stream *stream;
8035 stream = nghttp2_session_open_stream(
8038 if (stream == NULL) {
8043 should be the first stream open. */
8046 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
8050 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
8062 nghttp2_stream *stream;
8070 stream = nghttp2_session_get_stream(session, 1);
8071 assert(stream);
8082 stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_UPGRADE_WORKAROUND;
8091 nghttp2_stream *stream;
8099 stream = nghttp2_session_get_stream(session, 1);
8100 assert(stream);
8103 stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_HEAD;
8111 nghttp2_stream *stream;
8113 stream = nghttp2_session_get_stream(session, stream_id);
8115 if (!stream) {
8119 return (stream->shut_flags & NGHTTP2_SHUT_WR) != 0;
8124 nghttp2_stream *stream;
8126 stream = nghttp2_session_get_stream(session, stream_id);
8128 if (!stream) {
8132 return (stream->shut_flags & NGHTTP2_SHUT_RD) != 0;
8138 nghttp2_stream *stream;
8154 stream = nghttp2_session_get_stream(session, stream_id);
8156 if (!stream) {
8160 rv = session_update_stream_consumed_size(session, stream, size);
8188 nghttp2_stream *stream;
8198 stream = nghttp2_session_get_stream(session, stream_id);
8200 if (!stream) {
8204 rv = session_update_stream_consumed_size(session, stream, size);
8261 nghttp2_stream *stream;
8272 stream = nghttp2_session_get_stream_raw(session, stream_id);
8273 if (!stream) {
8280 rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec_copy);
8287 so that idle stream created by this function, and existing ones
8288 are kept for application. We will adjust number of idle stream
8297 nghttp2_stream *stream;
8309 stream = nghttp2_session_get_stream_raw(session, stream_id);
8310 if (stream) {
8317 stream =
8320 if (!stream) {
8325 so that idle stream created by this function, and existing ones
8326 are kept for application. We will adjust number of idle stream
8349 nghttp2_stream *stream;
8364 stream = nghttp2_session_get_stream_raw(session, stream_id);
8365 if (!stream) {
8374 stream->flags |= NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES;
8377 return session_update_stream_priority(session, stream,