nghttpx: Set request_start_time_ at Downstream ctor

.. so that we can avoid the problem that request_start_time_ is 0
This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-21 22:28:15 +09:00
parent 3c5ca63b6f
commit 041d9863c2
5 changed files with 4 additions and 7 deletions

View File

@ -106,7 +106,8 @@ void downstream_wtimeoutcb(struct ev_loop *loop, ev_timer *w, int revents) {
// upstream could be nullptr for unittests // upstream could be nullptr for unittests
Downstream::Downstream(Upstream *upstream, int32_t stream_id, int32_t priority) Downstream::Downstream(Upstream *upstream, int32_t stream_id, int32_t priority)
: request_buf_(upstream ? upstream->get_mcpool() : nullptr), : request_start_time_(std::chrono::high_resolution_clock::now()),
request_buf_(upstream ? upstream->get_mcpool() : nullptr),
response_buf_(upstream ? upstream->get_mcpool() : nullptr), response_buf_(upstream ? upstream->get_mcpool() : nullptr),
request_bodylen_(0), response_bodylen_(0), response_sent_bodylen_(0), request_bodylen_(0), response_bodylen_(0), response_sent_bodylen_(0),
request_content_length_(-1), response_content_length_(-1), request_content_length_(-1), response_content_length_(-1),

View File

@ -298,11 +298,12 @@ private:
Headers request_headers_; Headers request_headers_;
Headers response_headers_; Headers response_headers_;
std::chrono::high_resolution_clock::time_point request_start_time_;
std::string request_method_; std::string request_method_;
std::string request_path_; std::string request_path_;
std::string request_http2_scheme_; std::string request_http2_scheme_;
std::string request_http2_authority_; std::string request_http2_authority_;
std::chrono::high_resolution_clock::time_point request_start_time_;
std::string assembled_request_cookie_; std::string assembled_request_cookie_;
DefaultMemchunks request_buf_; DefaultMemchunks request_buf_;

View File

@ -310,7 +310,6 @@ int on_request_headers(Http2Upstream *upstream, Downstream *downstream,
downstream->set_request_http2_scheme(http2::value_to_str(scheme)); downstream->set_request_http2_scheme(http2::value_to_str(scheme));
downstream->set_request_http2_authority(http2::value_to_str(authority)); downstream->set_request_http2_authority(http2::value_to_str(authority));
downstream->set_request_path(http2::value_to_str(path)); downstream->set_request_path(http2::value_to_str(path));
downstream->set_request_start_time(std::chrono::high_resolution_clock::now());
if (!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM)) { if (!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM)) {
downstream->set_request_http2_expect_body(true); downstream->set_request_http2_expect_body(true);

View File

@ -139,7 +139,6 @@ int htp_hdrs_completecb(http_parser *htp) {
http_method_str((enum http_method)htp->method)); http_method_str((enum http_method)htp->method));
downstream->set_request_major(htp->http_major); downstream->set_request_major(htp->http_major);
downstream->set_request_minor(htp->http_minor); downstream->set_request_minor(htp->http_minor);
downstream->set_request_start_time(std::chrono::high_resolution_clock::now());
downstream->set_request_connection_close(!http_should_keep_alive(htp)); downstream->set_request_connection_close(!http_should_keep_alive(htp));

View File

@ -196,9 +196,6 @@ void on_ctrl_recv_callback(spdylay_session *session, spdylay_frame_type type,
downstream->set_request_path(path->value); downstream->set_request_path(path->value);
} }
downstream->set_request_start_time(
std::chrono::high_resolution_clock::now());
if (!(frame->syn_stream.hd.flags & SPDYLAY_CTRL_FLAG_FIN)) { if (!(frame->syn_stream.hd.flags & SPDYLAY_CTRL_FLAG_FIN)) {
downstream->set_request_http2_expect_body(true); downstream->set_request_http2_expect_body(true);
} }