nghttpx: Convert FreelistZone to enum class
This commit is contained in:
parent
4bd44b9cdf
commit
b46a324943
|
@ -199,7 +199,7 @@ Http2Session::Http2Session(struct ev_loop *loop, SSL_CTX *ssl_ctx,
|
||||||
raddr_(nullptr),
|
raddr_(nullptr),
|
||||||
state_(DISCONNECTED),
|
state_(DISCONNECTED),
|
||||||
connection_check_state_(CONNECTION_CHECK_NONE),
|
connection_check_state_(CONNECTION_CHECK_NONE),
|
||||||
freelist_zone_(FREELIST_ZONE_NONE),
|
freelist_zone_(FreelistZone::NONE),
|
||||||
settings_recved_(false),
|
settings_recved_(false),
|
||||||
allow_connect_proto_(false) {
|
allow_connect_proto_(false) {
|
||||||
read_ = write_ = &Http2Session::noop;
|
read_ = write_ = &Http2Session::noop;
|
||||||
|
@ -723,7 +723,7 @@ void Http2Session::remove_downstream_connection(
|
||||||
SSLOG(INFO, this) << "Remove downstream";
|
SSLOG(INFO, this) << "Remove downstream";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (freelist_zone_ == FREELIST_ZONE_NONE && !max_concurrency_reached()) {
|
if (freelist_zone_ == FreelistZone::NONE && !max_concurrency_reached()) {
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
SSLOG(INFO, this) << "Append to http2_extra_freelist, addr=" << addr_
|
SSLOG(INFO, this) << "Append to http2_extra_freelist, addr=" << addr_
|
||||||
<< ", freelist.size="
|
<< ", freelist.size="
|
||||||
|
@ -2313,7 +2313,7 @@ Http2Session::get_downstream_addr_group() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Http2Session::add_to_avail_freelist() {
|
void Http2Session::add_to_avail_freelist() {
|
||||||
if (freelist_zone_ != FREELIST_ZONE_NONE) {
|
if (freelist_zone_ != FreelistZone::NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2323,13 +2323,13 @@ void Http2Session::add_to_avail_freelist() {
|
||||||
<< group_->shared_addr->http2_avail_freelist.size();
|
<< group_->shared_addr->http2_avail_freelist.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
freelist_zone_ = FREELIST_ZONE_AVAIL;
|
freelist_zone_ = FreelistZone::AVAIL;
|
||||||
group_->shared_addr->http2_avail_freelist.append(this);
|
group_->shared_addr->http2_avail_freelist.append(this);
|
||||||
addr_->in_avail = true;
|
addr_->in_avail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Http2Session::add_to_extra_freelist() {
|
void Http2Session::add_to_extra_freelist() {
|
||||||
if (freelist_zone_ != FREELIST_ZONE_NONE) {
|
if (freelist_zone_ != FreelistZone::NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2339,15 +2339,15 @@ void Http2Session::add_to_extra_freelist() {
|
||||||
<< addr_->http2_extra_freelist.size();
|
<< addr_->http2_extra_freelist.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
freelist_zone_ = FREELIST_ZONE_EXTRA;
|
freelist_zone_ = FreelistZone::EXTRA;
|
||||||
addr_->http2_extra_freelist.append(this);
|
addr_->http2_extra_freelist.append(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Http2Session::remove_from_freelist() {
|
void Http2Session::remove_from_freelist() {
|
||||||
switch (freelist_zone_) {
|
switch (freelist_zone_) {
|
||||||
case FREELIST_ZONE_NONE:
|
case FreelistZone::NONE:
|
||||||
return;
|
return;
|
||||||
case FREELIST_ZONE_AVAIL:
|
case FreelistZone::AVAIL:
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
SSLOG(INFO, this) << "Remove from http2_avail_freelist, group=" << group_
|
SSLOG(INFO, this) << "Remove from http2_avail_freelist, group=" << group_
|
||||||
<< ", freelist.size="
|
<< ", freelist.size="
|
||||||
|
@ -2356,7 +2356,7 @@ void Http2Session::remove_from_freelist() {
|
||||||
group_->shared_addr->http2_avail_freelist.remove(this);
|
group_->shared_addr->http2_avail_freelist.remove(this);
|
||||||
addr_->in_avail = false;
|
addr_->in_avail = false;
|
||||||
break;
|
break;
|
||||||
case FREELIST_ZONE_EXTRA:
|
case FreelistZone::EXTRA:
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
SSLOG(INFO, this) << "Remove from http2_extra_freelist, addr=" << addr_
|
SSLOG(INFO, this) << "Remove from http2_extra_freelist, addr=" << addr_
|
||||||
<< ", freelist.size="
|
<< ", freelist.size="
|
||||||
|
@ -2364,16 +2364,16 @@ void Http2Session::remove_from_freelist() {
|
||||||
}
|
}
|
||||||
addr_->http2_extra_freelist.remove(this);
|
addr_->http2_extra_freelist.remove(this);
|
||||||
break;
|
break;
|
||||||
case FREELIST_ZONE_GONE:
|
case FreelistZone::GONE:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
freelist_zone_ = FREELIST_ZONE_NONE;
|
freelist_zone_ = FreelistZone::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Http2Session::exclude_from_scheduling() {
|
void Http2Session::exclude_from_scheduling() {
|
||||||
remove_from_freelist();
|
remove_from_freelist();
|
||||||
freelist_zone_ = FREELIST_ZONE_GONE;
|
freelist_zone_ = FreelistZone::GONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultMemchunks *Http2Session::get_request_buf() { return &wb_; }
|
DefaultMemchunks *Http2Session::get_request_buf() { return &wb_; }
|
||||||
|
|
|
@ -58,18 +58,18 @@ struct StreamData {
|
||||||
Http2DownstreamConnection *dconn;
|
Http2DownstreamConnection *dconn;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FreelistZone {
|
enum class FreelistZone {
|
||||||
// Http2Session object is not linked in any freelist.
|
// Http2Session object is not linked in any freelist.
|
||||||
FREELIST_ZONE_NONE,
|
NONE,
|
||||||
// Http2Session object is linked in group scope
|
// Http2Session object is linked in group scope
|
||||||
// http2_avail_freelist.
|
// http2_avail_freelist.
|
||||||
FREELIST_ZONE_AVAIL,
|
AVAIL,
|
||||||
// Http2Session object is linked in address scope
|
// Http2Session object is linked in address scope
|
||||||
// http2_extra_freelist.
|
// http2_extra_freelist.
|
||||||
FREELIST_ZONE_EXTRA,
|
EXTRA,
|
||||||
// Http2Session object is about to be deleted, and it does not
|
// Http2Session object is about to be deleted, and it does not
|
||||||
// belong to any linked list.
|
// belong to any linked list.
|
||||||
FREELIST_ZONE_GONE
|
GONE
|
||||||
};
|
};
|
||||||
|
|
||||||
class Http2Session {
|
class Http2Session {
|
||||||
|
@ -285,7 +285,7 @@ private:
|
||||||
std::unique_ptr<DNSQuery> dns_query_;
|
std::unique_ptr<DNSQuery> dns_query_;
|
||||||
int state_;
|
int state_;
|
||||||
int connection_check_state_;
|
int connection_check_state_;
|
||||||
int freelist_zone_;
|
FreelistZone freelist_zone_;
|
||||||
// true if SETTINGS without ACK is received from peer.
|
// true if SETTINGS without ACK is received from peer.
|
||||||
bool settings_recved_;
|
bool settings_recved_;
|
||||||
// true if peer enables RFC 8441 CONNECT protocol.
|
// true if peer enables RFC 8441 CONNECT protocol.
|
||||||
|
|
Loading…
Reference in New Issue