Add int return value to nghttp2_on_frame_recv_parse_error_callback

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-29 23:07:07 +09:00
parent 053c444769
commit db4f519500
6 changed files with 34 additions and 24 deletions

View File

@ -950,8 +950,13 @@ typedef int (*nghttp2_on_request_recv_callback)
* The |payloadlen| is the length of the |payload|. This is the data * The |payloadlen| is the length of the |payload|. This is the data
* after the length field. The |lib_error_code| is one of the error code * after the length field. The |lib_error_code| is one of the error code
* defined in :enum:`nghttp2_error` and indicates the error. * defined in :enum:`nghttp2_error` and indicates the error.
*
* 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_frame_recv_parse_error_callback) typedef int (*nghttp2_on_frame_recv_parse_error_callback)
(nghttp2_session *session, nghttp2_frame_type type, (nghttp2_session *session, nghttp2_frame_type type,
const uint8_t *head, size_t headlen, const uint8_t *head, size_t headlen,
const uint8_t *payload, size_t payloadlen, const uint8_t *payload, size_t payloadlen,

View File

@ -1681,7 +1681,7 @@ static int nghttp2_session_handle_parse_error(nghttp2_session *session,
nghttp2_error_code error_code) nghttp2_error_code error_code)
{ {
if(session->callbacks.on_frame_recv_parse_error_callback) { if(session->callbacks.on_frame_recv_parse_error_callback) {
session->callbacks.on_frame_recv_parse_error_callback if(session->callbacks.on_frame_recv_parse_error_callback
(session, (session,
type, type,
session->iframe.headbuf, session->iframe.headbuf,
@ -1689,7 +1689,9 @@ static int nghttp2_session_handle_parse_error(nghttp2_session *session,
session->iframe.buf, session->iframe.buf,
session->iframe.buflen, session->iframe.buflen,
lib_error_code, lib_error_code,
session->user_data); session->user_data) != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
} }
return nghttp2_session_fail_session(session, error_code); return nghttp2_session_fail_session(session, error_code);
} }

View File

@ -357,7 +357,7 @@ void dump_header(const uint8_t *head, size_t headlen)
} }
} // namespace } // namespace
void on_frame_recv_parse_error_callback(nghttp2_session *session, int on_frame_recv_parse_error_callback(nghttp2_session *session,
nghttp2_frame_type type, nghttp2_frame_type type,
const uint8_t *head, const uint8_t *head,
size_t headlen, size_t headlen,
@ -374,6 +374,7 @@ void on_frame_recv_parse_error_callback(nghttp2_session *session,
printf("Error: %s\n", nghttp2_strerror(error_code)); printf("Error: %s\n", nghttp2_strerror(error_code));
dump_header(head, headlen); dump_header(head, headlen);
fflush(stdout); fflush(stdout);
return 0;
} }
void on_unknown_frame_recv_callback(nghttp2_session *session, void on_unknown_frame_recv_callback(nghttp2_session *session,

View File

@ -46,7 +46,7 @@ int on_invalid_frame_recv_callback
(nghttp2_session *session, nghttp2_frame *frame, (nghttp2_session *session, nghttp2_frame *frame,
nghttp2_error_code error_code, void *user_data); nghttp2_error_code error_code, void *user_data);
void on_frame_recv_parse_error_callback(nghttp2_session *session, int on_frame_recv_parse_error_callback(nghttp2_session *session,
nghttp2_frame_type type, nghttp2_frame_type type,
const uint8_t *head, const uint8_t *head,
size_t headlen, size_t headlen,

View File

@ -354,7 +354,7 @@ int on_frame_not_send_callback(nghttp2_session *session,
} // namespace } // namespace
namespace { namespace {
void on_frame_recv_parse_error_callback(nghttp2_session *session, int on_frame_recv_parse_error_callback(nghttp2_session *session,
nghttp2_frame_type type, nghttp2_frame_type type,
const uint8_t *head, size_t headlen, const uint8_t *head, size_t headlen,
const uint8_t *payload, const uint8_t *payload,
@ -368,6 +368,7 @@ void on_frame_recv_parse_error_callback(nghttp2_session *session,
<< ", error_code=" << lib_error_code << ":" << ", error_code=" << lib_error_code << ":"
<< nghttp2_strerror(lib_error_code); << nghttp2_strerror(lib_error_code);
} }
return 0;
} }
} // namespace } // namespace

View File

@ -1005,7 +1005,7 @@ int on_frame_not_send_callback(nghttp2_session *session,
} // namespace } // namespace
namespace { namespace {
void on_frame_recv_parse_error_callback(nghttp2_session *session, int on_frame_recv_parse_error_callback(nghttp2_session *session,
nghttp2_frame_type type, nghttp2_frame_type type,
const uint8_t *head, size_t headlen, const uint8_t *head, size_t headlen,
const uint8_t *payload, const uint8_t *payload,
@ -1019,6 +1019,7 @@ void on_frame_recv_parse_error_callback(nghttp2_session *session,
<< ", lib_error_code=" << lib_error_code << ":" << ", lib_error_code=" << lib_error_code << ":"
<< nghttp2_strerror(lib_error_code); << nghttp2_strerror(lib_error_code);
} }
return 0;
} }
} // namespace } // namespace