Don't call nghttp2_send_data_callback if stream has already closed

This is more inline with other callback function invocations where if
stream was closed, they are not invoked.
This commit is contained in:
Tatsuhiro Tsujikawa 2015-04-05 12:40:21 +09:00
parent 9eff511c5e
commit cc03a12b75
1 changed files with 26 additions and 17 deletions

View File

@ -2914,22 +2914,31 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
return datalen; return datalen;
} }
case NGHTTP2_OB_SEND_NO_COPY: case NGHTTP2_OB_SEND_NO_COPY: {
nghttp2_stream *stream;
nghttp2_frame *frame;
DEBUGF(fprintf(stderr, "send: no copy DATA\n")); DEBUGF(fprintf(stderr, "send: no copy DATA\n"));
frame = &aob->item->frame;
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
if (stream == NULL) {
DEBUGF(fprintf(
stderr,
"send: no copy DATA cancelled because stream was closed\n"));
active_outbound_item_reset(aob, mem);
break;
}
rv = session_call_send_data(session, aob->item, framebufs); rv = session_call_send_data(session, aob->item, framebufs);
if (nghttp2_is_fatal(rv)) { if (nghttp2_is_fatal(rv)) {
return rv; return rv;
} }
if (rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) { if (rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) {
nghttp2_stream *stream;
nghttp2_frame *frame;
frame = &aob->item->frame;
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
if (stream) {
rv = nghttp2_stream_detach_item(stream, session); rv = nghttp2_stream_detach_item(stream, session);
if (nghttp2_is_fatal(rv)) { if (nghttp2_is_fatal(rv)) {
@ -2941,7 +2950,6 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
if (nghttp2_is_fatal(rv)) { if (nghttp2_is_fatal(rv)) {
return rv; return rv;
} }
}
active_outbound_item_reset(aob, mem); active_outbound_item_reset(aob, mem);
@ -2970,6 +2978,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
break; break;
} }
} }
}
} }
ssize_t nghttp2_session_mem_send(nghttp2_session *session, ssize_t nghttp2_session_mem_send(nghttp2_session *session,