nghttpx: Convert shrpx_proto to enum class
This commit is contained in:
parent
d105619bc3
commit
20ea964f2f
|
@ -396,7 +396,7 @@ ClientHandler::ClientHandler(Worker *worker, int fd, SSL *ssl,
|
||||||
get_config()->conn.upstream.ratelimit.write,
|
get_config()->conn.upstream.ratelimit.write,
|
||||||
get_config()->conn.upstream.ratelimit.read, writecb, readcb,
|
get_config()->conn.upstream.ratelimit.read, writecb, readcb,
|
||||||
timeoutcb, this, get_config()->tls.dyn_rec.warmup_threshold,
|
timeoutcb, this, get_config()->tls.dyn_rec.warmup_threshold,
|
||||||
get_config()->tls.dyn_rec.idle_timeout, PROTO_NONE),
|
get_config()->tls.dyn_rec.idle_timeout, Proto::NONE),
|
||||||
ipaddr_(make_string_ref(balloc_, ipaddr)),
|
ipaddr_(make_string_ref(balloc_, ipaddr)),
|
||||||
port_(make_string_ref(balloc_, port)),
|
port_(make_string_ref(balloc_, port)),
|
||||||
faddr_(faddr),
|
faddr_(faddr),
|
||||||
|
@ -769,7 +769,7 @@ Http2Session *ClientHandler::select_http2_session(
|
||||||
// First count the working backend addresses.
|
// First count the working backend addresses.
|
||||||
size_t min = 0;
|
size_t min = 0;
|
||||||
for (const auto &addr : shared_addr->addrs) {
|
for (const auto &addr : shared_addr->addrs) {
|
||||||
if (addr.proto != PROTO_HTTP2 || addr.connect_blocker->blocked()) {
|
if (addr.proto != Proto::HTTP2 || addr.connect_blocker->blocked()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,7 +825,7 @@ Http2Session *ClientHandler::select_http2_session(
|
||||||
DownstreamAddr *selected_addr = nullptr;
|
DownstreamAddr *selected_addr = nullptr;
|
||||||
|
|
||||||
for (auto &addr : shared_addr->addrs) {
|
for (auto &addr : shared_addr->addrs) {
|
||||||
if (addr.in_avail || addr.proto != PROTO_HTTP2 ||
|
if (addr.in_avail || addr.proto != Proto::HTTP2 ||
|
||||||
(addr.http2_extra_freelist.size() == 0 &&
|
(addr.http2_extra_freelist.size() == 0 &&
|
||||||
addr.connect_blocker->blocked())) {
|
addr.connect_blocker->blocked())) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -939,7 +939,7 @@ uint32_t ClientHandler::get_affinity_cookie(Downstream *downstream,
|
||||||
|
|
||||||
std::unique_ptr<DownstreamConnection>
|
std::unique_ptr<DownstreamConnection>
|
||||||
ClientHandler::get_downstream_connection(int &err, Downstream *downstream,
|
ClientHandler::get_downstream_connection(int &err, Downstream *downstream,
|
||||||
shrpx_proto pref_proto) {
|
Proto pref_proto) {
|
||||||
size_t group_idx;
|
size_t group_idx;
|
||||||
auto &downstreamconf = *worker_->get_downstream_config();
|
auto &downstreamconf = *worker_->get_downstream_config();
|
||||||
auto &routerconf = downstreamconf.router;
|
auto &routerconf = downstreamconf.router;
|
||||||
|
@ -1043,7 +1043,7 @@ ClientHandler::get_downstream_connection(int &err, Downstream *downstream,
|
||||||
}
|
}
|
||||||
addr = &shared_addr->addrs[shared_addr->affinity_hash[i].idx];
|
addr = &shared_addr->addrs[shared_addr->affinity_hash[i].idx];
|
||||||
if (addr->connect_blocker->blocked() ||
|
if (addr->connect_blocker->blocked() ||
|
||||||
(pref_proto != PROTO_NONE && pref_proto != addr->proto)) {
|
(pref_proto != Proto::NONE && pref_proto != addr->proto)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1055,7 +1055,7 @@ ClientHandler::get_downstream_connection(int &err, Downstream *downstream,
|
||||||
aff_idx = i;
|
aff_idx = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr->proto == PROTO_HTTP2) {
|
if (addr->proto == Proto::HTTP2) {
|
||||||
auto http2session = select_http2_session_with_affinity(group, addr);
|
auto http2session = select_http2_session_with_affinity(group, addr);
|
||||||
|
|
||||||
auto dconn = std::make_unique<Http2DownstreamConnection>(http2session);
|
auto dconn = std::make_unique<Http2DownstreamConnection>(http2session);
|
||||||
|
@ -1081,33 +1081,33 @@ ClientHandler::get_downstream_connection(int &err, Downstream *downstream,
|
||||||
auto http1_weight = shared_addr->http1_pri.weight;
|
auto http1_weight = shared_addr->http1_pri.weight;
|
||||||
auto http2_weight = shared_addr->http2_pri.weight;
|
auto http2_weight = shared_addr->http2_pri.weight;
|
||||||
|
|
||||||
auto proto = PROTO_NONE;
|
auto proto = Proto::NONE;
|
||||||
|
|
||||||
if (pref_proto == PROTO_HTTP1) {
|
if (pref_proto == Proto::HTTP1) {
|
||||||
if (http1_weight > 0) {
|
if (http1_weight > 0) {
|
||||||
proto = PROTO_HTTP1;
|
proto = Proto::HTTP1;
|
||||||
}
|
}
|
||||||
} else if (pref_proto == PROTO_HTTP2) {
|
} else if (pref_proto == Proto::HTTP2) {
|
||||||
if (http2_weight > 0) {
|
if (http2_weight > 0) {
|
||||||
proto = PROTO_HTTP2;
|
proto = Proto::HTTP2;
|
||||||
}
|
}
|
||||||
} else if (http1_weight > 0 && http2_weight > 0) {
|
} else if (http1_weight > 0 && http2_weight > 0) {
|
||||||
// We only advance cycle if both weight has nonzero to keep its
|
// We only advance cycle if both weight has nonzero to keep its
|
||||||
// distance under WEIGHT_MAX.
|
// distance under WEIGHT_MAX.
|
||||||
if (pri_less(shared_addr->http1_pri, shared_addr->http2_pri)) {
|
if (pri_less(shared_addr->http1_pri, shared_addr->http2_pri)) {
|
||||||
proto = PROTO_HTTP1;
|
proto = Proto::HTTP1;
|
||||||
shared_addr->http1_pri.cycle = next_cycle(shared_addr->http1_pri);
|
shared_addr->http1_pri.cycle = next_cycle(shared_addr->http1_pri);
|
||||||
} else {
|
} else {
|
||||||
proto = PROTO_HTTP2;
|
proto = Proto::HTTP2;
|
||||||
shared_addr->http2_pri.cycle = next_cycle(shared_addr->http2_pri);
|
shared_addr->http2_pri.cycle = next_cycle(shared_addr->http2_pri);
|
||||||
}
|
}
|
||||||
} else if (http1_weight > 0) {
|
} else if (http1_weight > 0) {
|
||||||
proto = PROTO_HTTP1;
|
proto = Proto::HTTP1;
|
||||||
} else if (http2_weight > 0) {
|
} else if (http2_weight > 0) {
|
||||||
proto = PROTO_HTTP2;
|
proto = Proto::HTTP2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proto == PROTO_NONE) {
|
if (proto == Proto::NONE) {
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
CLOG(INFO, this) << "No working downstream address found";
|
CLOG(INFO, this) << "No working downstream address found";
|
||||||
}
|
}
|
||||||
|
@ -1116,7 +1116,7 @@ ClientHandler::get_downstream_connection(int &err, Downstream *downstream,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proto == PROTO_HTTP2) {
|
if (proto == Proto::HTTP2) {
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
CLOG(INFO, this) << "Downstream connection pool is empty."
|
CLOG(INFO, this) << "Downstream connection pool is empty."
|
||||||
<< " Create new one";
|
<< " Create new one";
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
// backend whose protocol is |pref_proto|.
|
// backend whose protocol is |pref_proto|.
|
||||||
std::unique_ptr<DownstreamConnection>
|
std::unique_ptr<DownstreamConnection>
|
||||||
get_downstream_connection(int &err, Downstream *downstream,
|
get_downstream_connection(int &err, Downstream *downstream,
|
||||||
shrpx_proto pref_proto = PROTO_NONE);
|
Proto pref_proto = Proto::NONE);
|
||||||
MemchunkPool *get_mcpool();
|
MemchunkPool *get_mcpool();
|
||||||
SSL *get_ssl() const;
|
SSL *get_ssl() const;
|
||||||
// Call this function when HTTP/2 connection header is received at
|
// Call this function when HTTP/2 connection header is received at
|
||||||
|
|
|
@ -816,7 +816,7 @@ struct DownstreamParams {
|
||||||
ev_tstamp write_timeout;
|
ev_tstamp write_timeout;
|
||||||
size_t fall;
|
size_t fall;
|
||||||
size_t rise;
|
size_t rise;
|
||||||
shrpx_proto proto;
|
Proto proto;
|
||||||
bool tls;
|
bool tls;
|
||||||
bool dns;
|
bool dns;
|
||||||
bool redirect_if_not_tls;
|
bool redirect_if_not_tls;
|
||||||
|
@ -858,10 +858,10 @@ int parse_downstream_params(DownstreamParams &out,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (util::streq_l("h2", std::begin(protostr), protostr.size())) {
|
if (util::streq_l("h2", std::begin(protostr), protostr.size())) {
|
||||||
out.proto = PROTO_HTTP2;
|
out.proto = Proto::HTTP2;
|
||||||
} else if (util::streq_l("http/1.1", std::begin(protostr),
|
} else if (util::streq_l("http/1.1", std::begin(protostr),
|
||||||
protostr.size())) {
|
protostr.size())) {
|
||||||
out.proto = PROTO_HTTP1;
|
out.proto = Proto::HTTP1;
|
||||||
} else {
|
} else {
|
||||||
LOG(ERROR) << "backend: proto: unknown protocol " << protostr;
|
LOG(ERROR) << "backend: proto: unknown protocol " << protostr;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -993,7 +993,7 @@ int parse_mapping(Config *config, DownstreamAddrConfig &addr,
|
||||||
auto &addr_groups = downstreamconf.addr_groups;
|
auto &addr_groups = downstreamconf.addr_groups;
|
||||||
|
|
||||||
DownstreamParams params{};
|
DownstreamParams params{};
|
||||||
params.proto = PROTO_HTTP1;
|
params.proto = Proto::HTTP1;
|
||||||
|
|
||||||
if (parse_downstream_params(params, src_params) != 0) {
|
if (parse_downstream_params(params, src_params) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -3872,15 +3872,15 @@ int int_syslog_facility(const StringRef &strfacility) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef strproto(shrpx_proto proto) {
|
StringRef strproto(Proto proto) {
|
||||||
switch (proto) {
|
switch (proto) {
|
||||||
case PROTO_NONE:
|
case Proto::NONE:
|
||||||
return StringRef::from_lit("none");
|
return StringRef::from_lit("none");
|
||||||
case PROTO_HTTP1:
|
case Proto::HTTP1:
|
||||||
return StringRef::from_lit("http/1.1");
|
return StringRef::from_lit("http/1.1");
|
||||||
case PROTO_HTTP2:
|
case Proto::HTTP2:
|
||||||
return StringRef::from_lit("h2");
|
return StringRef::from_lit("h2");
|
||||||
case PROTO_MEMCACHED:
|
case Proto::MEMCACHED:
|
||||||
return StringRef::from_lit("memcached");
|
return StringRef::from_lit("memcached");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3943,7 +3943,7 @@ int configure_downstream_group(Config *config, bool http2_proxy,
|
||||||
DownstreamAddrConfig addr{};
|
DownstreamAddrConfig addr{};
|
||||||
addr.host = StringRef::from_lit(DEFAULT_DOWNSTREAM_HOST);
|
addr.host = StringRef::from_lit(DEFAULT_DOWNSTREAM_HOST);
|
||||||
addr.port = DEFAULT_DOWNSTREAM_PORT;
|
addr.port = DEFAULT_DOWNSTREAM_PORT;
|
||||||
addr.proto = PROTO_HTTP1;
|
addr.proto = Proto::HTTP1;
|
||||||
|
|
||||||
DownstreamAddrGroupConfig g(StringRef::from_lit("/"));
|
DownstreamAddrGroupConfig g(StringRef::from_lit("/"));
|
||||||
g.addrs.push_back(std::move(addr));
|
g.addrs.push_back(std::move(addr));
|
||||||
|
|
|
@ -362,7 +362,12 @@ constexpr size_t SHRPX_OBFUSCATED_NODE_LENGTH = 8;
|
||||||
constexpr char DEFAULT_DOWNSTREAM_HOST[] = "127.0.0.1";
|
constexpr char DEFAULT_DOWNSTREAM_HOST[] = "127.0.0.1";
|
||||||
constexpr int16_t DEFAULT_DOWNSTREAM_PORT = 80;
|
constexpr int16_t DEFAULT_DOWNSTREAM_PORT = 80;
|
||||||
|
|
||||||
enum shrpx_proto { PROTO_NONE, PROTO_HTTP1, PROTO_HTTP2, PROTO_MEMCACHED };
|
enum class Proto {
|
||||||
|
NONE,
|
||||||
|
HTTP1,
|
||||||
|
HTTP2,
|
||||||
|
MEMCACHED,
|
||||||
|
};
|
||||||
|
|
||||||
enum shrpx_session_affinity {
|
enum shrpx_session_affinity {
|
||||||
// No session affinity
|
// No session affinity
|
||||||
|
@ -466,7 +471,7 @@ struct DownstreamAddrConfig {
|
||||||
size_t fall;
|
size_t fall;
|
||||||
size_t rise;
|
size_t rise;
|
||||||
// Application protocol used in this group
|
// Application protocol used in this group
|
||||||
shrpx_proto proto;
|
Proto proto;
|
||||||
// backend port. 0 if |host_unix| is true.
|
// backend port. 0 if |host_unix| is true.
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
// true if |host| contains UNIX domain socket path.
|
// true if |host| contains UNIX domain socket path.
|
||||||
|
@ -1232,7 +1237,7 @@ read_tls_ticket_key_file(const std::vector<StringRef> &files,
|
||||||
const EVP_CIPHER *cipher, const EVP_MD *hmac);
|
const EVP_CIPHER *cipher, const EVP_MD *hmac);
|
||||||
|
|
||||||
// Returns string representation of |proto|.
|
// Returns string representation of |proto|.
|
||||||
StringRef strproto(shrpx_proto proto);
|
StringRef strproto(Proto proto);
|
||||||
|
|
||||||
int configure_downstream_group(Config *config, bool http2_proxy,
|
int configure_downstream_group(Config *config, bool http2_proxy,
|
||||||
bool numeric_addr_only,
|
bool numeric_addr_only,
|
||||||
|
|
|
@ -59,7 +59,7 @@ Connection::Connection(struct ev_loop *loop, int fd, SSL *ssl,
|
||||||
const RateLimitConfig &read_limit, IOCb writecb,
|
const RateLimitConfig &read_limit, IOCb writecb,
|
||||||
IOCb readcb, TimerCb timeoutcb, void *data,
|
IOCb readcb, TimerCb timeoutcb, void *data,
|
||||||
size_t tls_dyn_rec_warmup_threshold,
|
size_t tls_dyn_rec_warmup_threshold,
|
||||||
ev_tstamp tls_dyn_rec_idle_timeout, shrpx_proto proto)
|
ev_tstamp tls_dyn_rec_idle_timeout, Proto proto)
|
||||||
: tls{DefaultMemchunks(mcpool), DefaultPeekMemchunks(mcpool),
|
: tls{DefaultMemchunks(mcpool), DefaultPeekMemchunks(mcpool),
|
||||||
DefaultMemchunks(mcpool)},
|
DefaultMemchunks(mcpool)},
|
||||||
wlimit(loop, &wev, write_limit.rate, write_limit.burst),
|
wlimit(loop, &wev, write_limit.rate, write_limit.burst),
|
||||||
|
|
|
@ -100,7 +100,7 @@ struct Connection {
|
||||||
const RateLimitConfig &write_limit,
|
const RateLimitConfig &write_limit,
|
||||||
const RateLimitConfig &read_limit, IOCb writecb, IOCb readcb,
|
const RateLimitConfig &read_limit, IOCb writecb, IOCb readcb,
|
||||||
TimerCb timeoutcb, void *data, size_t tls_dyn_rec_warmup_threshold,
|
TimerCb timeoutcb, void *data, size_t tls_dyn_rec_warmup_threshold,
|
||||||
ev_tstamp tls_dyn_rec_idle_timeout, shrpx_proto proto);
|
ev_tstamp tls_dyn_rec_idle_timeout, Proto proto);
|
||||||
~Connection();
|
~Connection();
|
||||||
|
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
@ -169,7 +169,7 @@ struct Connection {
|
||||||
// Application protocol used over the connection. This field is not
|
// Application protocol used over the connection. This field is not
|
||||||
// used in this object at the moment. The rest of the program may
|
// used in this object at the moment. The rest of the program may
|
||||||
// use this value when it is useful.
|
// use this value when it is useful.
|
||||||
shrpx_proto proto;
|
Proto proto;
|
||||||
// The point of time when last read is observed. Note: since we use
|
// The point of time when last read is observed. Note: since we use
|
||||||
// |rt| as idle timer, the activity is not limited to read.
|
// |rt| as idle timer, the activity is not limited to read.
|
||||||
ev_tstamp last_read;
|
ev_tstamp last_read;
|
||||||
|
|
|
@ -189,7 +189,7 @@ Http2Session::Http2Session(struct ev_loop *loop, SSL_CTX *ssl_ctx,
|
||||||
group->shared_addr->timeout.write, group->shared_addr->timeout.read,
|
group->shared_addr->timeout.write, group->shared_addr->timeout.read,
|
||||||
{}, {}, writecb, readcb, timeoutcb, this,
|
{}, {}, writecb, readcb, timeoutcb, this,
|
||||||
get_config()->tls.dyn_rec.warmup_threshold,
|
get_config()->tls.dyn_rec.warmup_threshold,
|
||||||
get_config()->tls.dyn_rec.idle_timeout, PROTO_HTTP2),
|
get_config()->tls.dyn_rec.idle_timeout, Proto::HTTP2),
|
||||||
wb_(worker->get_mcpool()),
|
wb_(worker->get_mcpool()),
|
||||||
worker_(worker),
|
worker_(worker),
|
||||||
ssl_ctx_(ssl_ctx),
|
ssl_ctx_(ssl_ctx),
|
||||||
|
|
|
@ -92,7 +92,7 @@ void retry_downstream_connection(Downstream *downstream,
|
||||||
// request in request buffer.
|
// request in request buffer.
|
||||||
auto ndconn = handler->get_downstream_connection(
|
auto ndconn = handler->get_downstream_connection(
|
||||||
rv, downstream,
|
rv, downstream,
|
||||||
downstream->get_request_header_sent() ? PROTO_HTTP1 : PROTO_NONE);
|
downstream->get_request_header_sent() ? Proto::HTTP1 : Proto::NONE);
|
||||||
if (ndconn) {
|
if (ndconn) {
|
||||||
if (downstream->attach_downstream_connection(std::move(ndconn)) == 0 &&
|
if (downstream->attach_downstream_connection(std::move(ndconn)) == 0 &&
|
||||||
downstream->push_request_headers() == 0) {
|
downstream->push_request_headers() == 0) {
|
||||||
|
@ -193,7 +193,7 @@ HttpDownstreamConnection::HttpDownstreamConnection(
|
||||||
group->shared_addr->timeout.write, group->shared_addr->timeout.read,
|
group->shared_addr->timeout.write, group->shared_addr->timeout.read,
|
||||||
{}, {}, connectcb, readcb, connect_timeoutcb, this,
|
{}, {}, connectcb, readcb, connect_timeoutcb, this,
|
||||||
get_config()->tls.dyn_rec.warmup_threshold,
|
get_config()->tls.dyn_rec.warmup_threshold,
|
||||||
get_config()->tls.dyn_rec.idle_timeout, PROTO_HTTP1),
|
get_config()->tls.dyn_rec.idle_timeout, Proto::HTTP1),
|
||||||
on_read_(&HttpDownstreamConnection::noop),
|
on_read_(&HttpDownstreamConnection::noop),
|
||||||
on_write_(&HttpDownstreamConnection::noop),
|
on_write_(&HttpDownstreamConnection::noop),
|
||||||
signal_write_(&HttpDownstreamConnection::noop),
|
signal_write_(&HttpDownstreamConnection::noop),
|
||||||
|
@ -286,7 +286,7 @@ int HttpDownstreamConnection::initiate_connection() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr->proto != PROTO_HTTP1) {
|
if (addr->proto != Proto::HTTP1) {
|
||||||
if (end == next_downstream) {
|
if (end == next_downstream) {
|
||||||
return SHRPX_ERR_NETWORK;
|
return SHRPX_ERR_NETWORK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ LiveCheck::LiveCheck(struct ev_loop *loop, SSL_CTX *ssl_ctx, Worker *worker,
|
||||||
worker->get_downstream_config()->timeout.write,
|
worker->get_downstream_config()->timeout.write,
|
||||||
worker->get_downstream_config()->timeout.read, {}, {}, writecb,
|
worker->get_downstream_config()->timeout.read, {}, {}, writecb,
|
||||||
readcb, timeoutcb, this, get_config()->tls.dyn_rec.warmup_threshold,
|
readcb, timeoutcb, this, get_config()->tls.dyn_rec.warmup_threshold,
|
||||||
get_config()->tls.dyn_rec.idle_timeout, PROTO_NONE),
|
get_config()->tls.dyn_rec.idle_timeout, Proto::NONE),
|
||||||
wb_(worker->get_mcpool()),
|
wb_(worker->get_mcpool()),
|
||||||
gen_(gen),
|
gen_(gen),
|
||||||
read_(&LiveCheck::noop),
|
read_(&LiveCheck::noop),
|
||||||
|
@ -211,10 +211,10 @@ int LiveCheck::initiate_connection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (addr_->proto) {
|
switch (addr_->proto) {
|
||||||
case PROTO_HTTP1:
|
case Proto::HTTP1:
|
||||||
tls::setup_downstream_http1_alpn(ssl);
|
tls::setup_downstream_http1_alpn(ssl);
|
||||||
break;
|
break;
|
||||||
case PROTO_HTTP2:
|
case Proto::HTTP2:
|
||||||
tls::setup_downstream_http2_alpn(ssl);
|
tls::setup_downstream_http2_alpn(ssl);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -359,7 +359,7 @@ int LiveCheck::connected() {
|
||||||
return do_write();
|
return do_write();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr_->proto == PROTO_HTTP2) {
|
if (addr_->proto == Proto::HTTP2) {
|
||||||
// For HTTP/2, we try to read SETTINGS ACK from server to make
|
// For HTTP/2, we try to read SETTINGS ACK from server to make
|
||||||
// sure it is really alive, and serving HTTP/2.
|
// sure it is really alive, and serving HTTP/2.
|
||||||
read_ = &LiveCheck::read_clear;
|
read_ = &LiveCheck::read_clear;
|
||||||
|
@ -418,12 +418,12 @@ int LiveCheck::tls_handshake() {
|
||||||
auto proto = StringRef{next_proto, next_proto_len};
|
auto proto = StringRef{next_proto, next_proto_len};
|
||||||
|
|
||||||
switch (addr_->proto) {
|
switch (addr_->proto) {
|
||||||
case PROTO_HTTP1:
|
case Proto::HTTP1:
|
||||||
if (proto.empty() || proto == StringRef::from_lit("http/1.1")) {
|
if (proto.empty() || proto == StringRef::from_lit("http/1.1")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
case PROTO_HTTP2:
|
case Proto::HTTP2:
|
||||||
if (util::check_h2_is_selected(proto)) {
|
if (util::check_h2_is_selected(proto)) {
|
||||||
// For HTTP/2, we try to read SETTINGS ACK from server to make
|
// For HTTP/2, we try to read SETTINGS ACK from server to make
|
||||||
// sure it is really alive, and serving HTTP/2.
|
// sure it is really alive, and serving HTTP/2.
|
||||||
|
|
|
@ -102,7 +102,7 @@ MemcachedConnection::MemcachedConnection(const Address *addr,
|
||||||
MemchunkPool *mcpool,
|
MemchunkPool *mcpool,
|
||||||
std::mt19937 &gen)
|
std::mt19937 &gen)
|
||||||
: conn_(loop, -1, nullptr, mcpool, write_timeout, read_timeout, {}, {},
|
: conn_(loop, -1, nullptr, mcpool, write_timeout, read_timeout, {}, {},
|
||||||
connectcb, readcb, timeoutcb, this, 0, 0., PROTO_MEMCACHED),
|
connectcb, readcb, timeoutcb, this, 0, 0., Proto::MEMCACHED),
|
||||||
do_read_(&MemcachedConnection::noop),
|
do_read_(&MemcachedConnection::noop),
|
||||||
do_write_(&MemcachedConnection::noop),
|
do_write_(&MemcachedConnection::noop),
|
||||||
sni_name_(sni_name),
|
sni_name_(sni_name),
|
||||||
|
|
|
@ -1049,9 +1049,9 @@ int select_next_proto_cb(SSL *ssl, unsigned char **out, unsigned char *outlen,
|
||||||
void *arg) {
|
void *arg) {
|
||||||
auto conn = static_cast<Connection *>(SSL_get_app_data(ssl));
|
auto conn = static_cast<Connection *>(SSL_get_app_data(ssl));
|
||||||
switch (conn->proto) {
|
switch (conn->proto) {
|
||||||
case PROTO_HTTP1:
|
case Proto::HTTP1:
|
||||||
return select_h1_next_proto_cb(ssl, out, outlen, in, inlen, arg);
|
return select_h1_next_proto_cb(ssl, out, outlen, in, inlen, arg);
|
||||||
case PROTO_HTTP2:
|
case Proto::HTTP2:
|
||||||
return select_h2_next_proto_cb(ssl, out, outlen, in, inlen, arg);
|
return select_h2_next_proto_cb(ssl, out, outlen, in, inlen, arg);
|
||||||
default:
|
default:
|
||||||
return SSL_TLSEXT_ERR_NOACK;
|
return SSL_TLSEXT_ERR_NOACK;
|
||||||
|
|
|
@ -74,10 +74,10 @@ DownstreamAddrGroup::~DownstreamAddrGroup() {}
|
||||||
|
|
||||||
// DownstreamKey is used to index SharedDownstreamAddr in order to
|
// DownstreamKey is used to index SharedDownstreamAddr in order to
|
||||||
// find the same configuration.
|
// find the same configuration.
|
||||||
using DownstreamKey = std::tuple<
|
using DownstreamKey =
|
||||||
std::vector<std::tuple<StringRef, StringRef, size_t, size_t, shrpx_proto,
|
std::tuple<std::vector<std::tuple<StringRef, StringRef, size_t, size_t,
|
||||||
uint16_t, bool, bool, bool, bool>>,
|
Proto, uint16_t, bool, bool, bool, bool>>,
|
||||||
bool, int, StringRef, StringRef, int, int64_t, int64_t>;
|
bool, int, StringRef, StringRef, int, int64_t, int64_t>;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
DownstreamKey create_downstream_key(
|
DownstreamKey create_downstream_key(
|
||||||
|
@ -254,10 +254,10 @@ void Worker::replace_downstream_config(
|
||||||
randgen_, loop_,
|
randgen_, loop_,
|
||||||
[shared_addr_ptr, &dst_addr]() {
|
[shared_addr_ptr, &dst_addr]() {
|
||||||
switch (dst_addr.proto) {
|
switch (dst_addr.proto) {
|
||||||
case PROTO_HTTP1:
|
case Proto::HTTP1:
|
||||||
--shared_addr_ptr->http1_pri.weight;
|
--shared_addr_ptr->http1_pri.weight;
|
||||||
break;
|
break;
|
||||||
case PROTO_HTTP2:
|
case Proto::HTTP2:
|
||||||
--shared_addr_ptr->http2_pri.weight;
|
--shared_addr_ptr->http2_pri.weight;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -266,10 +266,10 @@ void Worker::replace_downstream_config(
|
||||||
},
|
},
|
||||||
[shared_addr_ptr, &dst_addr]() {
|
[shared_addr_ptr, &dst_addr]() {
|
||||||
switch (dst_addr.proto) {
|
switch (dst_addr.proto) {
|
||||||
case PROTO_HTTP1:
|
case Proto::HTTP1:
|
||||||
++shared_addr_ptr->http1_pri.weight;
|
++shared_addr_ptr->http1_pri.weight;
|
||||||
break;
|
break;
|
||||||
case PROTO_HTTP2:
|
case Proto::HTTP2:
|
||||||
++shared_addr_ptr->http2_pri.weight;
|
++shared_addr_ptr->http2_pri.weight;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -280,10 +280,10 @@ void Worker::replace_downstream_config(
|
||||||
dst_addr.live_check = std::make_unique<LiveCheck>(
|
dst_addr.live_check = std::make_unique<LiveCheck>(
|
||||||
loop_, cl_ssl_ctx_, this, &dst_addr, randgen_);
|
loop_, cl_ssl_ctx_, this, &dst_addr, randgen_);
|
||||||
|
|
||||||
if (dst_addr.proto == PROTO_HTTP2) {
|
if (dst_addr.proto == Proto::HTTP2) {
|
||||||
++num_http2;
|
++num_http2;
|
||||||
} else {
|
} else {
|
||||||
assert(dst_addr.proto == PROTO_HTTP1);
|
assert(dst_addr.proto == Proto::HTTP1);
|
||||||
++num_http1;
|
++num_http1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ struct DownstreamAddr {
|
||||||
// address.
|
// address.
|
||||||
size_t num_dconn;
|
size_t num_dconn;
|
||||||
// Application protocol used in this backend
|
// Application protocol used in this backend
|
||||||
shrpx_proto proto;
|
Proto proto;
|
||||||
// true if TLS is used in this backend
|
// true if TLS is used in this backend
|
||||||
bool tls;
|
bool tls;
|
||||||
// true if dynamic DNS is enabled
|
// true if dynamic DNS is enabled
|
||||||
|
|
Loading…
Reference in New Issue