Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1492


Ignore:
Timestamp:
May 31, 2008, 1:09:12 PM (16 years ago)
Author:
scheusso
Message:

removed some deadlocks and big timeouts in connectionmanager and clientconnection

Location:
code/branches/network/src/network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/ClientConnection.cc

    r1491 r1492  
    133133  }
    134134
    135 //   bool ClientConnection::sendPackets(ENetEvent *event) {
    136 //     if(server==NULL)
    137 //       return false;
    138 //     if(enet_host_service(client, event, NETWORK_SEND_WAIT)>=0){
    139 //       return true;}
    140 //     else
    141 //       return false;
    142 //   }
    143 
    144135  bool ClientConnection::sendPackets() {
    145     ENetEvent event;
    146136    if(server==NULL)
    147137      return false;
    148138    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
    149139    enet_host_flush(client);
     140    lock.unlock();
    150141    return true;
    151142  }
     
    159150      enet_initialize();
    160151      client = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0);
     152      lock.unlock();
    161153    }
    162154    if(client==NULL) {
     
    183175          // add some error handling here ========================
    184176        }
     177        lock.unlock();
    185178      }
    186179      switch(event->type){
     
    201194        continue;
    202195      }
    203       //receiverThread_->yield();
     196      receiverThread_->yield();
    204197    }
    205198    // now disconnect
  • code/branches/network/src/network/ClientConnection.h

    r1491 r1492  
    5454#define NETWORK_PORT 55556
    5555#define NETWORK_CLIENT_MAX_CONNECTIONS 5
    56 #define NETWORK_CLIENT_TIMEOUT 1000
    57 #define NETWORK_SEND_WAIT 500
     56#define NETWORK_CLIENT_TIMEOUT 10
    5857#define NETWORK_CLIENT_CHANNELS 2
    5958
  • code/branches/network/src/network/ConnectionManager.cc

    r1491 r1492  
    169169  }
    170170
    171   /*bool ConnectionManager::sendPackets(ENetEvent *event) {
    172     if(server==NULL)
    173       return false;
    174     if(enet_host_service(server, event, NETWORK_SEND_WAIT)>=0)
    175       return true;
    176     else
    177       return false;
    178   }*/
    179 
    180171  bool ConnectionManager::sendPackets() {
    181172    if(server==NULL)
     
    183174    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
    184175    enet_host_flush(server);
     176    lock.unlock();
    185177    return true;
    186178  }
     
    194186      enet_initialize();
    195187      server = enet_host_create(&bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0);
     188      lock.unlock();
    196189    }
    197190    if(server==NULL){
     
    211204          // add some error handling here ========================
    212205        }
     206        lock.unlock();
    213207      }
    214208      switch(event->type){
     
    235229        case ENET_EVENT_TYPE_NONE:
    236230          delete event;
    237           //receiverThread_->yield();
     231          receiverThread_->yield();
    238232          break;
    239233      }
     
    246240      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
    247241      enet_host_destroy(server);
     242      lock.unlock();
    248243    }
    249244  }
     
    259254        boost::recursive_mutex::scoped_lock lock(enet_mutex_);
    260255        enet_peer_disconnect(temp->getPeer(), 0);
     256        lock.unlock();
    261257      }
    262258      temp = temp->next();
     
    439435      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
    440436      enet_peer_disconnect(client->getPeer(), 0);
     437      lock.unlock();
    441438    }
    442439    removeShip(client);
  • code/branches/network/src/network/ConnectionManager.h

    r1491 r1492  
    6262#define NETWORK_PORT 55556
    6363#define NETWORK_MAX_CONNECTIONS 50
    64 #define NETWORK_WAIT_TIMEOUT 5000
    65 #define NETWORK_SEND_WAIT 5
     64#define NETWORK_WAIT_TIMEOUT 10
    6665
    6766  struct ClientList{
Note: See TracChangeset for help on using the changeset viewer.