nghttpx: Write accesslog when upstream connection is lost for HTTP/2 and SPDY
This commit is contained in:
parent
1e4f288a7c
commit
74ec1d3377
|
@ -1187,4 +1187,9 @@ void Downstream::disable_downstream_wtimer()
|
|||
disable_timer(downstream_wtimerev_);
|
||||
}
|
||||
|
||||
bool Downstream::accesslog_ready() const
|
||||
{
|
||||
return response_http_status_ > 0;
|
||||
}
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
|
@ -276,6 +276,9 @@ public:
|
|||
void ensure_downstream_wtimer();
|
||||
void disable_downstream_rtimer();
|
||||
void disable_downstream_wtimer();
|
||||
|
||||
// Returns true if accesslog can be written for this downstream.
|
||||
bool accesslog_ready() const;
|
||||
private:
|
||||
Headers request_headers_;
|
||||
Headers response_headers_;
|
||||
|
|
|
@ -142,4 +142,10 @@ bool DownstreamQueue::pending_empty() const
|
|||
return pending_downstreams_.empty();
|
||||
}
|
||||
|
||||
const std::map<int32_t, std::unique_ptr<Downstream>>&
|
||||
DownstreamQueue::get_active_downstreams() const
|
||||
{
|
||||
return active_downstreams_;
|
||||
}
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
|
@ -61,6 +61,8 @@ public:
|
|||
// Returns first Downstream object in pending_downstreams_. This
|
||||
// does not pop the first one. If queue is empty, returns nullptr.
|
||||
Downstream* pending_top() const;
|
||||
const std::map<int32_t, std::unique_ptr<Downstream>>&
|
||||
get_active_downstreams() const;
|
||||
private:
|
||||
// Downstream objects, not processed yet
|
||||
std::map<int32_t, std::unique_ptr<Downstream>> pending_downstreams_;
|
||||
|
|
|
@ -1207,7 +1207,7 @@ void Http2Upstream::add_pending_downstream
|
|||
|
||||
void Http2Upstream::remove_downstream(Downstream *downstream)
|
||||
{
|
||||
if(downstream->get_response_state() == Downstream::MSG_COMPLETE) {
|
||||
if(downstream->accesslog_ready()) {
|
||||
handler_->write_accesslog(downstream);
|
||||
}
|
||||
|
||||
|
@ -1469,6 +1469,12 @@ void Http2Upstream::reset_timeouts()
|
|||
}
|
||||
|
||||
void Http2Upstream::on_handler_delete()
|
||||
{}
|
||||
{
|
||||
for(auto& ent : downstream_queue_.get_active_downstreams()) {
|
||||
if(ent.second->accesslog_ready()) {
|
||||
handler_->write_accesslog(ent.second.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
|
@ -739,8 +739,7 @@ void HttpsUpstream::attach_downstream(std::unique_ptr<Downstream> downstream)
|
|||
|
||||
void HttpsUpstream::delete_downstream()
|
||||
{
|
||||
if(downstream_ &&
|
||||
downstream_->get_response_state() == Downstream::MSG_COMPLETE) {
|
||||
if(downstream_ && downstream_->accesslog_ready()) {
|
||||
handler_->write_accesslog(downstream_.get());
|
||||
}
|
||||
|
||||
|
@ -974,8 +973,7 @@ void HttpsUpstream::reset_timeouts()
|
|||
|
||||
void HttpsUpstream::on_handler_delete()
|
||||
{
|
||||
if(downstream_ &&
|
||||
downstream_->get_response_state() == Downstream::MSG_COMPLETE) {
|
||||
if(downstream_ && downstream_->accesslog_ready()) {
|
||||
handler_->write_accesslog(downstream_.get());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -918,7 +918,7 @@ Downstream* SpdyUpstream::add_pending_downstream
|
|||
|
||||
void SpdyUpstream::remove_downstream(Downstream *downstream)
|
||||
{
|
||||
if(downstream->get_response_state() == Downstream::MSG_COMPLETE) {
|
||||
if(downstream->accesslog_ready()) {
|
||||
handler_->write_accesslog(downstream);
|
||||
}
|
||||
|
||||
|
@ -1155,6 +1155,13 @@ void SpdyUpstream::reset_timeouts()
|
|||
}
|
||||
|
||||
void SpdyUpstream::on_handler_delete()
|
||||
{}
|
||||
{
|
||||
for(auto& ent : downstream_queue_.get_active_downstreams()) {
|
||||
if(ent.second->accesslog_ready()) {
|
||||
handler_->write_accesslog(ent.second.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
Loading…
Reference in New Issue