diff --git a/lib/base/tlsutility.hpp b/lib/base/tlsutility.hpp index edfdb1c09..b44b902c2 100644 --- a/lib/base/tlsutility.hpp +++ b/lib/base/tlsutility.hpp @@ -43,7 +43,7 @@ String I2_BASE_API SHA256(const String& s); class I2_BASE_API openssl_error : virtual public std::exception, virtual public boost::exception { }; struct errinfo_openssl_error_; -typedef boost::error_info errinfo_openssl_error; +typedef boost::error_info errinfo_openssl_error; inline std::string to_string(const errinfo_openssl_error& e) { diff --git a/lib/remote/apiclient.cpp b/lib/remote/apiclient.cpp index cc0e7a4a4..9b6117fe2 100644 --- a/lib/remote/apiclient.cpp +++ b/lib/remote/apiclient.cpp @@ -116,7 +116,21 @@ void ApiClient::DisconnectSync(void) bool ApiClient::ProcessMessage(void) { - Dictionary::Ptr message = JsonRpc::ReadMessage(m_Stream); + Dictionary::Ptr message; + + if (m_Stream->IsEof()) + return false; + + try { + message = JsonRpc::ReadMessage(m_Stream); + } catch (const openssl_error& ex) { + const unsigned long *pe = boost::get_error_info(ex); + + if (pe && *pe == 0) + return false; /* Connection was closed cleanly */ + + throw; + } if (!message) return false;