Skip to content

Commit

Permalink
Don't call nghttp2_send_data_callback if stream has already closed
Browse files Browse the repository at this point in the history
This is more inline with other callback function invocations where if
stream was closed, they are not invoked.
  • Loading branch information
tatsuhiro-t committed Apr 5, 2015
1 parent 9eff511 commit cc03a12
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions lib/nghttp2_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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)) {
return rv;
}
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);
Expand Down Expand Up @@ -2969,6 +2977,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,

break;
}
}
}
}

Expand Down

0 comments on commit cc03a12

Please sign in to comment.