Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3137 for code/branches


Ignore:
Timestamp:
Jun 10, 2009, 12:24:27 PM (15 years ago)
Author:
scheusso
Message:

various performance and memory issues fixed

Location:
code/branches/netp4/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp4/src/network/Client.cc

    r3084 r3137  
    169169      bool b = packet->process();
    170170      assert(b);
     171      delete event;
    171172    }
    172173    if(gamestate.processGamestates())
  • code/branches/netp4/src/network/ClientConnection.cc

    r3084 r3137  
    169169//              assert(0);
    170170          printf("ClientConnection: ENet returned with an error!\n");
    171           quit_=true;
    172           break;
     171//           quit_=true;
     172          continue;
    173173          // add some error handling here ========================
    174174        }
     
    197197      }
    198198    }
     199    delete event;
    199200    // now disconnect
    200201
    201202    if(!disconnectConnection())
     203    {
     204      printf("could not disconnect properly\n");
    202205      // if disconnecting failed destroy conn.
    203206      boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    204207      enet_peer_reset(server);
     208    }
     209    else
     210      printf("properly disconnected\n");
    205211    return;
    206212  }
     
    221227        break;
    222228      case ENET_EVENT_TYPE_DISCONNECT:
     229        printf("received disconnect confirmation from server");
    223230        return true;
    224231      }
  • code/branches/netp4/src/network/ClientInformation.h

    r2773 r3137  
    9191    bool getSynched();
    9292
    93 
    9493  private:
    9594    static ClientInformation *head_;
  • code/branches/netp4/src/network/ConnectionManager.cc

    r3093 r3137  
    132132    quit_=true;
    133133    receiverThread_->join();
     134    delete receiverThread_;
    134135    return true;
    135136  }
     
    206207          // we should never reach this point
    207208          printf("ConnectionManager: ENet returned with an error\n");
    208           quit_=true;
    209           printf("waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhh\n");
     209//           quit_=true;
     210//           printf("waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhh\n");
    210211          continue;
    211212          // add some error handling here ========================
     
    218219//             printf("====================================================================");
    219220        case ENET_EVENT_TYPE_DISCONNECT:
     221//           printf("====================================================================");
    220222        case ENET_EVENT_TYPE_RECEIVE:
    221             processData(event);
    222             event = new ENetEvent;
     223          processData(event);
     224          event = new ENetEvent;
    223225          break;
    224226        case ENET_EVENT_TYPE_NONE:
    225227          //receiverThread_->yield();
    226           msleep(10);
     228          msleep(1);
    227229          break;
    228230      }
  • code/branches/netp4/src/network/ConnectionManager.h

    r3093 r3137  
    5555    const int NETWORK_PORT = 55556;
    5656    const int NETWORK_MAX_CONNECTIONS = 50;
    57     const int NETWORK_WAIT_TIMEOUT = 10;
     57    const int NETWORK_WAIT_TIMEOUT = 1;
    5858    const int NETWORK_DEFAULT_CHANNEL = 0;
    5959
  • code/branches/netp4/src/network/GamestateManager.cc

    r3120 r3137  
    6363  GamestateManager::~GamestateManager()
    6464  {
     65    if( this->reference )
     66      delete this->reference;
     67    for( std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.begin(); it != gamestateQueue.end(); it++ )
     68      delete (*it).second;
    6569    delete trafficControl_;
    6670  }
  • code/branches/netp4/src/network/Server.cc

    r3102 r3137  
    129129  */
    130130  void Server::close() {
     131    ClientInformation *temp = ClientInformation::getBegin();
     132    ClientInformation *temp2;
     133    // disconnect all connected clients
     134    while( temp )
     135    {
     136      temp2 = temp;
     137      temp = temp->next();
     138      disconnectClient( temp2 );
     139    }
    131140    connection->quitListener();
    132141    return;
     
    199208      switch( event->type ) {
    200209      case ENET_EVENT_TYPE_CONNECT:
    201         COUT(3) << "processing event_Type_connect" << std::endl;
     210        COUT(4) << "processing event_Type_connect" << std::endl;
    202211        addClient(event);
    203212        break;
     
    305314      // gs gets automatically deleted by enet callback
    306315    }
     316    delete del;
    307317    return true;
    308318  }
     
    382392    if(!client)
    383393      return false;
     394    else
     395      disconnectClient( client );
     396    return true;
     397  }
     398
     399  void Server::disconnectClient(int clientID){
     400    ClientInformation *client = ClientInformation::findClient(clientID);
     401    if(client)
     402      disconnectClient(client);
     403  }
     404 
     405  void Server::disconnectClient( ClientInformation *client){
     406    connection->disconnectClient(client);
    384407    gamestates_->removeClient(client);
    385 
    386408// inform all the listeners
    387409    ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin();
    388410    while(listener){
    389411      listener->clientDisconnected(client->getID());
    390       listener++;
    391     }
    392 
    393     return ClientInformation::removeClient(event->peer);
    394   }
    395 
    396   void Server::disconnectClient(int clientID){
    397     ClientInformation *client = ClientInformation::findClient(clientID);
    398     if(client)
    399       disconnectClient(client);
    400   }
    401   void Server::disconnectClient( ClientInformation *client){
    402     connection->disconnectClient(client);
    403     gamestates_->removeClient(client);
     412      ++listener;
     413    }
     414    delete client; //remove client from list
    404415  }
    405416
  • code/branches/netp4/src/network/TrafficControl.cc

    r3132 r3137  
    137137        void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
    138138        {
     139    if ( !this->bActive_ )
     140      return;
    139141          std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
    140142
     
    227229        {
    228230
    229           //now the sorting
    230 
    231           //compare listToProcess vs clientListPerm
    232     //if listToProcess contains new Objects, add them to clientListPerm
    233     std::list<obj>::iterator itvec;
     231    if( bActive_ )
     232    {
     233      //now the sorting
     234
     235      //compare listToProcess vs clientListPerm
     236      //if listToProcess contains new Objects, add them to clientListPerm
     237      std::list<obj>::iterator itvec;
    234238   
    235     std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
     239      std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
    236240   
    237           for( itvec=list.begin(); itvec != list.end(); itvec++)
    238           {
    239             if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
    240       {
     241      for( itvec=list.begin(); itvec != list.end(); itvec++)
     242      {
     243        if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
     244        {
    241245        // we already have the object in our map
    242246        //obj bleibt in liste und permanente prio wird berechnet
    243         objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS;
    244         continue;//check next objId
    245       }
    246       else
    247       {
     247          objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS;
     248          continue;//check next objId
     249        }
     250        else
     251        {
    248252        // insert the object into clientListPerm
    249         insertinClientListPerm(clientID,*itvec);
    250         continue;//check next objId
    251       }
    252     }
    253           //end compare listToProcess vs clientListPerm
    254 
    255     if( bActive_ )
    256     {
     253          insertinClientListPerm(clientID,*itvec);
     254          continue;//check next objId
     255        }
     256      }
     257    //end compare listToProcess vs clientListPerm
     258     
    257259      //sort copied list according to priorities
    258260      // use boost bind here because we need to pass a memberfunction to stl sort
     
    275277//       sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
    276278      list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     279     
     280      //diese Funktion updateClientList muss noch gemacht werden
     281      updateClientListTemp(list);
     282      //end of sorting
    277283    }
    278     //diese Funktion updateClientList muss noch gemacht werden
    279     updateClientListTemp(list);
    280     //end of sorting
    281284  }
    282285
  • code/branches/netp4/src/network/packet/Gamestate.cc

    r3120 r3137  
    8080Gamestate::~Gamestate()
    8181{
     82  if( header_ )
     83    delete header_;
    8284}
    8385
     
    99101 
    100102  // create the header object
     103  assert( header_ == 0 );
    101104  header_ = new GamestateHeader(data_);
    102105
  • code/branches/netp4/src/network/synchronisable/Synchronisable.cc

    r3135 r3137  
    9898    // delete callback function objects
    9999    if(!Identifier::isCreatingHierarchy()){
     100      // remove object from the static objectMap
     101      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
     102        deletedObjects_.push(objectID);
     103      // delete all Synchronisable Variables from syncList ( which are also in stringList )
    100104      for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
    101105        delete (*it);
    102       if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
    103         deletedObjects_.push(objectID);
     106      syncList.clear();
     107      stringList.clear();
    104108    }
    105109    std::map<uint32_t, Synchronisable*>::iterator it;
  • code/branches/netp4/src/orxonox/gamestates/GSDedicated.cc

    r3126 r3137  
    163163                                break;
    164164                            default: //not supported...
     165//                                 std::cout << endl << c << endl;
    165166                                break;
    166167                        }
     
    251252    void GSDedicated::setTerminalMode()
    252253    {
     254#ifndef ORXONOX_PLATFORM_WINDOWS
    253255        termios new_settings;
    254256     
     
    262264        COUT(0) << endl;
    263265//       atexit(&GSDedicated::resetTerminalMode);
     266#endif
    264267    }
    265268   
Note: See TracChangeset for help on using the changeset viewer.