]> git.stg.codes - stg.git/commitdiff
Handle failures in Conn ctor.
authorMaxim Mamontov <faust.madf@gmail.com>
Sun, 21 Sep 2014 20:14:24 +0000 (23:14 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Sun, 21 Sep 2014 20:14:24 +0000 (23:14 +0300)
projects/stargazer/plugins/configuration/sgconfig/configproto.cpp

index 17a226bea6e7309b8257dd9eefc04193e61c8cf4..fabeb54a106db733437c16cf5ba251ed96d6d21a 100644 (file)
@@ -231,9 +231,16 @@ void CONFIGPROTO::AcceptConnection()
     assert(m_users != NULL);
     assert(m_tariffs != NULL);
 
     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)
 }
 /*
 void CONFIGPROTO::WriteLogAccessFailed(uint32_t ip)