From b46ee6da376a4dc717ce2a2c68c0f59ae8225b1b Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sun, 21 Sep 2014 23:14:24 +0300 Subject: [PATCH] Handle failures in Conn ctor. --- .../plugins/configuration/sgconfig/configproto.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp b/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp index 17a226be..fabeb54a 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp @@ -231,9 +231,16 @@ void CONFIGPROTO::AcceptConnection() assert(m_users != NULL); assert(m_tariffs != NULL); - m_conns.push_back(new STG::Conn(*m_settings, *m_admins, *m_users, *m_tariffs, sock, outerAddr)); - - printfd(__FILE__, "New connection from %s:%d\n", inet_ntostring(m_conns.back()->IP()).c_str(), m_conns.back()->Port()); + try + { + m_conns.push_back(new STG::Conn(*m_settings, *m_admins, *m_users, *m_tariffs, sock, outerAddr)); + printfd(__FILE__, "New connection from %s:%d\n", inet_ntostring(m_conns.back()->IP()).c_str(), m_conns.back()->Port()); + } + catch (const STG::Conn::Error & error) + { + // Unlikely. + m_logger(std::string("Failed to create new client connection: '") + error.what() + "'."); + } } /* void CONFIGPROTO::WriteLogAccessFailed(uint32_t ip) -- 2.44.2