nghttpx: Fix crash when upgrading HTTP/2 failed

This commit is contained in:
Tatsuhiro Tsujikawa 2015-03-01 10:11:45 +09:00
parent 38153e0f6e
commit 185ebd7b79
3 changed files with 9 additions and 8 deletions

View File

@ -662,6 +662,7 @@ int ClientHandler::perform_http2_upgrade(HttpsUpstream *http) {
"Upgrade: " NGHTTP2_CLEARTEXT_PROTO_VERSION_ID "\r\n" "Upgrade: " NGHTTP2_CLEARTEXT_PROTO_VERSION_ID "\r\n"
"\r\n"; "\r\n";
wb_.write(res, sizeof(res) - 1); wb_.write(res, sizeof(res) - 1);
signal_write();
return 0; return 0;
} }

View File

@ -116,8 +116,10 @@ int Http2Upstream::upgrade_upstream(HttpsUpstream *http) {
session_, reinterpret_cast<const uint8_t *>(settings_payload.c_str()), session_, reinterpret_cast<const uint8_t *>(settings_payload.c_str()),
settings_payload.size(), nullptr); settings_payload.size(), nullptr);
if (rv != 0) { if (rv != 0) {
ULOG(WARN, this) << "nghttp2_session_upgrade() returned error: " if (LOG_ENABLED(INFO)) {
<< nghttp2_strerror(rv); ULOG(INFO, this) << "nghttp2_session_upgrade() returned error: "
<< nghttp2_strerror(rv);
}
return -1; return -1;
} }
pre_upstream_.reset(http); pre_upstream_.reset(http);

View File

@ -234,13 +234,11 @@ int htp_msg_completecb(http_parser *htp) {
} }
if (handler->get_http2_upgrade_allowed() && if (handler->get_http2_upgrade_allowed() &&
downstream->get_http2_upgrade_request()) { downstream->get_http2_upgrade_request() &&
handler->perform_http2_upgrade(upstream) != 0) {
if (handler->perform_http2_upgrade(upstream) != 0) { if (LOG_ENABLED(INFO)) {
return -1; ULOG(INFO, upstream) << "HTTP Upgrade to HTTP/2 failed";
} }
handler->signal_write();
} }
// Stop further processing to complete this request // Stop further processing to complete this request