nghttpx: Fix memory leak, and blocked stream dispatch

This commit is contained in:
Tatsuhiro Tsujikawa 2015-07-15 19:47:15 +09:00
parent 6d10799301
commit 031fb31248
1 changed files with 7 additions and 7 deletions

View File

@ -124,17 +124,14 @@ Downstream *DownstreamQueue::remove_and_get_blocked(Downstream *downstream) {
// Delete downstream when this function returns. // Delete downstream when this function returns.
auto delptr = std::unique_ptr<Downstream>(downstream); auto delptr = std::unique_ptr<Downstream>(downstream);
if (downstream->get_dispatch_state() != Downstream::DISPATCH_ACTIVE) {
assert(downstream->get_dispatch_state() != Downstream::DISPATCH_NONE);
downstreams_.remove(downstream);
return nullptr;
}
downstreams_.remove(downstream); downstreams_.remove(downstream);
auto &host = make_host_key(downstream); auto &host = make_host_key(downstream);
auto &ent = find_host_entry(host); auto &ent = find_host_entry(host);
if (downstream->get_dispatch_state() == Downstream::DISPATCH_ACTIVE) {
--ent.num_active; --ent.num_active;
}
if (remove_host_entry_if_empty(ent, host_entries_, host)) { if (remove_host_entry_if_empty(ent, host_entries_, host)) {
return nullptr; return nullptr;
@ -147,7 +144,10 @@ Downstream *DownstreamQueue::remove_and_get_blocked(Downstream *downstream) {
for (auto link = ent.blocked.head; link;) { for (auto link = ent.blocked.head; link;) {
auto next = link->dlnext; auto next = link->dlnext;
if (!link->downstream) { if (!link->downstream) {
// If non-active (e.g., pending) Downstream got deleted,
// link->downstream is nullptr.
ent.blocked.remove(link); ent.blocked.remove(link);
delete link;
link = next; link = next;
continue; continue;
} }