Don't call on_data_recv_callback and on_data_chunk_recv_callback if

stream was closed or being closed.
This commit is contained in:
Tatsuhiro Tsujikawa 2012-06-08 23:48:35 +09:00
parent 183cce1707
commit adefcad530
1 changed files with 17 additions and 8 deletions

View File

@ -2523,6 +2523,7 @@ ssize_t spdylay_session_mem_recv(spdylay_session *session,
size_t bufavail, readlen; size_t bufavail, readlen;
int32_t data_stream_id = 0; int32_t data_stream_id = 0;
uint8_t data_flags = SPDYLAY_DATA_FLAG_NONE; uint8_t data_flags = SPDYLAY_DATA_FLAG_NONE;
spdylay_stream *data_stream = NULL;
rempayloadlen = session->iframe.payloadlen - session->iframe.off; rempayloadlen = session->iframe.payloadlen - session->iframe.off;
bufavail = inlimit - inmark; bufavail = inlimit - inmark;
@ -2582,6 +2583,8 @@ ssize_t spdylay_session_mem_recv(spdylay_session *session,
data_stream_id = spdylay_get_uint32(session->iframe.headbuf) & data_stream_id = spdylay_get_uint32(session->iframe.headbuf) &
SPDYLAY_STREAM_ID_MASK; SPDYLAY_STREAM_ID_MASK;
data_flags = session->iframe.headbuf[4]; data_flags = session->iframe.headbuf[4];
data_stream = spdylay_session_get_stream(session, data_stream_id);
if(data_stream && data_stream->state != SPDYLAY_STREAM_CLOSING) {
if(session->callbacks.on_data_chunk_recv_callback) { if(session->callbacks.on_data_chunk_recv_callback) {
session->callbacks.on_data_chunk_recv_callback(session, session->callbacks.on_data_chunk_recv_callback(session,
data_flags, data_flags,
@ -2591,10 +2594,12 @@ ssize_t spdylay_session_mem_recv(spdylay_session *session,
session->user_data); session->user_data);
} }
} }
}
session->iframe.off += readlen; session->iframe.off += readlen;
inmark += readlen; inmark += readlen;
if(session->flow_control && if(session->flow_control &&
data_stream && data_stream->state != SPDYLAY_STREAM_CLOSING &&
!spdylay_frame_is_ctrl_frame(session->iframe.headbuf[0])) { !spdylay_frame_is_ctrl_frame(session->iframe.headbuf[0])) {
if(readlen > 0 && if(readlen > 0 &&
(session->iframe.payloadlen != session->iframe.off || (session->iframe.payloadlen != session->iframe.off ||
@ -2613,7 +2618,11 @@ ssize_t spdylay_session_mem_recv(spdylay_session *session,
if(spdylay_frame_is_ctrl_frame(session->iframe.headbuf[0])) { if(spdylay_frame_is_ctrl_frame(session->iframe.headbuf[0])) {
r = spdylay_session_process_ctrl_frame(session); r = spdylay_session_process_ctrl_frame(session);
} else { } else {
if(data_stream && data_stream->state != SPDYLAY_STREAM_CLOSING) {
r = spdylay_session_process_data_frame(session); r = spdylay_session_process_data_frame(session);
} else {
r = 0;
}
} }
if(r < 0) { if(r < 0) {
/* FATAL */ /* FATAL */