From c3459c9e865f4fc7be4ecf035216e6fa1b6e2dc9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 16 Nov 2015 21:44:36 +0900 Subject: [PATCH] nghttpx: Clarify return value of nghttp2_submit_push_promise is stream ID --- src/shrpx_http2_upstream.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 42a347fb..c7e93ed9 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -1798,7 +1798,6 @@ int Http2Upstream::submit_push_promise(const std::string &scheme, const std::string &authority, const std::string &path, Downstream *downstream) { - int rv; std::vector nva; // 4 for :method, :scheme, :path and :authority nva.reserve(4 + downstream->get_request_headers().size()); @@ -1827,16 +1826,16 @@ int Http2Upstream::submit_push_promise(const std::string &scheme, } } - rv = nghttp2_submit_push_promise(session_, NGHTTP2_FLAG_NONE, - downstream->get_stream_id(), nva.data(), - nva.size(), nullptr); + auto promised_stream_id = nghttp2_submit_push_promise( + session_, NGHTTP2_FLAG_NONE, downstream->get_stream_id(), nva.data(), + nva.size(), nullptr); - if (rv < 0) { + if (promised_stream_id < 0) { if (LOG_ENABLED(INFO)) { ULOG(INFO, this) << "nghttp2_submit_push_promise() failed: " - << nghttp2_strerror(rv); + << nghttp2_strerror(promised_stream_id); } - if (nghttp2_is_fatal(rv)) { + if (nghttp2_is_fatal(promised_stream_id)) { return -1; } return 0; @@ -1847,8 +1846,8 @@ int Http2Upstream::submit_push_promise(const std::string &scheme, for (auto &nv : nva) { ss << TTY_HTTP_HD << nv.name << TTY_RST << ": " << nv.value << "\n"; } - ULOG(INFO, this) << "HTTP push request headers. promised_stream_id=" << rv - << "\n" << ss.str(); + ULOG(INFO, this) << "HTTP push request headers. promised_stream_id=" + << promised_stream_id << "\n" << ss.str(); } return 0;