]> git.tdb.fi Git - r2c2.git/commitdiff
Prevent certain network errors from crashing the program
authorMikko Rasa <tdb@tdb.fi>
Wed, 6 Apr 2011 07:33:08 +0000 (07:33 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 6 Apr 2011 07:33:08 +0000 (07:33 +0000)
source/network/server.cpp

index 43d22ffef9016f26b376e691d840840bea13a940..b3f4662a05079814bb618062245e0a6215ed8b70 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of R²C²
-Copyright © 2009-2010  Mikkosoft Productions, Mikko Rasa
+Copyright © 2009-2011  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
@@ -117,8 +117,17 @@ template<typename P>
 void Server::send(const P &pkt)
 {
        for(vector<Connection *>::const_iterator i=connections.begin(); i!=connections.end(); ++i)
-               if(!(*i)->stale)
-                       (*i)->comm.send(pkt);
+               if(!(*i)->stale && (*i)->comm.is_handshake_done())
+               {
+                       try
+                       {
+                               (*i)->comm.send(pkt);
+                       }
+                       catch(...)
+                       {
+                               (*i)->stale = true;
+                       }
+               }
 }