Don't send WINDOW_UPDATE automatically if SPDYLAY_OPT_NO_AUTO_WINDOW_UPDATE

is set.
This commit is contained in:
Tatsuhiro Tsujikawa 2012-05-08 23:29:24 +09:00
parent d6a03f74b7
commit fa04757ff4
1 changed files with 20 additions and 13 deletions

View File

@ -2255,7 +2255,8 @@ static int spdylay_session_process_data_frame(spdylay_session *session)
/* /*
* Accumulates received bytes |delta_size| and decides whether to send * Accumulates received bytes |delta_size| and decides whether to send
* WINDOW_UPDATE. * WINDOW_UPDATE. If SPDYLAY_OPT_NO_AUTO_WINDOW_UPDATE is set,
* WINDOW_UPDATE will not be sent.
* *
* This function returns 0 if it succeeds, or one of the following * This function returns 0 if it succeeds, or one of the following
* negative error codes: * negative error codes:
@ -2270,19 +2271,25 @@ static int spdylay_session_update_recv_window_size(spdylay_session *session,
spdylay_stream *stream; spdylay_stream *stream;
stream = spdylay_session_get_stream(session, stream_id); stream = spdylay_session_get_stream(session, stream_id);
if(stream) { if(stream) {
/* TODO If SPDYLAY_OPT_NO_AUTO_WINDOW_UPDATE is set and the
application does not send WINDOW_UPDATE and the remote endpoint
keeps sending data, stream->recv_window_size will eventually
overflow. */
stream->recv_window_size += delta_size; stream->recv_window_size += delta_size;
/* This is just a heuristics. */ if(!(session->opt_flags & SPDYLAY_OPTMASK_NO_AUTO_WINDOW_UPDATE)) {
/* We have to use local_settings here because it is the constraint /* This is just a heuristics. */
the remote endpoint should honor. */ /* We have to use local_settings here because it is the constraint
if((size_t)stream->recv_window_size*2 >= the remote endpoint should honor. */
session->local_settings[SPDYLAY_SETTINGS_INITIAL_WINDOW_SIZE]) { if((size_t)stream->recv_window_size*2 >=
int r; session->local_settings[SPDYLAY_SETTINGS_INITIAL_WINDOW_SIZE]) {
r = spdylay_session_add_window_update(session, stream_id, int r;
stream->recv_window_size); r = spdylay_session_add_window_update(session, stream_id,
if(r == 0) { stream->recv_window_size);
stream->recv_window_size = 0; if(r == 0) {
} else { stream->recv_window_size = 0;
return r; } else {
return r;
}
} }
} }
} }