Allow application to call nghttp2_submit_data() in on_frame_send_callback
Previously we always call on_frame_send_callback before calling nghttp2_stream_detach_data() after sending DATA frame. As a result, even if DATA frame has END_STREAM, application cannot call nghttp2_submit_data() in on_frame_send_callback because previous data is still attached. This commit makes a change so that nghttp2_stream_detach_data() is called before on_frame_send_callback so that application can issue nghttp2_submit_data() in the callback.
This commit is contained in:
parent
82bc7198e6
commit
93b4d9efc3
|
@ -2109,15 +2109,6 @@ static int session_after_frame_sent(nghttp2_session *session)
|
||||||
stream->remote_window_size -= data_frame->hd.length;
|
stream->remote_window_size -= data_frame->hd.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(session->callbacks.on_frame_send_callback) {
|
|
||||||
nghttp2_frame public_data_frame;
|
|
||||||
nghttp2_frame_data_init(&public_data_frame.data, data_frame);
|
|
||||||
rv = session_call_on_frame_send(session, &public_data_frame);
|
|
||||||
if(nghttp2_is_fatal(rv)) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(stream && data_frame->eof) {
|
if(stream && data_frame->eof) {
|
||||||
rv = nghttp2_stream_detach_data(stream, &session->ob_pq,
|
rv = nghttp2_stream_detach_data(stream, &session->ob_pq,
|
||||||
session->last_cycle);
|
session->last_cycle);
|
||||||
|
@ -2126,6 +2117,18 @@ static int session_after_frame_sent(nghttp2_session *session)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Call on_frame_send_callback after
|
||||||
|
nghttp2_stream_detach_data(), so that application can issue
|
||||||
|
nghttp2_submit_data() in the callback. */
|
||||||
|
if(session->callbacks.on_frame_send_callback) {
|
||||||
|
nghttp2_frame public_data_frame;
|
||||||
|
nghttp2_frame_data_init(&public_data_frame.data, data_frame);
|
||||||
|
rv = session_call_on_frame_send(session, &public_data_frame);
|
||||||
|
if(nghttp2_is_fatal(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(data_frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
|
if(data_frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
|
||||||
int stream_closed;
|
int stream_closed;
|
||||||
|
|
||||||
|
@ -2143,7 +2146,15 @@ static int session_after_frame_sent(nghttp2_session *session)
|
||||||
stream = NULL;
|
stream = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(session->callbacks.on_frame_send_callback) {
|
||||||
|
nghttp2_frame public_data_frame;
|
||||||
|
nghttp2_frame_data_init(&public_data_frame.data, data_frame);
|
||||||
|
rv = session_call_on_frame_send(session, &public_data_frame);
|
||||||
|
if(nghttp2_is_fatal(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If session is closed or RST_STREAM was queued, we won't send
|
/* If session is closed or RST_STREAM was queued, we won't send
|
||||||
further data. */
|
further data. */
|
||||||
if(data_frame->eof ||
|
if(data_frame->eof ||
|
||||||
|
|
Loading…
Reference in New Issue