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,33 +2914,41 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
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"));
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);
if (nghttp2_is_fatal(rv)) {
return rv;
}
if (rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) {
nghttp2_stream *stream;
nghttp2_frame *frame;
rv = nghttp2_stream_detach_item(stream, session);
frame = &aob->item->frame;
if (nghttp2_is_fatal(rv)) {
return rv;
}
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
if (stream) {
rv = nghttp2_stream_detach_item(stream, session);
if (nghttp2_is_fatal(rv)) {
return rv;
}
rv = nghttp2_session_add_rst_stream(session, frame->hd.stream_id,
NGHTTP2_INTERNAL_ERROR);
if (nghttp2_is_fatal(rv)) {
return rv;
}
rv = nghttp2_session_add_rst_stream(session, frame->hd.stream_id,
NGHTTP2_INTERNAL_ERROR);
if (nghttp2_is_fatal(rv)) {
return rv;
}
active_outbound_item_reset(aob, mem);
@ -2969,6 +2977,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
break;
}
}
}
}