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