[Orxonox-commit 3518] r8204 - code/branches/masterserver2/src/libraries/network

smerkli at orxonox.net smerkli at orxonox.net
Thu Apr 7 16:37:30 CEST 2011


Author: smerkli
Date: 2011-04-07 16:37:29 +0200 (Thu, 07 Apr 2011)
New Revision: 8204

Modified:
   code/branches/masterserver2/src/libraries/network/MasterServer.cc
   code/branches/masterserver2/src/libraries/network/MasterServer.h
Log:


Modified: code/branches/masterserver2/src/libraries/network/MasterServer.cc
===================================================================
--- code/branches/masterserver2/src/libraries/network/MasterServer.cc	2011-04-07 14:31:37 UTC (rev 8203)
+++ code/branches/masterserver2/src/libraries/network/MasterServer.cc	2011-04-07 14:37:29 UTC (rev 8204)
@@ -103,7 +103,7 @@
    * servers.
    */
   void 
-  MasterServer::helper_cleanupServers()
+  MasterServer::helper_cleanupServers( void )
   {
     /* get an iterator */
     std::list<ServerListElem>::iterator i;
@@ -114,12 +114,20 @@
     /* loop through list elements */
     for( i = mainlist.serverlist.begin(); i 
         != mainlist.serverlist.end(); ++i ) 
-    {
+    { /* see if we have a disconnected peer */
       if( (*i).peer && 
          ((*i).peer->state == ENET_PEER_STATE_DISCONNECTED ||
           (*i).peer->state == ENET_PEER_STATE_ZOMBIE ))
-      { mainlist.delServerByName( (*i).ServerInfo.getServerName() );
-        COUT(2) << "someone timed out.\n";
+      { 
+        /* Remove it from the list */
+        COUT(2) << (char*)(*i).peer->data << " timed out.\n";
+        mainlist.delServerByName( (*i).ServerInfo.getServerName() );
+
+        /* stop iterating, we manipulated the list */
+        /* TODO note: this only removes one dead server per loop
+         * iteration. not beautiful, but one iteration is ~100ms, 
+         * so not really relevant for the moment.
+         */
         break;
       }
     }
@@ -262,9 +270,7 @@
       exit( EXIT_FAILURE );
     }
 
-    /* check for timed out pings and remove those guys from
-     * the server list
-     */
+    /* check for timed out peers and remove those from * the server list */
     helper_cleanupServers();
 
 

Modified: code/branches/masterserver2/src/libraries/network/MasterServer.h
===================================================================
--- code/branches/masterserver2/src/libraries/network/MasterServer.h	2011-04-07 14:31:37 UTC (rev 8203)
+++ code/branches/masterserver2/src/libraries/network/MasterServer.h	2011-04-07 14:37:29 UTC (rev 8204)
@@ -68,8 +68,7 @@
 
       /* helpers */
       void helper_sendlist( ENetEvent *event );
-      void helper_pingServers( void );
-      void helper_cleanupServers();
+      void helper_cleanupServers( void );
 
       /* members */
       ENetAddress address;




More information about the Orxonox-commit mailing list