Add int return value to on_data_send_callback

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-29 21:55:04 +09:00
parent b9d2f9b6b0
commit 5a7f65f1f7
5 changed files with 20 additions and 11 deletions

View File

@ -893,8 +893,13 @@ typedef int (*nghttp2_on_frame_not_send_callback)
* @functypedef * @functypedef
* *
* Callback function invoked after DATA frame is sent. * Callback function invoked after DATA frame is sent.
*
* 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_on_data_send_callback) typedef int (*nghttp2_on_data_send_callback)
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id, (nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data); void *user_data);

View File

@ -1355,13 +1355,15 @@ static int nghttp2_session_after_frame_sent(nghttp2_session *session)
nghttp2_data *data_frame; nghttp2_data *data_frame;
data_frame = nghttp2_outbound_item_get_data_frame(session->aob.item); data_frame = nghttp2_outbound_item_get_data_frame(session->aob.item);
if(session->callbacks.on_data_send_callback) { if(session->callbacks.on_data_send_callback) {
session->callbacks.on_data_send_callback if(session->callbacks.on_data_send_callback
(session, (session,
session->aob.framebuflen - NGHTTP2_FRAME_HEAD_LENGTH, session->aob.framebuflen - NGHTTP2_FRAME_HEAD_LENGTH,
data_frame->eof ? data_frame->hd.flags : data_frame->eof ? data_frame->hd.flags :
(data_frame->hd.flags & (~NGHTTP2_FLAG_END_STREAM)), (data_frame->hd.flags & (~NGHTTP2_FLAG_END_STREAM)),
data_frame->hd.stream_id, data_frame->hd.stream_id,
session->user_data); session->user_data) != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
} }
if(data_frame->eof && (data_frame->hd.flags & NGHTTP2_FLAG_END_STREAM)) { if(data_frame->eof && (data_frame->hd.flags & NGHTTP2_FLAG_END_STREAM)) {
nghttp2_stream *stream = nghttp2_stream *stream =

View File

@ -778,7 +778,7 @@ int hd_on_data_recv_callback
} // namespace } // namespace
namespace { namespace {
void hd_on_data_send_callback int hd_on_data_send_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id, (nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data) void *user_data)
{ {
@ -787,6 +787,7 @@ void hd_on_data_send_callback
print_session_id(hd->session_id()); print_session_id(hd->session_id());
on_data_send_callback(session, length, flags, stream_id, user_data); on_data_send_callback(session, length, flags, stream_id, user_data);
} }
return 0;
} }
} // namespace } // namespace

View File

@ -425,7 +425,7 @@ int on_data_recv_callback
return 0; return 0;
} }
void on_data_send_callback int on_data_send_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id, (nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data) void *user_data)
{ {
@ -433,6 +433,7 @@ void on_data_send_callback
printf(" send "); printf(" send ");
print_data_frame(PRINT_SEND, length, flags, stream_id); print_data_frame(PRINT_SEND, length, flags, stream_id);
fflush(stdout); fflush(stdout);
return 0;
} }
int64_t time_delta(const timeval& a, const timeval& b) int64_t time_delta(const timeval& a, const timeval& b)

View File

@ -68,7 +68,7 @@ int on_data_recv_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id, (nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data); void *user_data);
void on_data_send_callback int on_data_send_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id, (nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data); void *user_data);