Add int return value to nghttp2_on_invalid_frame_recv_callback

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-29 21:12:43 +09:00
parent a59cd3be82
commit fb7d22fcb9
5 changed files with 27 additions and 14 deletions

View File

@ -783,7 +783,7 @@ typedef ssize_t (*nghttp2_recv_callback)
* 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
* return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
* immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
*/
typedef int (*nghttp2_on_frame_recv_callback)
(nghttp2_session *session, nghttp2_frame *frame, void *user_data);
@ -796,8 +796,13 @@ typedef int (*nghttp2_on_frame_recv_callback)
* :enum:`nghttp2_error_code` and indicates the error. When this
* callback function is invoked, the library automatically submits
* either RST_STREAM or GOAWAY frame.
*
* 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_invalid_frame_recv_callback)
typedef int (*nghttp2_on_invalid_frame_recv_callback)
(nghttp2_session *session, nghttp2_frame *frame, nghttp2_error_code error_code,
void *user_data);

View File

@ -1649,8 +1649,10 @@ static int nghttp2_session_handle_invalid_stream
return r;
}
if(session->callbacks.on_invalid_frame_recv_callback) {
session->callbacks.on_invalid_frame_recv_callback
(session, frame, error_code, session->user_data);
if(session->callbacks.on_invalid_frame_recv_callback
(session, frame, error_code, session->user_data) != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
return 0;
}
@ -1664,8 +1666,10 @@ static int nghttp2_session_handle_invalid_connection
nghttp2_error_code error_code)
{
if(session->callbacks.on_invalid_frame_recv_callback) {
session->callbacks.on_invalid_frame_recv_callback
(session, frame, error_code, session->user_data);
if(session->callbacks.on_invalid_frame_recv_callback
(session, frame, error_code, session->user_data) != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
return nghttp2_session_fail_session(session, error_code);
}
@ -2254,8 +2258,10 @@ int nghttp2_session_on_push_promise_received(nghttp2_session *session,
}
} else {
if(session->callbacks.on_invalid_frame_recv_callback) {
session->callbacks.on_invalid_frame_recv_callback
(session, frame, NGHTTP2_PROTOCOL_ERROR, session->user_data);
if(session->callbacks.on_invalid_frame_recv_callback
(session, frame, NGHTTP2_PROTOCOL_ERROR, session->user_data) != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
return nghttp2_session_add_rst_stream
(session,

View File

@ -333,7 +333,7 @@ int on_frame_recv_callback
return 0;
}
void on_invalid_frame_recv_callback
int on_invalid_frame_recv_callback
(nghttp2_session *session, nghttp2_frame *frame,
nghttp2_error_code error_code, void *user_data)
{
@ -341,6 +341,7 @@ void on_invalid_frame_recv_callback
printf(" [INVALID; status=%s] recv ", strstatus(error_code));
print_frame(PRINT_RECV, frame);
fflush(stdout);
return 0;
}
namespace {

View File

@ -42,7 +42,7 @@ void print_nv(char **nv);
int on_frame_recv_callback
(nghttp2_session *session, nghttp2_frame *frame, void *user_data);
void on_invalid_frame_recv_callback
int on_invalid_frame_recv_callback
(nghttp2_session *session, nghttp2_frame *frame,
nghttp2_error_code error_code, void *user_data);

View File

@ -135,13 +135,14 @@ static int on_frame_recv_callback(nghttp2_session *session,
return 0;
}
static void on_invalid_frame_recv_callback(nghttp2_session *session,
nghttp2_frame *frame,
nghttp2_error_code error_code,
void *user_data)
static int on_invalid_frame_recv_callback(nghttp2_session *session,
nghttp2_frame *frame,
nghttp2_error_code error_code,
void *user_data)
{
my_user_data *ud = (my_user_data*)user_data;
++ud->invalid_frame_recv_cb_called;
return 0;
}
static void on_frame_send_callback(nghttp2_session *session,