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.
This commit is contained in:
Tatsuhiro Tsujikawa 2016-01-23 14:47:39 +09:00
parent 1f7032088d
commit 4a78f59e7b
5 changed files with 15 additions and 13 deletions

View File

@ -130,7 +130,7 @@ static int session_detect_idle_stream(nghttp2_session *session,
int32_t stream_id) { int32_t stream_id) {
/* Assume that stream object with stream_id does not exist */ /* Assume that stream object with stream_id does not exist */
if (nghttp2_session_is_my_stream_id(session, stream_id)) { 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 1;
} }
return 0; return 0;
@ -1872,8 +1872,8 @@ static int session_prep_frame(nghttp2_session *session,
nghttp2_bufs_len(&session->aob.framebufs))); nghttp2_bufs_len(&session->aob.framebufs)));
if (frame->headers.cat == NGHTTP2_HCAT_REQUEST) { if (frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
assert(session->sent_stream_id < frame->hd.stream_id); assert(session->last_sent_stream_id < frame->hd.stream_id);
session->sent_stream_id = frame->hd.stream_id; session->last_sent_stream_id = frame->hd.stream_id;
} }
break; break;
@ -1945,9 +1945,9 @@ static int session_prep_frame(nghttp2_session *session,
return rv; return rv;
} }
assert(session->sent_stream_id + 2 <= assert(session->last_sent_stream_id + 2 <=
frame->push_promise.promised_stream_id); 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; break;
} }
@ -6569,7 +6569,7 @@ static int nghttp2_session_upgrade_internal(nghttp2_session *session,
session->last_proc_stream_id = 1; session->last_proc_stream_id = 1;
} else { } else {
nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR); nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);
session->sent_stream_id = 1; session->last_sent_stream_id = 1;
session->next_stream_id += 2; session->next_stream_id += 2;
} }
return 0; return 0;

View File

@ -249,7 +249,7 @@ struct nghttp2_session {
/* The last stream ID this session initiated. For client session, /* The last stream ID this session initiated. For client session,
this is the last stream ID it has sent. For server session, it this is the last stream ID it has sent. For server session, it
is the last promised stream ID sent in PUSH_PROMISE. */ 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 */ /* The largest stream ID received so far */
int32_t last_recv_stream_id; int32_t last_recv_stream_id;
/* The largest stream ID which has been processed in some way. This /* The largest stream ID which has been processed in some way. This

View File

@ -2194,7 +2194,7 @@ void test_nghttp2_session_on_request_headers_received(void) {
nghttp2_session_client_new(&session, &callbacks, &user_data); nghttp2_session_client_new(&session, &callbacks, &user_data);
session->next_stream_id = 5; 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 /* Stream ID which is not idle and not in stream map is just
ignored */ ignored */
@ -3544,7 +3544,7 @@ void test_nghttp2_session_upgrade2(void) {
nghttp2_session_client_new(&session, &callbacks, NULL); nghttp2_session_client_new(&session, &callbacks, NULL);
CU_ASSERT(0 == nghttp2_session_upgrade2(session, settings_payload, CU_ASSERT(0 == nghttp2_session_upgrade2(session, settings_payload,
settings_payloadlen, 0, &callbacks)); 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); stream = nghttp2_session_get_stream(session, 1);
CU_ASSERT(stream != NULL); CU_ASSERT(stream != NULL);
CU_ASSERT(&callbacks == stream->stream_user_data); CU_ASSERT(&callbacks == stream->stream_user_data);

View File

@ -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, stream = nghttp2_session_open_stream(session, stream_id, flags, pri_spec_in,
initial_state, stream_user_data); 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 = session->next_stream_id =
nghttp2_max(session->next_stream_id, (uint32_t)stream_id + 2); 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); 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 = session->next_stream_id =
nghttp2_max(session->next_stream_id, (uint32_t)stream_id + 2); nghttp2_max(session->next_stream_id, (uint32_t)stream_id + 2);

View File

@ -111,8 +111,8 @@ nghttp2_stream *open_stream_with_dep_excl(nghttp2_session *session,
nghttp2_outbound_item *create_data_ob_item(nghttp2_mem *mem); nghttp2_outbound_item *create_data_ob_item(nghttp2_mem *mem);
/* Opens stream. This stream is assumed to be sent from |session|, /* Opens stream. This stream is assumed to be sent from |session|,
and session->sent_stream_id and session->next_stream_id will be and session->last_sent_stream_id and session->next_stream_id will
adjusted accordingly. */ be adjusted accordingly. */
nghttp2_stream *open_sent_stream(nghttp2_session *session, int32_t stream_id); nghttp2_stream *open_sent_stream(nghttp2_session *session, int32_t stream_id);
nghttp2_stream *open_sent_stream2(nghttp2_session *session, int32_t stream_id, nghttp2_stream *open_sent_stream2(nghttp2_session *session, int32_t stream_id,