nghttpx: Use same priority in frontend and backend HTTP2

This commit is contained in:
Tatsuhiro Tsujikawa 2013-11-16 15:41:24 +09:00
parent 81cf484124
commit a255e4efa6
4 changed files with 14 additions and 6 deletions

View File

@ -525,11 +525,16 @@ evbuffer* Downstream::get_response_body_buf()
return response_body_buf_; return response_body_buf_;
} }
void Downstream::set_priority(int pri) void Downstream::set_priority(int32_t pri)
{ {
priority_ = pri; priority_ = pri;
} }
int32_t Downstream::get_priorty() const
{
return priority_;
}
void Downstream::check_upgrade_fulfilled() void Downstream::check_upgrade_fulfilled()
{ {
if(request_method_ == "CONNECT") { if(request_method_ == "CONNECT") {

View File

@ -54,7 +54,8 @@ public:
Upstream* get_upstream() const; Upstream* get_upstream() const;
void set_stream_id(int32_t stream_id); void set_stream_id(int32_t stream_id);
int32_t get_stream_id() const; int32_t get_stream_id() const;
void set_priority(int pri); void set_priority(int32_t pri);
int32_t get_priorty() const;
void pause_read(IOCtrlReason reason); void pause_read(IOCtrlReason reason);
int resume_read(IOCtrlReason reason); int resume_read(IOCtrlReason reason);
void force_resume_read(); void force_resume_read();
@ -177,7 +178,7 @@ private:
Upstream *upstream_; Upstream *upstream_;
DownstreamConnection *dconn_; DownstreamConnection *dconn_;
int32_t stream_id_; int32_t stream_id_;
int priority_; int32_t priority_;
// stream ID in backend connection // stream ID in backend connection
int32_t downstream_stream_id_; int32_t downstream_stream_id_;
// true if the request contains upgrade token (HTTP Upgrade or // true if the request contains upgrade token (HTTP Upgrade or

View File

@ -392,9 +392,11 @@ int Http2DownstreamConnection::push_request_headers()
nghttp2_data_provider data_prd; nghttp2_data_provider data_prd;
data_prd.source.ptr = this; data_prd.source.ptr = this;
data_prd.read_callback = http2_data_read_callback; data_prd.read_callback = http2_data_read_callback;
rv = http2session_->submit_request(this, 0, nv.data(), &data_prd); rv = http2session_->submit_request(this, downstream_->get_priorty(),
nv.data(), &data_prd);
} else { } else {
rv = http2session_->submit_request(this, 0, nv.data(), nullptr); rv = http2session_->submit_request(this, downstream_->get_priorty(),
nv.data(), nullptr);
} }
if(rv != 0) { if(rv != 0) {
DCLOG(FATAL, this) << "nghttp2_submit_request() failed"; DCLOG(FATAL, this) << "nghttp2_submit_request() failed";

View File

@ -76,7 +76,7 @@ int htp_msg_begin(http_parser *htp)
ULOG(INFO, upstream) << "HTTP request started"; ULOG(INFO, upstream) << "HTTP request started";
} }
upstream->reset_current_header_length(); upstream->reset_current_header_length();
auto downstream = new Downstream(upstream, 0, 0); auto downstream = new Downstream(upstream, 0, NGHTTP2_PRI_DEFAULT);
upstream->attach_downstream(downstream); upstream->attach_downstream(downstream);
return 0; return 0;
} }