From 4a78f59e7b1635de8ef0bb16528ad74098557b46 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 23 Jan 2016 14:47:39 +0900 Subject: [PATCH] Rename nghttp2_session.sent_stream_id as last_sent_stream_id This is more accurate, and there is symmetric relation between last_sent_stream_id and last_recv_stream_id, which is bettern fit in my sense. --- lib/nghttp2_session.c | 12 ++++++------ lib/nghttp2_session.h | 2 +- tests/nghttp2_session_test.c | 4 ++-- tests/nghttp2_test_helper.c | 6 ++++-- tests/nghttp2_test_helper.h | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 26fc8f79..e42e46b8 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -130,7 +130,7 @@ static int session_detect_idle_stream(nghttp2_session *session, int32_t stream_id) { /* Assume that stream object with stream_id does not exist */ if (nghttp2_session_is_my_stream_id(session, stream_id)) { - if (session->sent_stream_id < stream_id) { + if (session->last_sent_stream_id < stream_id) { return 1; } return 0; @@ -1872,8 +1872,8 @@ static int session_prep_frame(nghttp2_session *session, nghttp2_bufs_len(&session->aob.framebufs))); if (frame->headers.cat == NGHTTP2_HCAT_REQUEST) { - assert(session->sent_stream_id < frame->hd.stream_id); - session->sent_stream_id = frame->hd.stream_id; + assert(session->last_sent_stream_id < frame->hd.stream_id); + session->last_sent_stream_id = frame->hd.stream_id; } break; @@ -1945,9 +1945,9 @@ static int session_prep_frame(nghttp2_session *session, return rv; } - assert(session->sent_stream_id + 2 <= + assert(session->last_sent_stream_id + 2 <= frame->push_promise.promised_stream_id); - session->sent_stream_id = frame->push_promise.promised_stream_id; + session->last_sent_stream_id = frame->push_promise.promised_stream_id; break; } @@ -6569,7 +6569,7 @@ static int nghttp2_session_upgrade_internal(nghttp2_session *session, session->last_proc_stream_id = 1; } else { nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR); - session->sent_stream_id = 1; + session->last_sent_stream_id = 1; session->next_stream_id += 2; } return 0; diff --git a/lib/nghttp2_session.h b/lib/nghttp2_session.h index 11f0b7cc..204aea91 100644 --- a/lib/nghttp2_session.h +++ b/lib/nghttp2_session.h @@ -249,7 +249,7 @@ struct nghttp2_session { /* The last stream ID this session initiated. For client session, this is the last stream ID it has sent. For server session, it is the last promised stream ID sent in PUSH_PROMISE. */ - int32_t sent_stream_id; + int32_t last_sent_stream_id; /* The largest stream ID received so far */ int32_t last_recv_stream_id; /* The largest stream ID which has been processed in some way. This diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 56d38b87..bd07b822 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -2194,7 +2194,7 @@ void test_nghttp2_session_on_request_headers_received(void) { nghttp2_session_client_new(&session, &callbacks, &user_data); session->next_stream_id = 5; - session->sent_stream_id = 3; + session->last_sent_stream_id = 3; /* Stream ID which is not idle and not in stream map is just ignored */ @@ -3544,7 +3544,7 @@ void test_nghttp2_session_upgrade2(void) { nghttp2_session_client_new(&session, &callbacks, NULL); CU_ASSERT(0 == nghttp2_session_upgrade2(session, settings_payload, settings_payloadlen, 0, &callbacks)); - CU_ASSERT(1 == session->sent_stream_id); + CU_ASSERT(1 == session->last_sent_stream_id); stream = nghttp2_session_get_stream(session, 1); CU_ASSERT(stream != NULL); CU_ASSERT(&callbacks == stream->stream_user_data); diff --git a/tests/nghttp2_test_helper.c b/tests/nghttp2_test_helper.c index b21e5e45..ed92f132 100644 --- a/tests/nghttp2_test_helper.c +++ b/tests/nghttp2_test_helper.c @@ -335,7 +335,8 @@ nghttp2_stream *open_sent_stream3(nghttp2_session *session, int32_t stream_id, stream = nghttp2_session_open_stream(session, stream_id, flags, pri_spec_in, initial_state, stream_user_data); - session->sent_stream_id = nghttp2_max(session->sent_stream_id, stream_id); + session->last_sent_stream_id = + nghttp2_max(session->last_sent_stream_id, stream_id); session->next_stream_id = nghttp2_max(session->next_stream_id, (uint32_t)stream_id + 2); @@ -359,7 +360,8 @@ nghttp2_stream *open_sent_stream_with_dep_weight(nghttp2_session *session, stream = open_stream_with_all(session, stream_id, weight, 0, dep_stream); - session->sent_stream_id = nghttp2_max(session->sent_stream_id, stream_id); + session->last_sent_stream_id = + nghttp2_max(session->last_sent_stream_id, stream_id); session->next_stream_id = nghttp2_max(session->next_stream_id, (uint32_t)stream_id + 2); diff --git a/tests/nghttp2_test_helper.h b/tests/nghttp2_test_helper.h index f23625b8..135f6ed8 100644 --- a/tests/nghttp2_test_helper.h +++ b/tests/nghttp2_test_helper.h @@ -111,8 +111,8 @@ nghttp2_stream *open_stream_with_dep_excl(nghttp2_session *session, nghttp2_outbound_item *create_data_ob_item(nghttp2_mem *mem); /* Opens stream. This stream is assumed to be sent from |session|, - and session->sent_stream_id and session->next_stream_id will be - adjusted accordingly. */ + and session->last_sent_stream_id and session->next_stream_id will + be adjusted accordingly. */ nghttp2_stream *open_sent_stream(nghttp2_session *session, int32_t stream_id); nghttp2_stream *open_sent_stream2(nghttp2_session *session, int32_t stream_id,