Commit ad64f11a authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Remove code submitting WINDOW_UPDATE with negative delta

It is effectively dead code because we should have already submit
WINDOW_UPDATE before this case happens.
parent 2e7bc014
......@@ -118,7 +118,8 @@ int nghttp2_adjust_local_window_size(int32_t *local_window_size_ptr,
*recv_window_size_ptr += recv_reduction_diff;
} else {
/* If *recv_window_size_ptr > 0, then those bytes are
considered to be backed to the remote peer, so it is
considered to be backed to the remote peer (by
WINDOW_UPDATE with the adjusted *delta_ptr), so it is
effectively 0 now. */
*recv_window_size_ptr = recv_reduction_diff;
}
......@@ -142,6 +143,7 @@ int nghttp2_adjust_local_window_size(int32_t *local_window_size_ptr,
*local_window_size_ptr += *delta_ptr;
*recv_window_size_ptr += *delta_ptr;
*recv_reduction_ptr -= *delta_ptr;
*delta_ptr = 0;
}
return 0;
}
......
......@@ -171,7 +171,8 @@ struct nghttp2_session {
current initial window size of remote endpoint. */
int32_t remote_window_size;
/* Keep track of the number of bytes received without
WINDOW_UPDATE. */
WINDOW_UPDATE. This could be negative after submitting negative
value to WINDOW_UPDATE. */
int32_t recv_window_size;
/* The amount of recv_window_size cut using submitting negative
value to WINDOW_UPDATE */
......
......@@ -113,7 +113,8 @@ typedef struct {
current initial window size of remote endpoint. */
int32_t remote_window_size;
/* Keep track of the number of bytes received without
WINDOW_UPDATE. */
WINDOW_UPDATE. This could be negative after submitting negative
value to WINDOW_UPDATE */
int32_t recv_window_size;
/* The amount of recv_window_size cut using submitting negative
value to WINDOW_UPDATE */
......
......@@ -269,14 +269,6 @@ int nghttp2_submit_window_update(nghttp2_session *session, uint8_t flags,
if(rv != 0) {
return rv;
}
if(!(session->opt_flags &
NGHTTP2_OPTMASK_NO_AUTO_CONNECTION_WINDOW_UPDATE) &&
window_size_increment < 0 &&
nghttp2_should_send_window_update(session->local_window_size,
session->recv_window_size)) {
window_size_increment = session->recv_window_size;
session->recv_window_size = 0;
}
} else {
stream = nghttp2_session_get_stream(session, stream_id);
if(stream) {
......@@ -290,14 +282,6 @@ int nghttp2_submit_window_update(nghttp2_session *session, uint8_t flags,
if(rv != 0) {
return rv;
}
if(!(session->opt_flags &
NGHTTP2_OPTMASK_NO_AUTO_STREAM_WINDOW_UPDATE) &&
window_size_increment < 0 &&
nghttp2_should_send_window_update(stream->local_window_size,
stream->recv_window_size)) {
window_size_increment = stream->recv_window_size;
stream->recv_window_size = 0;
}
} else {
return NGHTTP2_ERR_STREAM_CLOSED;
}
......
......@@ -83,7 +83,7 @@ void test_nghttp2_adjust_local_window_size(void)
CU_ASSERT(100 == local_window_size);
CU_ASSERT(-1 == recv_window_size);
CU_ASSERT(1 == recv_reduction);
CU_ASSERT(-1 == delta);
CU_ASSERT(0 == delta);
delta = 1;
CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size,
......
......@@ -2508,23 +2508,21 @@ void test_nghttp2_submit_window_update_local_window_size(void)
CU_ASSERT(0 == nghttp2_session_send(session));
/* Let's decrement local window size */
stream->recv_window_size = 65536;
stream->recv_window_size = 4096;
CU_ASSERT(0 == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2,
-stream->local_window_size / 2));
CU_ASSERT(32768 == stream->local_window_size);
CU_ASSERT(0 == stream->recv_window_size);
CU_ASSERT(-28672 == stream->recv_window_size);
CU_ASSERT(32768 == stream->recv_reduction);
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_WINDOW_UPDATE == OB_CTRL_TYPE(item));
CU_ASSERT(32768 == OB_CTRL(item)->window_update.window_size_increment);
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(item == NULL);
/* Increase local window size */
CU_ASSERT(0 == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2,
16384));
CU_ASSERT(49152 == stream->local_window_size);
CU_ASSERT(16384 == stream->recv_window_size);
CU_ASSERT(-12288 == stream->recv_window_size);
CU_ASSERT(16384 == stream->recv_reduction);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
......@@ -2548,22 +2546,20 @@ void test_nghttp2_submit_window_update_local_window_size(void)
CU_ASSERT(0 == nghttp2_session_send(session));
/* Go decrement part */
session->recv_window_size = 65536;
session->recv_window_size = 4096;
CU_ASSERT(0 == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0,
-session->local_window_size/2));
CU_ASSERT(32768 == session->local_window_size);
CU_ASSERT(0 == session->recv_window_size);
CU_ASSERT(-28672 == session->recv_window_size);
CU_ASSERT(32768 == session->recv_reduction);
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_WINDOW_UPDATE == OB_CTRL_TYPE(item));
CU_ASSERT(32768 == OB_CTRL(item)->window_update.window_size_increment);
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(item == NULL);
/* Increase local window size */
CU_ASSERT(0 == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0,
16384));
CU_ASSERT(49152 == session->local_window_size);
CU_ASSERT(16384 == session->recv_window_size);
CU_ASSERT(-12288 == session->recv_window_size);
CU_ASSERT(16384 == session->recv_reduction);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
......
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