nghttpx: More replacement of spdy with http2

This commit is contained in:
Tatsuhiro Tsujikawa 2013-11-04 18:22:29 +09:00
parent 0fcd14300a
commit b1905c5815
9 changed files with 22 additions and 21 deletions

View File

@ -94,7 +94,8 @@ std::chrono::steady_clock::time_point get_time();
void print_timer(); void print_timer();
// Setting true will print characters with ANSI color escape codes // 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); void set_color_output(bool f);
} // namespace nghttp2 } // namespace nghttp2

View File

@ -344,15 +344,15 @@ void fill_default_config()
mod_config()->private_key_passwd = 0; mod_config()->private_key_passwd = 0;
mod_config()->cert_file = 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_sec = 180;
mod_config()->http2_upstream_read_timeout.tv_usec = 0; 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_sec = 180;
mod_config()->upstream_read_timeout.tv_usec = 0; 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_sec = 60;
mod_config()->upstream_write_timeout.tv_usec = 0; mod_config()->upstream_write_timeout.tv_usec = 0;

View File

@ -84,7 +84,7 @@ private:
bool should_close_after_write_; bool should_close_after_write_;
std::set<DownstreamConnection*> dconn_pool_; std::set<DownstreamConnection*> dconn_pool_;
// Shared HTTP2 session for each thread. NULL if backend is not // 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_; Http2Session *http2session_;
// The number of bytes of HTTP/2.0 client connection header to read // The number of bytes of HTTP/2.0 client connection header to read
size_t left_connhd_len_; size_t left_connhd_len_;

View File

@ -58,7 +58,7 @@ public:
void pause_read(IOCtrlReason reason); void pause_read(IOCtrlReason reason);
int resume_read(IOCtrlReason reason); int resume_read(IOCtrlReason reason);
void force_resume_read(); 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); void set_downstream_stream_id(int32_t stream_id);
int32_t get_downstream_stream_id() const; int32_t get_downstream_stream_id() const;
@ -213,9 +213,9 @@ private:
Headers response_headers_; Headers response_headers_;
bool response_header_key_prev_; bool response_header_key_prev_;
// This buffer is used to temporarily store downstream response // 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_; 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_; nghttp2_error_code response_rst_stream_error_code_;
int32_t recv_window_size_; int32_t recv_window_size_;
}; };

View File

@ -45,7 +45,7 @@ using namespace nghttp2;
namespace shrpx { namespace shrpx {
namespace { 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
namespace { namespace {
@ -59,7 +59,7 @@ ssize_t send_callback(nghttp2_session *session,
auto bev = handler->get_bev(); auto bev = handler->get_bev();
auto output = bufferevent_get_output(bev); auto output = bufferevent_get_output(bev);
// Check buffer length and return WOULDBLOCK if it is large enough. // 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; return NGHTTP2_ERR_WOULDBLOCK;
} }
@ -539,7 +539,7 @@ int Http2Upstream::on_read()
nghttp2_session_want_write(session_) == 0 && nghttp2_session_want_write(session_) == 0 &&
evbuffer_get_length(bufferevent_get_output(handler_->get_bev())) == 0) { evbuffer_get_length(bufferevent_get_output(handler_->get_bev())) == 0) {
if(LOG_ENABLED(INFO)) { 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; rv = -1;
} }
@ -565,7 +565,7 @@ int Http2Upstream::send()
nghttp2_session_want_write(session_) == 0 && nghttp2_session_want_write(session_) == 0 &&
evbuffer_get_length(bufferevent_get_output(handler_->get_bev())) == 0) { evbuffer_get_length(bufferevent_get_output(handler_->get_bev())) == 0) {
if(LOG_ENABLED(INFO)) { 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; rv = -1;
} }
@ -590,7 +590,7 @@ void downstream_readcb(bufferevent *bev, void *ptr)
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<Http2Upstream*>(downstream->get_upstream()); auto upstream = static_cast<Http2Upstream*>(downstream->get_upstream());
if(downstream->get_request_state() == Downstream::STREAM_CLOSED) { 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 // because there is no consumer now. Downstream connection is also
// closed in this case. // closed in this case.
upstream->remove_downstream(downstream); upstream->remove_downstream(downstream);
@ -1005,7 +1005,7 @@ int Http2Upstream::on_downstream_body(Downstream *downstream,
nghttp2_session_resume_data(session_, downstream->get_stream_id()); nghttp2_session_resume_data(session_, downstream->get_stream_id());
size_t bodylen = evbuffer_get_length(body); 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); downstream->pause_read(SHRPX_NO_BUFFER);
} }

View File

@ -422,8 +422,8 @@ void https_downstream_readcb(bufferevent *bev, void *ptr)
} }
} }
} else if(downstream->get_upgraded()) { } else if(downstream->get_upgraded()) {
// This path is effectively only taken for SPDY downstream // This path is effectively only taken for HTTP2 downstream
// because only SPDY downstream sets response_state to // because only HTTP2 downstream sets response_state to
// MSG_COMPLETE and this function. For HTTP downstream, EOF // MSG_COMPLETE and this function. For HTTP downstream, EOF
// from tunnel connection is handled on // from tunnel connection is handled on
// https_downstream_eventcb. // https_downstream_eventcb.

View File

@ -64,9 +64,9 @@ namespace shrpx {
#define DCLOG(SEVERITY, DCONN) \ #define DCLOG(SEVERITY, DCONN) \
(Log(SEVERITY, __FILE__, __LINE__) << "[DCONN:" << DCONN << "] ") (Log(SEVERITY, __FILE__, __LINE__) << "[DCONN:" << DCONN << "] ")
// Downstream SPDY session log // Downstream HTTP2 session log
#define SSLOG(SEVERITY, SPDY) \ #define SSLOG(SEVERITY, HTTP2) \
(Log(SEVERITY, __FILE__, __LINE__) << "[DSPDY:" << SPDY << "] ") (Log(SEVERITY, __FILE__, __LINE__) << "[DHTTP2:" << HTTP2 << "] ")
enum SeverityLevel { enum SeverityLevel {
INFO, WARNING, ERROR, FATAL INFO, WARNING, ERROR, FATAL

View File

@ -1,5 +1,5 @@
/* /*
* Spdylay - SPDY Library * nghttp2 - HTTP/2.0 C Library
* *
* Copyright (c) 2012 Tatsuhiro Tsujikawa * Copyright (c) 2012 Tatsuhiro Tsujikawa
* *

View File

@ -1,5 +1,5 @@
/* /*
* Spdylay - SPDY Library * nghttp2 - HTTP/2.0 C Library
* *
* Copyright (c) 2012 Tatsuhiro Tsujikawa * Copyright (c) 2012 Tatsuhiro Tsujikawa
* *