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;
728 nghttp2_stream *stream;
734 stream = (nghttp2_stream *)entry;
735 item = stream->item;
742 nghttp2_stream_free(stream);
743 nghttp2_mem_free(mem, stream);
815 stream->item->queued */
832 nghttp2_session *session, nghttp2_stream *stream,
841 assert(pri_spec->stream_id != stream->stream_id);
843 if (!nghttp2_stream_in_dep_tree(stream)) {
870 } else if (nghttp2_stream_dep_find_ancestor(dep_stream, stream)) {
871 DEBUGF("stream: cycle detected, dep_stream(%p)=%d stream(%p)=%d\n",
872 dep_stream, dep_stream->stream_id, stream, stream->stream_id);
875 rv = nghttp2_stream_dep_add_subtree(stream->dep_prev, dep_stream);
883 if (dep_stream == stream->dep_prev && !pri_spec->exclusive) {
885 nghttp2_stream_change_weight(stream, pri_spec->weight);
890 nghttp2_stream_dep_remove_subtree(stream);
892 /* We have to update weight after removing stream from tree */
893 stream->weight = pri_spec->weight;
896 rv = nghttp2_stream_dep_insert_subtree(dep_stream, stream);
898 rv = nghttp2_stream_dep_add_subtree(dep_stream, stream);
909 nghttp2_stream *stream;
915 stream = nghttp2_struct_of(nghttp2_pq_top(pq), nghttp2_stream, pq_entry);
916 return stream->cycle;
920 nghttp2_stream *stream) {
926 assert(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES);
927 assert(stream->queued == 0);
929 urgency = nghttp2_extpri_uint8_urgency(stream->extpri);
930 inc = nghttp2_extpri_uint8_inc(stream->extpri);
936 stream->cycle = pq_get_first_cycle(pq);
938 stream->cycle += stream->last_writelen;
941 rv = nghttp2_pq_push(pq, &stream->pq_entry);
946 stream->queued = 1;
952 nghttp2_stream *stream) {
955 assert(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES);
956 assert(stream->queued == 1);
958 urgency = nghttp2_extpri_uint8_urgency(stream->extpri);
962 nghttp2_pq_remove(&session->sched[urgency].ob_data, &stream->pq_entry);
964 stream->queued = 0;
968 nghttp2_stream *stream,
972 rv = nghttp2_stream_attach_item(stream, item);
977 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES)) {
981 return session_ob_data_push(session, stream);
985 nghttp2_stream *stream) {
986 nghttp2_stream_detach_item(stream);
988 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) ||
989 !stream->queued) {
993 session_ob_data_remove(session, stream);
997 nghttp2_stream *stream, uint8_t flags) {
998 nghttp2_stream_defer_item(stream, flags);
1000 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) ||
1001 !stream->queued) {
1005 session_ob_data_remove(session, stream);
1009 nghttp2_stream *stream,
1013 rv = nghttp2_stream_resume_deferred_item(stream, flags);
1018 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) ||
1019 (stream->flags & NGHTTP2_STREAM_FLAG_DEFERRED_ALL)) {
1023 return session_ob_data_push(session, stream);
1030 nghttp2_stream *stream;
1038 stream = nghttp2_struct_of(ent, nghttp2_stream, pq_entry);
1039 return stream->item;
1058 nghttp2_stream *stream) {
1060 uint32_t urgency = nghttp2_extpri_uint8_urgency(stream->extpri);
1061 int inc = nghttp2_extpri_uint8_inc(stream->extpri);
1062 uint64_t penalty = (uint64_t)stream->last_writelen;
1075 nghttp2_pq_remove(pq, &stream->pq_entry);
1077 stream->cycle += penalty;
1079 rv = nghttp2_pq_push(pq, &stream->pq_entry);
1085 nghttp2_stream *stream,
1087 if (stream->extpri == u8extpri) {
1091 if (stream->queued) {
1092 session_ob_data_remove(session, stream);
1094 stream->extpri = u8extpri;
1096 return session_ob_data_push(session, stream);
1099 stream->extpri = u8extpri;
1106 /* TODO Return error if stream is not found for the frame requiring
1107 stream presence. */
1109 nghttp2_stream *stream;
1113 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
1117 if (!stream) {
1121 if (stream->item) {
1125 rv = session_attach_stream_item(session, stream, item);
1136 /* TODO If 2 HEADERS are submitted for reserved stream, then
1140 (stream && stream->state == NGHTTP2_STREAM_RESERVED)) {
1156 if (stream) {
1157 stream->state = NGHTTP2_STREAM_CLOSING;
1168 if (!stream) {
1172 nghttp2_priority_spec_init(&pri_spec, stream->stream_id,
1183 here, since stream->stream_id is local stream_id, and it does
1184 not affect closed stream count. */
1192 if (stream) {
1193 stream->window_update_queued = 1;
1212 nghttp2_stream *stream;
1216 stream = nghttp2_session_get_stream(session, stream_id);
1217 if (stream && stream->state == NGHTTP2_STREAM_CLOSING) {
1221 /* Sending RST_STREAM to an idle stream is subject to protocol
1234 refers to that stream. */
1291 nghttp2_stream *stream;
1299 stream = nghttp2_session_get_stream_raw(session, stream_id);
1306 if (stream) {
1307 assert(stream->state == NGHTTP2_STREAM_IDLE);
1308 assert((stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) ||
1309 nghttp2_stream_in_dep_tree(stream));
1311 if (nghttp2_stream_in_dep_tree(stream)) {
1312 assert(!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES));
1313 nghttp2_session_detach_idle_stream(session, stream);
1314 rv = nghttp2_stream_dep_remove(stream);
1320 stream->flags |= NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES;
1324 stream = nghttp2_mem_malloc(mem, sizeof(nghttp2_stream));
1325 if (stream == NULL) {
1351 /* Depends on idle stream, which does not exist in memory.
1361 nghttp2_mem_free(mem, stream);
1367 /* If dep_stream is not part of dependency tree, stream will get
1370 don't check pri_spec->stream_id against new stream ID in
1372 stream created by PRIORITY frame was opened. Somehow we
1373 first remove the idle stream from dependency tree. This is
1386 nghttp2_stream_init(stream, stream_id, flags, initial_state,
1393 stream->seq = session->stream_seq++;
1396 rv = nghttp2_map_insert(&session->streams, stream_id, stream);
1398 nghttp2_stream_free(stream);
1399 nghttp2_mem_free(mem, stream);
1403 stream->flags = flags;
1404 stream->state = initial_state;
1405 stream->weight = pri_spec->weight;
1406 stream->stream_user_data = stream_user_data;
1413 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
1416 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
1419 /* Reserved stream does not count in the concurrent streams
1423 /* Idle stream does not count toward the concurrent streams limit.
1425 nghttp2_session_keep_idle_stream(session, stream);
1435 if (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) {
1436 return stream;
1446 rv = nghttp2_stream_dep_insert(dep_stream, stream);
1451 nghttp2_stream_dep_add(dep_stream, stream);
1454 return stream;
1460 nghttp2_stream *stream;
1465 stream = nghttp2_session_get_stream(session, stream_id);
1467 if (!stream) {
1471 DEBUGF("stream: stream(%p)=%d close\n", stream, stream->stream_id);
1473 if (stream->item) {
1476 item = stream->item;
1478 session_detach_stream_item(session, stream);
1490 /* We call on_stream_close_callback even if stream->state is
1492 HEADERS, a local endpoint receives RST_STREAM for that stream. It
1493 may be PROTOCOL_ERROR, but without notifying stream closure will
1494 hang the stream in a local endpoint.
1509 if ((stream->flags & NGHTTP2_STREAM_FLAG_PUSH)) {
1522 stream->flags |= NGHTTP2_STREAM_FLAG_CLOSED;
1525 return nghttp2_session_destroy_stream(session, stream);
1530 nghttp2_stream_in_dep_tree(stream)) {
1531 /* On server side, retain stream at most MAX_CONCURRENT_STREAMS
1534 nghttp2_session_keep_closed_stream(session, stream);
1536 rv = nghttp2_session_destroy_stream(session, stream);
1546 nghttp2_stream *stream) {
1550 DEBUGF("stream: destroy closed stream(%p)=%d\n", stream, stream->stream_id);
1554 if (nghttp2_stream_in_dep_tree(stream)) {
1555 rv = nghttp2_stream_dep_remove(stream);
1561 nghttp2_map_remove(&session->streams, stream->stream_id);
1562 nghttp2_stream_free(stream);
1563 nghttp2_mem_free(mem, stream);
1569 nghttp2_stream *stream) {
1570 DEBUGF("stream: keep closed stream(%p)=%d, state=%d\n", stream,
1571 stream->stream_id, stream->state);
1574 session->closed_stream_tail->closed_next = stream;
1575 stream->closed_prev = session->closed_stream_tail;
1577 session->closed_stream_head = stream;
1579 session->closed_stream_tail = stream;
1585 nghttp2_stream *stream) {
1586 DEBUGF("stream: keep idle stream(%p)=%d, state=%d\n", stream,
1587 stream->stream_id, stream->state);
1590 session->idle_stream_tail->closed_next = stream;
1591 stream->closed_prev = session->idle_stream_tail;
1593 session->idle_stream_head = stream;
1595 session->idle_stream_tail = stream;
1601 nghttp2_stream *stream) {
1604 DEBUGF("stream: detach idle stream(%p)=%d, state=%d\n", stream,
1605 stream->stream_id, stream->state);
1607 prev_stream = stream->closed_prev;
1608 next_stream = stream->closed_next;
1622 stream->closed_prev = NULL;
1623 stream->closed_next = NULL;
1639 DEBUGF("stream: adjusting kept closed streams num_closed_streams=%zu, "
1688 DEBUGF("stream: adjusting kept idle streams num_idle_streams=%zu, max=%zu\n",
1722 * Closes stream with stream ID |stream_id| if both transmission and
1723 * reception of the stream were disallowed. The |error_code| indicates
1730 * The stream is not found.
1735 nghttp2_stream *stream) {
1736 if ((stream->shut_flags & NGHTTP2_SHUT_RDWR) == NGHTTP2_SHUT_RDWR) {
1737 return nghttp2_session_close_stream(session, stream->stream_id,
1744 * Returns nonzero if local endpoint allows reception of new stream
1762 * Check that we can send a frame to the |stream|. This function
1767 * The stream is already closed.
1769 * The stream is half-closed for transmission.
1774 nghttp2_stream *stream) {
1775 if (stream == NULL) {
1781 if (stream->shut_flags & NGHTTP2_SHUT_WR) {
1794 * This function checks request HEADERS frame, which opens stream, can
1801 * New stream cannot be created because of GOAWAY: session is
1824 * server, with the |stream| can be sent at this time. The |stream|
1831 * The stream is already closed or does not exist.
1833 * The transmission is not allowed for this stream (e.g., a frame
1836 * The stream ID is invalid.
1838 * RST_STREAM was queued for this stream.
1840 * The state of the stream is not valid.
1847 nghttp2_stream *stream) {
1849 rv = session_predicate_for_stream_send(session, stream);
1853 assert(stream);
1857 if (nghttp2_session_is_my_stream_id(session, stream->stream_id)) {
1860 switch (stream->state) {
1871 * This function checks HEADERS for reserved stream can be sent. The
1872 * |stream| must be reserved state and the |session| is server side.
1873 * The |stream| can be NULL.
1879 * The stream is already closed.
1881 * The stream is half-closed for transmission.
1883 * The stream is not reserved state
1885 * RST_STREAM was queued for this stream.
1889 * New stream cannot be created because GOAWAY is already sent or
1896 nghttp2_stream *stream) {
1899 rv = session_predicate_for_stream_send(session, stream);
1903 assert(stream);
1907 if (stream->state != NGHTTP2_STREAM_RESERVED) {
1917 * This function checks HEADERS, which is neither stream-opening nor
1918 * first response header, with the |stream| can be sent at this time.
1919 * The |stream| can be NULL.
1925 * The stream is already closed or does not exist.
1927 * The transmission is not allowed for this stream (e.g., a frame
1930 * RST_STREAM was queued for this stream.
1932 * The state of the stream is not valid.
1937 nghttp2_stream *stream) {
1939 rv = session_predicate_for_stream_send(session, stream);
1943 assert(stream);
1945 switch (stream->state) {
1951 if (nghttp2_session_is_my_stream_id(session, stream->stream_id)) {
1959 * This function checks PUSH_PROMISE frame |frame| with the |stream|
1960 * can be sent at this time. The |stream| can be NULL.
1966 * New stream cannot be created because GOAWAY is already sent or
1970 * sends PUSH_PROMISE for the stream not initiated by the client.
1972 * The stream is already closed or does not exist.
1974 * RST_STREAM was queued for this stream.
1976 * The transmission is not allowed for this stream (e.g., a frame
1984 nghttp2_stream *stream) {
1991 rv = session_predicate_for_stream_send(session, stream);
1996 assert(stream);
2001 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2011 * This function checks WINDOW_UPDATE with the stream ID |stream_id|
2019 * The stream is already closed or does not exist.
2021 * RST_STREAM was queued for this stream.
2023 * The state of the stream is not valid.
2029 nghttp2_stream *stream;
2039 stream = nghttp2_session_get_stream(session, stream_id);
2040 if (stream == NULL) {
2043 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2046 if (state_reserved_local(session, stream)) {
2054 nghttp2_stream *stream;
2064 stream = nghttp2_session_get_stream(session, stream_id);
2065 if (stream == NULL) {
2068 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2084 nghttp2_stream *stream;
2090 stream = nghttp2_session_get_stream(session, stream_id);
2091 if (stream == NULL) {
2094 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2097 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
2108 nghttp2_stream *stream,
2111 "stream(id %d)=%d\n",
2113 stream->stream_id, stream->remote_window_size);
2116 stream->remote_window_size),
2123 * connection-level and/or stream-wise flow control are enabled, the
2128 nghttp2_stream *stream) {
2132 session, stream, NGHTTP2_DATA_PAYLOADLEN);
2140 * This function checks DATA with the |stream| can be sent at this
2141 * time. The |stream| can be NULL.
2147 * The stream is already closed or does not exist.
2149 * The transmission is not allowed for this stream (e.g., a frame
2152 * RST_STREAM was queued for this stream.
2154 * The state of the stream is not valid.
2159 nghttp2_stream *stream) {
2161 rv = session_predicate_for_stream_send(session, stream);
2165 assert(stream);
2166 if (nghttp2_session_is_my_stream_id(session, stream->stream_id)) {
2168 /* If stream->state is NGHTTP2_STREAM_CLOSING, RST_STREAM was
2171 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2174 if (stream->state == NGHTTP2_STREAM_RESERVED) {
2180 if (stream->state == NGHTTP2_STREAM_OPENED) {
2183 if (stream->state == NGHTTP2_STREAM_CLOSING) {
2311 nghttp2_stream *stream;
2313 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2315 if (stream) {
2316 assert(stream->item == item);
2319 rv = nghttp2_session_predicate_data_send(session, stream);
2321 // If stream was already closed, nghttp2_session_get_stream()
2322 // returns NULL, but item is still attached to the stream.
2323 // Search stream including closed again.
2324 stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id);
2325 if (stream) {
2326 session_detach_stream_item(session, stream);
2331 /* Assuming stream is not NULL */
2332 assert(stream);
2333 next_readmax = nghttp2_session_next_data_read(session, stream);
2341 session_defer_stream_item(session, stream,
2351 stream);
2356 session_defer_stream_item(session, stream,
2364 session_detach_stream_item(session, stream);
2374 session_detach_stream_item(session, stream);
2387 /* initial HEADERS, which opens stream */
2388 nghttp2_stream *stream;
2390 stream = nghttp2_session_open_stream(
2395 if (stream == NULL) {
2400 since we don't keep closed stream in client side */
2408 nghttp2_http_record_request_method(stream, frame);
2411 nghttp2_stream *stream;
2413 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2415 if (stream && stream->state == NGHTTP2_STREAM_RESERVED) {
2416 rv = session_predicate_push_response_headers_send(session, stream);
2421 stream->stream_user_data = aux_data->stream_user_data;
2424 } else if (session_predicate_response_headers_send(session, stream) ==
2431 rv = session_predicate_headers_send(session, stream);
2477 /* PRIORITY frame can be sent at any time and to any stream
2481 /* Peer can send PRIORITY frame against idle stream to create
2484 or idle) streams in memory, so we don't open stream here. */
2513 nghttp2_stream *stream;
2516 /* stream could be NULL if associated stream was already
2518 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2520 /* predicate should fail if stream is NULL. */
2521 rv = session_predicate_push_promise_send(session, stream);
2526 assert(stream);
2742 nghttp2_stream *stream;
2745 stream = (nghttp2_stream *)entry;
2747 if (nghttp2_session_is_my_stream_id(arg->session, stream->stream_id)) {
2755 if (stream->state != NGHTTP2_STREAM_IDLE &&
2756 (stream->flags & NGHTTP2_STREAM_FLAG_CLOSED) == 0 &&
2757 stream->stream_id > arg->last_stream_id) {
2761 assert(stream->closed_next == NULL);
2762 assert(stream->closed_prev == NULL);
2765 stream->closed_next = arg->head;
2766 arg->head = stream;
2768 arg->head = stream;
2775 /* Closes non-idle and non-closed streams whose stream ID >
2782 nghttp2_stream *stream, *next_stream;
2789 stream = arg.head;
2790 while (stream) {
2791 next_stream = stream->closed_next;
2792 stream->closed_next = NULL;
2793 rv = nghttp2_session_close_stream(session, stream->stream_id,
2796 /* stream may be deleted here */
2798 stream = next_stream;
2802 while (stream) {
2803 next_stream = stream->closed_next;
2804 stream->closed_next = NULL;
2805 stream = next_stream;
2815 nghttp2_stream *stream) {
2816 stream->last_writelen = stream->item->frame.hd.length;
2818 if (!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES)) {
2819 nghttp2_stream_reschedule(stream);
2827 session_sched_reschedule_stream(session, stream);
2831 nghttp2_stream *stream,
2839 * on_frame_send_callback and handles stream closure upon END_STREAM
2857 nghttp2_stream *stream;
2866 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2871 if (stream) {
2872 stream->remote_window_size -= (int32_t)frame->hd.length;
2875 if (stream && aux_data->eof) {
2876 session_detach_stream_item(session, stream);
2892 (stream->shut_flags & NGHTTP2_SHUT_RDWR) == NGHTTP2_SHUT_RDWR;
2894 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
2896 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
2900 /* stream may be NULL if it was closed */
2902 stream = NULL;
2935 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
2936 if (!stream) {
2942 stream->state = NGHTTP2_STREAM_OPENING;
2944 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
2946 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
2959 /* TODO nghttp2_submit_data() may fail if stream has already
2965 stream->flags = (uint8_t)(stream->flags & ~NGHTTP2_STREAM_FLAG_PUSH);
2969 stream->state = NGHTTP2_STREAM_OPENED;
2973 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
2975 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
2987 /* TODO nghttp2_submit_data() may fail if stream has already
3002 stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id);
3004 if (!stream) {
3009 stream = nghttp2_session_open_stream(
3012 if (!stream) {
3016 rv = nghttp2_session_reprioritize_stream(session, stream,
3076 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
3077 if (!stream) {
3081 stream->window_update_queued = 0;
3085 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
3090 rv = session_update_stream_consumed_size(session, stream, 0);
3093 nghttp2_session_update_recv_stream_window_size(session, stream, 0, 1);
3116 nghttp2_stream *stream;
3149 which attach data to stream. We don't want to detach it. */
3159 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
3163 if (nghttp2_session_predicate_data_send(session, stream) != 0) {
3164 if (stream) {
3165 session_detach_stream_item(session, stream);
3271 /* We have to close stream opened by failed request HEADERS
3346 /* We have to close stream opened by canceled request
3431 nghttp2_stream *stream;
3439 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
3440 if (stream == NULL) {
3441 DEBUGF("send: no copy DATA cancelled because stream was closed\n");
3454 session_detach_stream_item(session, stream);
3524 /* We have to call session_after_frame_sent1 here to handle stream
3862 * stream should be RST_STREAMed.
3877 nghttp2_stream *stream;
3882 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
3888 subject_stream = stream;
3889 trailer = session_trailer_headers(session, stream, frame);
3904 from invoking subsequent callbacks for the same stream
3955 "%u, stream: %d, name: [%.*s], value: [%.*s]",
3973 "%u, stream: %d, name: [%.*s], value: [%.*s]",
4024 nghttp2_stream *stream) {
4031 (stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES) &&
4032 !(stream->flags & NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES) &&
4033 (stream->http_flags & NGHTTP2_HTTP_FLAG_PRIORITY)) {
4034 rv = session_update_stream_priority(session, stream, stream->http_extpri);
4045 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
4046 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
4057 nghttp2_stream *stream;
4059 /* We don't call on_frame_recv_callback if stream has been closed
4061 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
4062 if (!stream || stream->state == NGHTTP2_STREAM_CLOSING) {
4079 rv = nghttp2_http_on_request_headers(stream, frame);
4083 rv = nghttp2_http_on_response_headers(stream);
4086 if (stream->http_flags & NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE) {
4088 rv = nghttp2_http_on_response_headers(stream);
4090 rv = nghttp2_http_on_trailer_headers(stream, frame);
4097 rv = nghttp2_http_on_remote_end_stream(stream);
4117 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
4134 return session_end_stream_headers_received(session, frame, stream);
4140 nghttp2_stream *stream;
4146 /* If client receives idle stream from server, it is invalid
4147 regardless stream ID is even or odd. This is because client is
4170 * stream ID (e.g, numerically smaller than previous), it MUST
4177 * share the complete picture of open/closed stream status. For
4178 * example, after server sends RST_STREAM for a stream, client may
4179 * send trailer HEADERS for that stream. If naive server detects
4185 * connection error if stream ID refers idle stream, or we are
4186 * sure that stream is half-closed(remote) or closed. Otherwise
4189 stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id);
4190 if (stream && (stream->shut_flags & NGHTTP2_SHUT_RD)) {
4192 session, frame, NGHTTP2_ERR_STREAM_CLOSED, "HEADERS: stream closed");
4206 /* We just ignore stream after GOAWAY was sent */
4220 stream = nghttp2_session_open_stream(
4223 if (!stream) {
4243 nghttp2_stream *stream) {
4245 /* This function is only called if stream->state ==
4247 assert(stream->state == NGHTTP2_STREAM_OPENING &&
4253 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
4256 If an endpoint receives additional frames for a stream that is
4257 in this state it MUST respond with a stream error (Section
4263 session, frame, NGHTTP2_ERR_STREAM_CLOSED, "HEADERS: stream closed");
4265 stream->state = NGHTTP2_STREAM_OPENED;
4275 nghttp2_stream *stream) {
4277 assert(stream->state == NGHTTP2_STREAM_RESERVED);
4297 /* We don't accept new stream after GOAWAY was sent. */
4306 nghttp2_stream_promise_fulfilled(stream);
4307 if (!nghttp2_session_is_my_stream_id(session, stream->stream_id)) {
4320 nghttp2_stream *stream) {
4326 if ((stream->shut_flags & NGHTTP2_SHUT_RD)) {
4329 If an endpoint receives additional frames for a stream that is
4330 in this state it MUST respond with a stream error (Section
4336 session, frame, NGHTTP2_ERR_STREAM_CLOSED, "HEADERS: stream closed");
4339 if (stream->state == NGHTTP2_STREAM_OPENED) {
4349 /* If this is remote peer initiated stream, it is OK unless it
4350 has sent END_STREAM frame already. But if stream is in
4353 if (stream->state != NGHTTP2_STREAM_CLOSING) {
4366 nghttp2_stream *stream;
4370 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
4371 if (!stream) {
4376 if (stream->state == NGHTTP2_STREAM_RESERVED) {
4379 stream);
4382 if (stream->state == NGHTTP2_STREAM_OPENING &&
4385 return nghttp2_session_on_response_headers_received(session, frame, stream);
4389 return nghttp2_session_on_headers_received(session, frame, stream);
4395 nghttp2_stream *stream;
4414 stream = nghttp2_session_get_stream_raw(session, frame->hd.stream_id);
4416 if (!stream) {
4417 /* PRIORITY against idle stream can create anchor node in
4423 stream = nghttp2_session_open_stream(
4427 if (stream == NULL) {
4436 rv = nghttp2_session_reprioritize_stream(session, stream,
4483 nghttp2_stream *stream;
4491 "RST_STREAM: stream in idle");
4494 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
4495 if (stream) {
4496 /* We may use stream->shut_flags for strict error checking. */
4497 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
4525 nghttp2_stream *stream;
4528 stream = (nghttp2_stream *)entry;
4531 stream, arg->new_window_size, arg->old_window_size);
4533 return nghttp2_session_add_rst_stream(arg->session, stream->stream_id,
4539 if (stream->remote_window_size > 0 &&
4540 nghttp2_stream_check_deferred_by_flow_control(stream)) {
4543 arg->session, stream, NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL);
4578 nghttp2_stream *stream;
4580 stream = (nghttp2_stream *)entry;
4582 stream, arg->new_window_size, arg->old_window_size);
4584 return nghttp2_session_add_rst_stream(arg->session, stream->stream_id,
4588 if (stream->window_update_queued) {
4593 return session_update_stream_consumed_size(arg->session, stream, 0);
4596 if (nghttp2_should_send_window_update(stream->local_window_size,
4597 stream->recv_window_size)) {
4600 stream->stream_id,
4601 stream->recv_window_size);
4606 stream->recv_window_size = 0;
4966 nghttp2_stream *stream;
4992 illegal stream ID is subject to a connection error of type
5001 session, frame, NGHTTP2_ERR_PROTO, "PUSH_PROMISE: stream in idle");
5005 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
5006 if (!stream || stream->state == NGHTTP2_STREAM_CLOSING ||
5010 /* Currently, client does not retain closed stream, so we don't
5021 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
5024 "PUSH_PROMISE: stream closed");
5027 nghttp2_priority_spec_init(&pri_spec, stream->stream_id,
5039 don't keep closed stream in client side */
5097 last stream identifier. */
5156 nghttp2_stream *stream;
5160 "WINDOW_UPDATE to idle stream");
5163 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
5164 if (!stream) {
5167 if (state_reserved_remote(session, stream)) {
5169 session, frame, NGHTTP2_ERR_PROTO, "WINDOW_UPADATE to reserved stream");
5177 stream->remote_window_size) {
5181 stream->remote_window_size += frame->window_update.window_size_increment;
5183 if (stream->remote_window_size > 0 &&
5184 nghttp2_stream_check_deferred_by_flow_control(stream)) {
5187 session, stream, NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL);
5218 nghttp2_stream *stream;
5235 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
5236 if (!stream) {
5240 if (stream->state == NGHTTP2_STREAM_CLOSING) {
5261 nghttp2_stream *stream;
5282 /* TODO Ignore priority signal to a push stream for now */
5286 stream = nghttp2_session_get_stream_raw(session, priority_update->stream_id);
5287 if (stream) {
5289 if (stream->flags & NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES) {
5301 stream = nghttp2_session_open_stream(session, priority_update->stream_id,
5304 if (!stream) {
5321 rv = session_update_stream_priority(session, stream,
5397 nghttp2_stream *stream;
5399 /* We don't call on_frame_recv_callback if stream has been closed
5401 stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
5402 if (!stream || stream->state == NGHTTP2_STREAM_CLOSING) {
5403 /* This should be treated as stream error, but it results in lots
5404 of RST_STREAM. So just ignore frame against nonexistent stream
5411 if (nghttp2_http_on_remote_end_stream(stream) != 0) {
5412 rv = nghttp2_session_add_rst_stream(session, stream->stream_id,
5418 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
5431 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
5432 rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);
5472 nghttp2_stream *stream,
5476 rv = adjust_recv_window_size(&stream->recv_window_size, delta_size,
5477 stream->local_window_size);
5479 return nghttp2_session_add_rst_stream(session, stream->stream_id,
5483 last chunk in the incoming stream. */
5488 stream->window_update_queued == 0 &&
5489 nghttp2_should_send_window_update(stream->local_window_size,
5490 stream->recv_window_size)) {
5492 stream->stream_id,
5493 stream->recv_window_size);
5498 stream->recv_window_size = 0;
5516 /* Use stream ID 0 to update connection-level flow control
5568 nghttp2_stream *stream,
5571 session, &stream->consumed_size, &stream->recv_window_size,
5572 stream->window_update_queued, stream->stream_id, delta_size,
5573 stream->local_window_size);
5584 * Checks that we can receive the DATA frame for stream, which is
5602 nghttp2_stream *stream;
5612 /* The spec says that if a DATA frame is received whose stream ID
5620 failure_reason = "DATA: stream in idle";
5625 stream = nghttp2_session_get_stream(session, stream_id);
5626 if (!stream) {
5627 stream = nghttp2_session_get_stream_raw(session, stream_id);
5628 if (stream && (stream->shut_flags & NGHTTP2_SHUT_RD)) {
5629 failure_reason = "DATA: stream closed";
5636 if (stream->shut_flags & NGHTTP2_SHUT_RD) {
5637 failure_reason = "DATA: stream in half-closed(remote)";
5643 if (stream->state == NGHTTP2_STREAM_CLOSING) {
5646 if (stream->state != NGHTTP2_STREAM_OPENED) {
5647 failure_reason = "DATA: stream not opened";
5652 if (stream->state == NGHTTP2_STREAM_RESERVED) {
5653 failure_reason = "DATA: stream in reserved";
5656 if (stream->state == NGHTTP2_STREAM_CLOSING) {
5818 nghttp2_stream *stream;
5941 /* Check stream is open. If it is not open or closing,
6508 if (padlen < 0 || (size_t)padlen + 4 /* promised stream id */
6580 /* 8 is Last-stream-ID + Error Code */
6725 /* Use promised stream ID for PUSH_PROMISE */
6989 stream = nghttp2_session_get_stream(session, iframe->frame.hd.stream_id);
6990 if (stream) {
6992 session, stream, readlen,
7018 stream = nghttp2_session_get_stream(session, iframe->frame.hd.stream_id);
7020 if (!stream) {
7049 session, stream, readlen,
7084 if (nghttp2_http_on_data_chunk(stream, (size_t)data_readlen) != 0) {
7361 * response HEADERS and concurrent stream limit is reached, we don't
7606 here. We use it to refuse the incoming stream and PUSH_PROMISE
7642 nghttp2_stream *stream) {
7657 session, frame->hd.type, stream->stream_id, session->remote_window_size,
7658 stream->remote_window_size, session->remote_settings.max_frame_size,
7663 payloadlen = nghttp2_session_enforce_flow_control_limits(session, stream,
7761 session_reschedule_stream(session, stream);
7776 nghttp2_stream *stream;
7777 stream = nghttp2_session_get_stream(session, stream_id);
7778 if (stream) {
7779 return stream->stream_user_data;
7788 nghttp2_stream *stream;
7792 stream = nghttp2_session_get_stream(session, stream_id);
7793 if (stream) {
7794 stream->stream_user_data = stream_user_data;
7829 nghttp2_stream *stream;
7830 stream = nghttp2_session_get_stream(session, stream_id);
7831 if (stream == NULL || !nghttp2_stream_check_deferred_item(stream)) {
7835 rv = session_resume_deferred_stream_item(session, stream,
7849 /* TODO account for item attached to stream */
7855 nghttp2_stream *stream;
7856 stream = nghttp2_session_get_stream(session, stream_id);
7857 if (stream == NULL) {
7860 return stream->recv_window_size < 0 ? 0 : stream->recv_window_size;
7866 nghttp2_stream *stream;
7867 stream = nghttp2_session_get_stream(session, stream_id);
7868 if (stream == NULL) {
7871 return stream->local_window_size;
7876 nghttp2_stream *stream;
7878 stream = nghttp2_session_get_stream(session, stream_id);
7879 if (stream == NULL) {
7883 size = stream->local_window_size - stream->recv_window_size;
7910 nghttp2_stream *stream;
7912 stream = nghttp2_session_get_stream(session, stream_id);
7913 if (stream == NULL) {
7917 /* stream->remote_window_size can be negative when
7919 return nghttp2_max(0, stream->remote_window_size);
7980 nghttp2_stream *stream;
8024 stream = nghttp2_session_open_stream(
8027 if (stream == NULL) {
8032 should be the first stream open. */
8035 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
8039 nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
8051 nghttp2_stream *stream;
8059 stream = nghttp2_session_get_stream(session, 1);
8060 assert(stream);
8071 stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_UPGRADE_WORKAROUND;
8080 nghttp2_stream *stream;
8088 stream = nghttp2_session_get_stream(session, 1);
8089 assert(stream);
8092 stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_HEAD;
8100 nghttp2_stream *stream;
8102 stream = nghttp2_session_get_stream(session, stream_id);
8104 if (!stream) {
8108 return (stream->shut_flags & NGHTTP2_SHUT_WR) != 0;
8113 nghttp2_stream *stream;
8115 stream = nghttp2_session_get_stream(session, stream_id);
8117 if (!stream) {
8121 return (stream->shut_flags & NGHTTP2_SHUT_RD) != 0;
8127 nghttp2_stream *stream;
8143 stream = nghttp2_session_get_stream(session, stream_id);
8145 if (!stream) {
8149 rv = session_update_stream_consumed_size(session, stream, size);
8177 nghttp2_stream *stream;
8187 stream = nghttp2_session_get_stream(session, stream_id);
8189 if (!stream) {
8193 rv = session_update_stream_consumed_size(session, stream, size);
8250 nghttp2_stream *stream;
8261 stream = nghttp2_session_get_stream_raw(session, stream_id);
8262 if (!stream) {
8269 rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec_copy);
8276 so that idle stream created by this function, and existing ones
8277 are kept for application. We will adjust number of idle stream
8286 nghttp2_stream *stream;
8298 stream = nghttp2_session_get_stream_raw(session, stream_id);
8299 if (stream) {
8306 stream =
8309 if (!stream) {
8314 so that idle stream created by this function, and existing ones
8315 are kept for application. We will adjust number of idle stream
8338 nghttp2_stream *stream;
8353 stream = nghttp2_session_get_stream_raw(session, stream_id);
8354 if (!stream) {
8363 stream->flags |= NGHTTP2_STREAM_FLAG_IGNORE_CLIENT_PRIORITIES;
8366 return session_update_stream_priority(session, stream,