Commit ae93f634 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Allow PRIORITY frame at anytime.

Allowing PRIORITY frame at anytime so that PRIORITY frame to idle
stream can create anchor node in dependency tree.  In this change, we
open stream with new NGHTTP2_STREAM_IDLE state, which is linked in
session->closed_stream_head and is treated as if it is closed stream.
One difference is that if the stream is opened, we remove it from
linked list and change the state to the appropriate one.  To O(1)
removal from linked list, we change session->closed_stream_head to
doubly linked list.
parent 9bba6164
This diff is collapsed.
......@@ -425,6 +425,12 @@ void nghttp2_session_destroy_stream(nghttp2_session *session,
void nghttp2_session_keep_closed_stream(nghttp2_session *session,
nghttp2_stream *stream);
/*
* Detaches |stream| from closed streams linked list.
*/
void nghttp2_session_detach_closed_stream(nghttp2_session *session,
nghttp2_stream *stream);
/*
* Deletes closed stream to ensure that number of incoming streams
* including active and closed is in the maximum number of allowed
......@@ -644,7 +650,8 @@ nghttp2_stream* nghttp2_session_get_stream(nghttp2_session *session,
/*
* This function behaves like nghttp2_session_get_stream(), but it
* returns stream object even if it is marked as closed.
* returns stream object even if it is marked as closed or in
* NGHTTP2_STREAM_IDLE state.
*/
nghttp2_stream* nghttp2_session_get_stream_raw(nghttp2_session *session,
int32_t stream_id);
......
......@@ -57,6 +57,7 @@ void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id,
stream->sib_prev = NULL;
stream->sib_next = NULL;
stream->closed_prev = NULL;
stream->closed_next = NULL;
stream->dpri = NGHTTP2_STREAM_DPRI_NO_DATA;
......
......@@ -65,7 +65,10 @@ typedef enum {
memory. */
NGHTTP2_STREAM_CLOSING,
/* PUSH_PROMISE is received or sent */
NGHTTP2_STREAM_RESERVED
NGHTTP2_STREAM_RESERVED,
/* Stream is created in this state if it is used as anchor in
dependency tree. */
NGHTTP2_STREAM_IDLE
} nghttp2_stream_state;
typedef enum {
......@@ -126,11 +129,11 @@ struct nghttp2_stream {
doubly-linked list and first element is pointed by
roots->head. */
nghttp2_stream *root_prev, *root_next;
/* When stream is kept after closure, it may be kept in single
/* When stream is kept after closure, it may be kept in doubly
linked list pointed by nghttp2_session closed_stream_head.
closed_next points to the next stream object if it is the element
of the list. */
nghttp2_stream *closed_next;
nghttp2_stream *closed_prev, *closed_next;
/* pointer to roots, which tracks dependency tree roots */
nghttp2_stream_roots *roots;
/* The arbitrary data provided by user for this stream. */
......
......@@ -243,6 +243,8 @@ int main(int argc, char* argv[])
test_nghttp2_session_stream_attach_data_subtree) ||
!CU_add_test(pSuite, "session_stream_keep_closed_stream",
test_nghttp2_session_keep_closed_stream) ||
!CU_add_test(pSuite, "session_detach_closed_stream",
test_nghttp2_session_detach_closed_stream) ||
!CU_add_test(pSuite, "session_large_dep_tree",
test_nghttp2_session_large_dep_tree) ||
!CU_add_test(pSuite, "session_graceful_shutdown",
......@@ -253,6 +255,8 @@ int main(int argc, char* argv[])
test_nghttp2_session_recv_client_preface) ||
!CU_add_test(pSuite, "session_delete_data_item",
test_nghttp2_session_delete_data_item) ||
!CU_add_test(pSuite, "session_open_idle_stream",
test_nghttp2_session_open_idle_stream) ||
!CU_add_test(pSuite, "frame_pack_headers",
test_nghttp2_frame_pack_headers) ||
!CU_add_test(pSuite, "frame_pack_headers_frame_too_large",
......
This diff is collapsed.
......@@ -111,10 +111,12 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void);
void test_nghttp2_session_stream_attach_data(void);
void test_nghttp2_session_stream_attach_data_subtree(void);
void test_nghttp2_session_keep_closed_stream(void);
void test_nghttp2_session_detach_closed_stream(void);
void test_nghttp2_session_large_dep_tree(void);
void test_nghttp2_session_graceful_shutdown(void);
void test_nghttp2_session_on_header_temporal_failure(void);
void test_nghttp2_session_recv_client_preface(void);
void test_nghttp2_session_delete_data_item(void);
void test_nghttp2_session_open_idle_stream(void);
#endif /* NGHTTP2_SESSION_TEST_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment