diff options
author | Alex Vakulenko <avakulenko@google.com> | 2016-03-23 11:59:04 -0700 |
---|---|---|
committer | Alex Vakulenko <avakulenko@google.com> | 2016-03-23 11:59:04 -0700 |
commit | 6a269a316d9f146d2f1381e816bda6284b23ebc4 (patch) | |
tree | 7b8aa08621146b81ff42c7beede9e95a32cc7aad | |
parent | aa436b16e8d3425302eed56ffb92ecef4bc8e909 (diff) | |
download | weaved-6a269a316d9f146d2f1381e816bda6284b23ebc4.tar.gz |
weaved: Fix OnProtocolHandlerConnected notification
Web server may have multiple protocol handlers on many ports, but
weave cares only for the default ones on port 80 and 443. When both
handlers are available, we invoke |server_available_callback_| callback.
The current code had a problem that https port was used in condition
twice and also when another protocol handler is connected after the
default http/https ones, the callback will be invoked multiple times.
BUG:27655609
Change-Id: I0982bb37d29974bf7de127405c2aca0190a48a3d
-rw-r--r-- | buffet/webserv_client.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/buffet/webserv_client.cc b/buffet/webserv_client.cc index 030ae59..5b35c8b 100644 --- a/buffet/webserv_client.cc +++ b/buffet/webserv_client.cc @@ -149,14 +149,17 @@ void WebServClient::OnRequest(const RequestHandlerCallback& callback, void WebServClient::OnProtocolHandlerConnected( libwebserv::ProtocolHandler* protocol_handler) { + bool connected = false; if (protocol_handler->GetName() == libwebserv::ProtocolHandler::kHttp) { http_port_ = *protocol_handler->GetPorts().begin(); + connected = true; } else if (protocol_handler->GetName() == libwebserv::ProtocolHandler::kHttps) { https_port_ = *protocol_handler->GetPorts().begin(); certificate_ = protocol_handler->GetCertificateFingerprint(); + connected = true; } - if (https_port_ && https_port_) + if (connected && http_port_ && https_port_) server_available_callback_.Run(); } |