Separate Index class to track streams via intrusive list

This commit is contained in:
flamingcow
2019-05-12 08:45:56 -07:00
parent 79709c5b25
commit d29157c1ac
7 changed files with 84 additions and 29 deletions

View File

@@ -25,16 +25,11 @@ void Server::OnRequest(firecgi::Request* request) {
request->WriteHeader("Cache-Control", "no-cache");
request->WriteHeader("X-Accel-Buffering", "no");
request->WriteBody("");
auto stream = new Stream(request);
auto stream = new Stream(request, &index_);
{
std::lock_guard l(mu_);
streams_.insert(stream);
request->OnClose([this, stream]() {
std::lock_guard l(mu_);
request->OnClose([stream]() {
stream->Close();
streams_.erase(stream);
delete stream;
});
}