From b1905c58159292eda7c5e203aaab3a1dd3f5b3c4 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 4 Nov 2013 18:22:29 +0900 Subject: [PATCH] nghttpx: More replacement of spdy with http2 --- src/app_helper.h | 3 ++- src/shrpx.cc | 6 +++--- src/shrpx_client_handler.h | 2 +- src/shrpx_downstream.h | 6 +++--- src/shrpx_http2_upstream.cc | 12 ++++++------ src/shrpx_https_upstream.cc | 4 ++-- src/shrpx_log.h | 6 +++--- src/shrpx_spdy_upstream.cc | 2 +- src/shrpx_spdy_upstream.h | 2 +- 9 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/app_helper.h b/src/app_helper.h index 5d1624b7..aaf1b6fb 100644 --- a/src/app_helper.h +++ b/src/app_helper.h @@ -94,7 +94,8 @@ std::chrono::steady_clock::time_point get_time(); void print_timer(); // Setting true will print characters with ANSI color escape codes -// when printing SPDY frames. This function changes a static variable. +// when printing HTTP2 frames. This function changes a static +// variable. void set_color_output(bool f); } // namespace nghttp2 diff --git a/src/shrpx.cc b/src/shrpx.cc index 28a22ac4..73369da2 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -344,15 +344,15 @@ void fill_default_config() mod_config()->private_key_passwd = 0; mod_config()->cert_file = 0; - // Read timeout for SPDY upstream connection + // Read timeout for HTTP2 upstream connection mod_config()->http2_upstream_read_timeout.tv_sec = 180; mod_config()->http2_upstream_read_timeout.tv_usec = 0; - // Read timeout for non-SPDY upstream connection + // Read timeout for non-HTTP2 upstream connection mod_config()->upstream_read_timeout.tv_sec = 180; mod_config()->upstream_read_timeout.tv_usec = 0; - // Write timeout for SPDY/non-SPDY upstream connection + // Write timeout for HTTP2/non-HTTP2 upstream connection mod_config()->upstream_write_timeout.tv_sec = 60; mod_config()->upstream_write_timeout.tv_usec = 0; diff --git a/src/shrpx_client_handler.h b/src/shrpx_client_handler.h index 97093c6e..abbc6f99 100644 --- a/src/shrpx_client_handler.h +++ b/src/shrpx_client_handler.h @@ -84,7 +84,7 @@ private: bool should_close_after_write_; std::set dconn_pool_; // Shared HTTP2 session for each thread. NULL if backend is not - // SPDY. Not deleted by this object. + // HTTP2. Not deleted by this object. Http2Session *http2session_; // The number of bytes of HTTP/2.0 client connection header to read size_t left_connhd_len_; diff --git a/src/shrpx_downstream.h b/src/shrpx_downstream.h index b074dfd8..c78188da 100644 --- a/src/shrpx_downstream.h +++ b/src/shrpx_downstream.h @@ -58,7 +58,7 @@ public: void pause_read(IOCtrlReason reason); int resume_read(IOCtrlReason reason); void force_resume_read(); - // Set stream ID for downstream SPDY connection. + // Set stream ID for downstream HTTP2 connection. void set_downstream_stream_id(int32_t stream_id); int32_t get_downstream_stream_id() const; @@ -213,9 +213,9 @@ private: Headers response_headers_; bool response_header_key_prev_; // This buffer is used to temporarily store downstream response - // body. Spdylay reads data from this in the callback. + // body. nghttp2 library reads data from this in the callback. evbuffer *response_body_buf_; - // RST_STREAM error_code from downstream SPDY connection + // RST_STREAM error_code from downstream HTTP2 connection nghttp2_error_code response_rst_stream_error_code_; int32_t recv_window_size_; }; diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index a05cbfe1..c009197e 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -45,7 +45,7 @@ using namespace nghttp2; namespace shrpx { namespace { -const size_t SHRPX_SPDY_UPSTREAM_OUTPUT_UPPER_THRES = 64*1024; +const size_t SHRPX_HTTP2_UPSTREAM_OUTPUT_UPPER_THRES = 64*1024; } // namespace namespace { @@ -59,7 +59,7 @@ ssize_t send_callback(nghttp2_session *session, auto bev = handler->get_bev(); auto output = bufferevent_get_output(bev); // Check buffer length and return WOULDBLOCK if it is large enough. - if(evbuffer_get_length(output) > SHRPX_SPDY_UPSTREAM_OUTPUT_UPPER_THRES) { + if(evbuffer_get_length(output) > SHRPX_HTTP2_UPSTREAM_OUTPUT_UPPER_THRES) { return NGHTTP2_ERR_WOULDBLOCK; } @@ -539,7 +539,7 @@ int Http2Upstream::on_read() nghttp2_session_want_write(session_) == 0 && evbuffer_get_length(bufferevent_get_output(handler_->get_bev())) == 0) { if(LOG_ENABLED(INFO)) { - ULOG(INFO, this) << "No more read/write for this SPDY session"; + ULOG(INFO, this) << "No more read/write for this HTTP2 session"; } rv = -1; } @@ -565,7 +565,7 @@ int Http2Upstream::send() nghttp2_session_want_write(session_) == 0 && evbuffer_get_length(bufferevent_get_output(handler_->get_bev())) == 0) { if(LOG_ENABLED(INFO)) { - ULOG(INFO, this) << "No more read/write for this SPDY session"; + ULOG(INFO, this) << "No more read/write for this HTTP2 session"; } rv = -1; } @@ -590,7 +590,7 @@ void downstream_readcb(bufferevent *bev, void *ptr) auto downstream = dconn->get_downstream(); auto upstream = static_cast(downstream->get_upstream()); if(downstream->get_request_state() == Downstream::STREAM_CLOSED) { - // If upstream SPDY stream was closed, we just close downstream, + // If upstream HTTP2 stream was closed, we just close downstream, // because there is no consumer now. Downstream connection is also // closed in this case. upstream->remove_downstream(downstream); @@ -1005,7 +1005,7 @@ int Http2Upstream::on_downstream_body(Downstream *downstream, nghttp2_session_resume_data(session_, downstream->get_stream_id()); size_t bodylen = evbuffer_get_length(body); - if(bodylen > SHRPX_SPDY_UPSTREAM_OUTPUT_UPPER_THRES) { + if(bodylen > SHRPX_HTTP2_UPSTREAM_OUTPUT_UPPER_THRES) { downstream->pause_read(SHRPX_NO_BUFFER); } diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index c65b44e5..1670ffbe 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -422,8 +422,8 @@ void https_downstream_readcb(bufferevent *bev, void *ptr) } } } else if(downstream->get_upgraded()) { - // This path is effectively only taken for SPDY downstream - // because only SPDY downstream sets response_state to + // This path is effectively only taken for HTTP2 downstream + // because only HTTP2 downstream sets response_state to // MSG_COMPLETE and this function. For HTTP downstream, EOF // from tunnel connection is handled on // https_downstream_eventcb. diff --git a/src/shrpx_log.h b/src/shrpx_log.h index 0a58c8be..3379d55e 100644 --- a/src/shrpx_log.h +++ b/src/shrpx_log.h @@ -64,9 +64,9 @@ namespace shrpx { #define DCLOG(SEVERITY, DCONN) \ (Log(SEVERITY, __FILE__, __LINE__) << "[DCONN:" << DCONN << "] ") -// Downstream SPDY session log -#define SSLOG(SEVERITY, SPDY) \ - (Log(SEVERITY, __FILE__, __LINE__) << "[DSPDY:" << SPDY << "] ") +// Downstream HTTP2 session log +#define SSLOG(SEVERITY, HTTP2) \ + (Log(SEVERITY, __FILE__, __LINE__) << "[DHTTP2:" << HTTP2 << "] ") enum SeverityLevel { INFO, WARNING, ERROR, FATAL diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index 4cb9b91a..ae0691d5 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -1,5 +1,5 @@ /* - * Spdylay - SPDY Library + * nghttp2 - HTTP/2.0 C Library * * Copyright (c) 2012 Tatsuhiro Tsujikawa * diff --git a/src/shrpx_spdy_upstream.h b/src/shrpx_spdy_upstream.h index e650a8f7..a499d82a 100644 --- a/src/shrpx_spdy_upstream.h +++ b/src/shrpx_spdy_upstream.h @@ -1,5 +1,5 @@ /* - * Spdylay - SPDY Library + * nghttp2 - HTTP/2.0 C Library * * Copyright (c) 2012 Tatsuhiro Tsujikawa *