nghttpx: Simplify BlockedLink management
This commit is contained in:
parent
031fb31248
commit
e63e775fea
|
@ -152,10 +152,6 @@ Downstream::~Downstream() {
|
||||||
DLOG(INFO, this) << "Deleting";
|
DLOG(INFO, this) << "Deleting";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blocked_link_) {
|
|
||||||
detach_blocked_link(blocked_link_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check nullptr for unittest
|
// check nullptr for unittest
|
||||||
if (upstream_) {
|
if (upstream_) {
|
||||||
auto loop = upstream_->get_client_handler()->get_loop();
|
auto loop = upstream_->get_client_handler()->get_loop();
|
||||||
|
@ -1200,12 +1196,10 @@ void Downstream::attach_blocked_link(BlockedLink *l) {
|
||||||
blocked_link_ = l;
|
blocked_link_ = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downstream::detach_blocked_link(BlockedLink *l) {
|
BlockedLink *Downstream::detach_blocked_link() {
|
||||||
assert(blocked_link_);
|
auto link = blocked_link_;
|
||||||
assert(l->downstream == this);
|
|
||||||
|
|
||||||
l->downstream = nullptr;
|
|
||||||
blocked_link_ = nullptr;
|
blocked_link_ = nullptr;
|
||||||
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downstream::add_request_headers_sum(size_t amount) {
|
void Downstream::add_request_headers_sum(size_t amount) {
|
||||||
|
|
|
@ -332,7 +332,7 @@ public:
|
||||||
void set_dispatch_state(int s);
|
void set_dispatch_state(int s);
|
||||||
|
|
||||||
void attach_blocked_link(BlockedLink *l);
|
void attach_blocked_link(BlockedLink *l);
|
||||||
void detach_blocked_link(BlockedLink *l);
|
BlockedLink *detach_blocked_link();
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
EVENT_ERROR = 0x1,
|
EVENT_ERROR = 0x1,
|
||||||
|
|
|
@ -131,6 +131,12 @@ Downstream *DownstreamQueue::remove_and_get_blocked(Downstream *downstream) {
|
||||||
|
|
||||||
if (downstream->get_dispatch_state() == Downstream::DISPATCH_ACTIVE) {
|
if (downstream->get_dispatch_state() == Downstream::DISPATCH_ACTIVE) {
|
||||||
--ent.num_active;
|
--ent.num_active;
|
||||||
|
} else {
|
||||||
|
auto link = downstream->detach_blocked_link();
|
||||||
|
if (link) {
|
||||||
|
ent.blocked.remove(link);
|
||||||
|
delete link;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remove_host_entry_if_empty(ent, host_entries_, host)) {
|
if (remove_host_entry_if_empty(ent, host_entries_, host)) {
|
||||||
|
@ -141,24 +147,19 @@ Downstream *DownstreamQueue::remove_and_get_blocked(Downstream *downstream) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto link = ent.blocked.head; link;) {
|
auto link = ent.blocked.head;
|
||||||
auto next = link->dlnext;
|
|
||||||
if (!link->downstream) {
|
if (!link) {
|
||||||
// If non-active (e.g., pending) Downstream got deleted,
|
return nullptr;
|
||||||
// link->downstream is nullptr.
|
|
||||||
ent.blocked.remove(link);
|
|
||||||
delete link;
|
|
||||||
link = next;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto next_downstream = link->downstream;
|
auto next_downstream = link->downstream;
|
||||||
next_downstream->detach_blocked_link(link);
|
next_downstream->detach_blocked_link();
|
||||||
ent.blocked.remove(link);
|
ent.blocked.remove(link);
|
||||||
delete link;
|
delete link;
|
||||||
remove_host_entry_if_empty(ent, host_entries_, host);
|
remove_host_entry_if_empty(ent, host_entries_, host);
|
||||||
|
|
||||||
return next_downstream;
|
return next_downstream;
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Downstream *DownstreamQueue::get_downstreams() const {
|
Downstream *DownstreamQueue::get_downstreams() const {
|
||||||
|
|
Loading…
Reference in New Issue