Commit 61b594af authored by gejun's avatar gejun

Separate window_size of connections from streams and fix WU bugs

parent 8994b65a
......@@ -23,17 +23,39 @@ H2Settings::H2Settings()
: header_table_size(DEFAULT_HEADER_TABLE_SIZE)
, enable_push(false)
, max_concurrent_streams(std::numeric_limits<uint32_t>::max())
, initial_window_size(DEFAULT_INITIAL_WINDOW_SIZE)
, stream_window_size(256 * 1024)
, connection_window_size(1024 * 1024)
, max_frame_size(DEFAULT_MAX_FRAME_SIZE)
, max_header_list_size(std::numeric_limits<uint32_t>::max()) {
}
bool H2Settings::IsValid(bool log_error) const {
if (stream_window_size > MAX_WINDOW_SIZE) {
LOG_IF(ERROR, log_error) << "Invalid stream_window_size=" << stream_window_size;
return false;
}
if (connection_window_size < DEFAULT_INITIAL_WINDOW_SIZE ||
connection_window_size > MAX_WINDOW_SIZE) {
LOG_IF(ERROR, log_error) << "Invalid connection_window_size=" << connection_window_size;
return false;
}
if (max_frame_size < DEFAULT_MAX_FRAME_SIZE ||
max_frame_size > MAX_OF_MAX_FRAME_SIZE) {
LOG_IF(ERROR, log_error) << "Invalid max_frame_size=" << max_frame_size;
return false;
}
return true;
}
std::ostream& operator<<(std::ostream& os, const H2Settings& s) {
os << "{header_table_size=" << s.header_table_size
<< " enable_push=" << s.enable_push
<< " max_concurrent_streams=" << s.max_concurrent_streams
<< " initial_window_size=" << s.initial_window_size
<< " max_frame_size=" << s.max_frame_size
<< " stream_window_size=" << s.stream_window_size;
if (s.connection_window_size > 0) {
os << " conn_window_size=" << s.connection_window_size;
}
os << " max_frame_size=" << s.max_frame_size
<< " max_header_list_size=" << s.max_header_list_size
<< '}';
return os;
......
......@@ -26,6 +26,9 @@ struct H2Settings {
// Construct with default values.
H2Settings();
// Returns true iff all options are valid.
bool IsValid(bool log_error = false) const;
// Allows the sender to inform the remote endpoint of the maximum size of
// the header compression table used to decode header blocks, in octets.
// The encoder can select any size equal to or less than this value by
......@@ -41,7 +44,7 @@ struct H2Settings {
// parameter to 0 and had it acknowledged MUST treat the receipt of a
// PUSH_PROMISE frame as a connection error (Section 5.4.1) of type
// PROTOCOL_ERROR.
// Default: true (server push is permitted)
// Default: false (server push is disabled)
static const bool DEFAULT_ENABLE_PUSH = true;
bool enable_push;
......@@ -60,10 +63,15 @@ struct H2Settings {
// This setting affects the window size of all streams (see Section 6.9.2).
// Values above the maximum flow-control window size of 2^31-1 are treated
// as a connection error (Section 5.4.1) of type FLOW_CONTROL_ERROR
// Default: 65535
// Default: 256 * 1024
static const uint32_t DEFAULT_INITIAL_WINDOW_SIZE = 65535;
static const uint32_t MAX_INITIAL_WINDOW_SIZE = (1u << 31) - 1;
uint32_t initial_window_size;
static const uint32_t MAX_WINDOW_SIZE = (1u << 31) - 1;
uint32_t stream_window_size;
// Initial window size for connection-level flow control.
// Default: 1024 * 1024
// Setting to zero stops printing this field.
uint32_t connection_window_size;
// Size of the largest frame payload that the sender is willing to receive,
// in octets. The value advertised by an endpoint MUST be between 16384 and
......
This diff is collapsed.
......@@ -725,6 +725,11 @@ int Server::StartInternal(const butil::ip_t& ip,
_options = ServerOptions();
}
if (!_options.h2_settings.IsValid(true/*log_error*/)) {
LOG(ERROR) << "Invalid h2_settings";
return -1;
}
if (_options.http_master_service) {
// Check requirements for http_master_service:
// has "default_method" & request/response have no fields
......
......@@ -231,7 +231,7 @@ struct ServerOptions {
std::string enabled_protocols;
// Customize parameters of HTTP2, defined in http2.h
H2Settings http2_settings;
H2Settings h2_settings;
private:
// SSLOptions is large and not often used, allocate it on heap to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment