From 156556ddd2128e8e9a73a7166985639228015bcf Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 28 Oct 2020 17:18:33 -0700 Subject: web_service: web_backend: Handle socket errors with GenericRequest. - Fixes a shutdown crash when we try to submit telemetry if there is a service issue. --- src/web_service/web_backend.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/web_service') diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp index c56cd7c71..f264b98a0 100644 --- a/src/web_service/web_backend.cpp +++ b/src/web_service/web_backend.cpp @@ -65,6 +65,17 @@ struct Client::Impl { if (cli == nullptr) { cli = std::make_unique(host.c_str()); } + + if (!cli->is_valid()) { + LOG_ERROR(WebService, "Client is invalid, skipping request!"); + return {}; + } + + if (!cli->is_socket_open()) { + LOG_ERROR(WebService, "Failed to open socket, skipping request!"); + return {}; + } + cli->set_connection_timeout(TIMEOUT_SECONDS); cli->set_read_timeout(TIMEOUT_SECONDS); cli->set_write_timeout(TIMEOUT_SECONDS); -- cgit v1.2.3