Skip to content

Commit

Permalink
Http::cleanupPeers: check fulfiller is non-null
Browse files Browse the repository at this point in the history
resolves #185
  • Loading branch information
ohwgiles committed Mar 16, 2023
1 parent 1e7e931 commit dab620b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,16 @@ kj::Promise<void> Http::cleanupPeers(kj::Timer& timer)
{
return timer.afterDelay(15 * kj::SECONDS).then([&]{
for(EventPeer* p : eventPeers) {
// an empty SSE message is a colon followed by two newlines
p->pendingOutput.push_back(":\n\n");
p->fulfiller->fulfill();
// Even single threaded, if load causes this timeout to be serviced
// before writeEvents has created a fulfiller, or if an exception
// caused the destruction of the promise but attach(peer) hasn't yet
// removed it from the eventPeers list, we will see a null fulfiller
// here
if(p->fulfiller) {
// an empty SSE message is a colon followed by two newlines
p->pendingOutput.push_back(":\n\n");
p->fulfiller->fulfill();
}
}
return cleanupPeers(timer);
}).eagerlyEvaluate(nullptr);
Expand Down

0 comments on commit dab620b

Please sign in to comment.