From 53ee21caa9a3aa8d3e1dc849c05edb0f4b892923 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 23 Aug 2014 17:42:20 +0900 Subject: [PATCH] Remove nghttp2_on_unknown_frame_recv_callback It is not used by library for a while. It could be used to pass unsupported extension frames to application, but its interface requires library to buffer entire frame, which we'd like to avoid. For unsupported extension frames, we will add new callbacks which does not require buffering if they are required. --- lib/includes/nghttp2/nghttp2.h | 37 ---------------------------------- lib/nghttp2_callbacks.c | 7 ------- lib/nghttp2_callbacks.h | 5 ----- src/HttpServer.cc | 3 --- src/app_helper.cc | 27 ------------------------- src/app_helper.h | 7 ------- src/nghttp.cc | 3 --- src/shrpx_http2_session.cc | 17 ---------------- src/shrpx_http2_upstream.cc | 17 ---------------- 9 files changed, 123 deletions(-) diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h index 52cc0a0a..ad21715b 100644 --- a/lib/includes/nghttp2/nghttp2.h +++ b/lib/includes/nghttp2/nghttp2.h @@ -1321,33 +1321,6 @@ typedef int (*nghttp2_on_stream_close_callback) (nghttp2_session *session, int32_t stream_id, uint32_t error_code, void *user_data); -/** - * @functypedef - * - * Callback function invoked when the received frame type is unknown. - * The |head| is the pointer to the header of the received frame. The - * |headlen| is the length of the |head|. According to the spec, the - * |headlen| is always 8. In other words, the |head| is the first 8 - * bytes of the received frame. The |payload| is the pointer to the - * data portion of the received frame. The |payloadlen| is the length - * of the |payload|. This is the data after the length field. The - * |user_data| pointer is the third argument passed in to the call to - * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`. - * - * 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`. - * - * To set this callback to :type:`nghttp2_session_callbacks`, use - * `nghttp2_session_callbacks_set_on_unknown_frame_recv_callback()`. - */ -typedef int (*nghttp2_on_unknown_frame_recv_callback) -(nghttp2_session *session, - const uint8_t *head, size_t headlen, - const uint8_t *payload, size_t payloadlen, - void *user_data); - /** * @functypedef * @@ -1594,16 +1567,6 @@ void nghttp2_session_callbacks_set_on_stream_close_callback (nghttp2_session_callbacks *cbs, nghttp2_on_stream_close_callback on_stream_close_callback); -/** - * @function - * - * Sets callback function invoked when the received frame type is - * unknown. - */ -void nghttp2_session_callbacks_set_on_unknown_frame_recv_callback -(nghttp2_session_callbacks *cbs, - nghttp2_on_unknown_frame_recv_callback on_unknown_frame_recv_callback); - /** * @function * diff --git a/lib/nghttp2_callbacks.c b/lib/nghttp2_callbacks.c index 9af35503..9a3aa4d9 100644 --- a/lib/nghttp2_callbacks.c +++ b/lib/nghttp2_callbacks.c @@ -103,13 +103,6 @@ void nghttp2_session_callbacks_set_on_stream_close_callback cbs->on_stream_close_callback = on_stream_close_callback; } -void nghttp2_session_callbacks_set_on_unknown_frame_recv_callback -(nghttp2_session_callbacks *cbs, - nghttp2_on_unknown_frame_recv_callback on_unknown_frame_recv_callback) -{ - cbs->on_unknown_frame_recv_callback = on_unknown_frame_recv_callback; -} - void nghttp2_session_callbacks_set_on_begin_headers_callback (nghttp2_session_callbacks *cbs, nghttp2_on_begin_headers_callback on_begin_headers_callback) diff --git a/lib/nghttp2_callbacks.h b/lib/nghttp2_callbacks.h index 2057cd10..5a4792c4 100644 --- a/lib/nghttp2_callbacks.h +++ b/lib/nghttp2_callbacks.h @@ -81,11 +81,6 @@ struct nghttp2_session_callbacks { * Callback function invoked when the stream is closed. */ nghttp2_on_stream_close_callback on_stream_close_callback; - /** - * Callback function invoked when the received frame type is - * unknown. - */ - nghttp2_on_unknown_frame_recv_callback on_unknown_frame_recv_callback; /** * Callback function invoked when the reception of header block in * HEADERS or PUSH_PROMISE is started. diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 3a569195..dba97f52 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -1459,9 +1459,6 @@ void fill_callback(nghttp2_session_callbacks *callbacks, const Config *config) if(config->verbose) { nghttp2_session_callbacks_set_on_invalid_frame_recv_callback (callbacks, verbose_on_invalid_frame_recv_callback); - - nghttp2_session_callbacks_set_on_unknown_frame_recv_callback - (callbacks, verbose_on_unknown_frame_recv_callback); } nghttp2_session_callbacks_set_on_data_chunk_recv_callback diff --git a/src/app_helper.cc b/src/app_helper.cc index 21697b00..18e21519 100644 --- a/src/app_helper.cc +++ b/src/app_helper.cc @@ -473,33 +473,6 @@ int verbose_on_invalid_frame_recv_callback return 0; } -namespace { -void dump_header(const uint8_t *head, size_t headlen) -{ - size_t i; - print_frame_attr_indent(); - fprintf(outfile, "Header dump: "); - for(i = 0; i < headlen; ++i) { - fprintf(outfile, "%02X ", head[i]); - } - fprintf(outfile, "\n"); -} -} // namespace - -int verbose_on_unknown_frame_recv_callback(nghttp2_session *session, - const uint8_t *head, - size_t headlen, - const uint8_t *payload, - size_t payloadlen, - void *user_data) -{ - print_timer(); - fprintf(outfile, " recv unknown frame\n"); - dump_header(head, headlen); - fflush(outfile); - return 0; -} - int verbose_on_frame_send_callback (nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { diff --git a/src/app_helper.h b/src/app_helper.h index 4d547e3d..4a551942 100644 --- a/src/app_helper.h +++ b/src/app_helper.h @@ -53,13 +53,6 @@ int verbose_on_invalid_frame_recv_callback (nghttp2_session *session, const nghttp2_frame *frame, uint32_t error_code, void *user_data); -int verbose_on_unknown_frame_recv_callback(nghttp2_session *session, - const uint8_t *head, - size_t headlen, - const uint8_t *payload, - size_t payloadlen, - void *user_data); - int verbose_on_frame_send_callback (nghttp2_session *session, const nghttp2_frame *frame, void *user_data); diff --git a/src/nghttp.cc b/src/nghttp.cc index 651effe1..a3146d10 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -1847,9 +1847,6 @@ int run(char **uris, int n) nghttp2_session_callbacks_set_on_invalid_frame_recv_callback (callbacks, verbose_on_invalid_frame_recv_callback); - - nghttp2_session_callbacks_set_on_unknown_frame_recv_callback - (callbacks, verbose_on_unknown_frame_recv_callback); } nghttp2_session_callbacks_set_on_data_chunk_recv_callback diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index d17bf5a3..ca8aebfc 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -1345,20 +1345,6 @@ int on_frame_not_send_callback(nghttp2_session *session, } } // namespace -namespace { -int on_unknown_frame_recv_callback(nghttp2_session *session, - const uint8_t *head, size_t headlen, - const uint8_t *payload, size_t payloadlen, - void *user_data) -{ - auto http2session = static_cast(user_data); - if(LOG_ENABLED(INFO)) { - SSLOG(INFO, http2session) << "Received unknown control frame"; - } - return 0; -} -} // namespace - int Http2Session::on_connect() { int rv; @@ -1414,9 +1400,6 @@ int Http2Session::on_connect() nghttp2_session_callbacks_set_on_frame_not_send_callback (callbacks, on_frame_not_send_callback); - nghttp2_session_callbacks_set_on_unknown_frame_recv_callback - (callbacks, on_unknown_frame_recv_callback); - nghttp2_session_callbacks_set_on_header_callback (callbacks, on_header_callback); diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 7649720d..4a1be731 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -607,20 +607,6 @@ int on_frame_not_send_callback(nghttp2_session *session, } } // namespace -namespace { -int on_unknown_frame_recv_callback(nghttp2_session *session, - const uint8_t *head, size_t headlen, - const uint8_t *payload, size_t payloadlen, - void *user_data) -{ - auto upstream = static_cast(user_data); - if(LOG_ENABLED(INFO)) { - ULOG(INFO, upstream) << "Received unknown control frame."; - } - return 0; -} -} // namespace - namespace { uint32_t infer_upstream_rst_stream_error_code(uint32_t downstream_error_code) { @@ -669,9 +655,6 @@ Http2Upstream::Http2Upstream(ClientHandler *handler) nghttp2_session_callbacks_set_on_frame_not_send_callback (callbacks, on_frame_not_send_callback); - nghttp2_session_callbacks_set_on_unknown_frame_recv_callback - (callbacks, on_unknown_frame_recv_callback); - nghttp2_session_callbacks_set_on_header_callback (callbacks, on_header_callback);