nghttpx: Fix request is sent to backend prematurely with http2 upstream
This commit is contained in:
parent
f3a76d84f1
commit
a225bb29df
|
@ -121,6 +121,17 @@ std::unique_ptr<Downstream> DownstreamQueue::pop_pending()
|
|||
return downstream;
|
||||
}
|
||||
|
||||
Downstream* DownstreamQueue::pending_top() const
|
||||
{
|
||||
auto i = std::begin(pending_downstreams_);
|
||||
|
||||
if(i == std::end(pending_downstreams_)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (*i).second.get();
|
||||
}
|
||||
|
||||
size_t DownstreamQueue::num_active() const
|
||||
{
|
||||
return active_downstreams_.size();
|
||||
|
|
|
@ -58,6 +58,9 @@ public:
|
|||
// Pops first Downstream object in pending_downstreams_ and returns
|
||||
// it.
|
||||
std::unique_ptr<Downstream> pop_pending();
|
||||
// Returns first Downstream object in pending_downstreams_. This
|
||||
// does not pop the first one. If queue is empty, returns nullptr.
|
||||
Downstream* pending_top() const;
|
||||
private:
|
||||
// Downstream objects, not processed yet
|
||||
std::map<int32_t, std::unique_ptr<Downstream>> pending_downstreams_;
|
||||
|
|
|
@ -382,6 +382,18 @@ void Http2Upstream::maintain_downstream_concurrency()
|
|||
{
|
||||
while(get_config()->max_downstream_connections >
|
||||
downstream_queue_.num_active()) {
|
||||
if(downstream_queue_.pending_empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
auto downstream = downstream_queue_.pending_top();
|
||||
if(downstream->get_request_state() != Downstream::HEADER_COMPLETE &&
|
||||
downstream->get_request_state() != Downstream::MSG_COMPLETE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto downstream = downstream_queue_.pop_pending();
|
||||
|
||||
if(!downstream) {
|
||||
|
|
Loading…
Reference in New Issue