Add int return value to nghttp2_before_frame_send_callback

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-29 21:45:10 +09:00
parent 544ac9f61f
commit a51cdaacfc
3 changed files with 17 additions and 9 deletions

View File

@ -850,8 +850,13 @@ typedef int (*nghttp2_on_data_recv_callback)
* HEADERS and PUSH_PROMISE frame (see also
* `nghttp2_session_get_stream_user_data()`), which is not assigned
* when it was queued.
*
* The implementation of this function must return 0 if it
* succeeds. If nonzero is returned, it is treated as fatal error and
* `nghttp2_session_recv()` and `nghttp2_session_send()` functions
* immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
*/
typedef void (*nghttp2_before_frame_send_callback)
typedef int (*nghttp2_before_frame_send_callback)
(nghttp2_session *session, nghttp2_frame *frame, void *user_data);
/**

View File

@ -1496,10 +1496,12 @@ int nghttp2_session_send(nghttp2_session *session)
/* Call before_send callback */
if(item->frame_cat == NGHTTP2_CAT_CTRL &&
session->callbacks.before_frame_send_callback) {
session->callbacks.before_frame_send_callback
(session,
nghttp2_outbound_item_get_ctrl_frame(item),
session->user_data);
if(session->callbacks.before_frame_send_callback
(session,
nghttp2_outbound_item_get_ctrl_frame(item),
session->user_data) != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
}
data = session->aob.framebuf + session->aob.framebufoff;

View File

@ -945,9 +945,9 @@ int on_data_chunk_recv_callback(nghttp2_session *session,
} // namespace
namespace {
void before_frame_send_callback(nghttp2_session *session,
nghttp2_frame *frame,
void *user_data)
int before_frame_send_callback(nghttp2_session *session,
nghttp2_frame *frame,
void *user_data)
{
if(frame->hd.type == NGHTTP2_HEADERS &&
frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
@ -956,7 +956,7 @@ void before_frame_send_callback(nghttp2_session *session,
if(!sd || !sd->dconn) {
nghttp2_submit_rst_stream(session, frame->hd.stream_id,
NGHTTP2_CANCEL);
return;
return 0;
}
auto downstream = sd->dconn->get_downstream();
if(downstream) {
@ -965,6 +965,7 @@ void before_frame_send_callback(nghttp2_session *session,
nghttp2_submit_rst_stream(session, frame->hd.stream_id, NGHTTP2_CANCEL);
}
}
return 0;
}
} // namespace