[Orxonox-commit 1126] r5847 - code/branches/core5/src/libraries/network
scheusso at orxonox.net
scheusso at orxonox.net
Thu Oct 1 11:09:06 CEST 2009
Author: scheusso
Date: 2009-10-01 11:09:05 +0200 (Thu, 01 Oct 2009)
New Revision: 5847
Modified:
code/branches/core5/src/libraries/network/Connection.h
code/branches/core5/src/libraries/network/Server.cc
code/branches/core5/src/libraries/network/ServerConnection.cc
code/branches/core5/src/libraries/network/ServerConnection.h
Log:
fixing a bug that made a segfault/memory corruption/corrupted double linked list in some cases of client disconnect
Modified: code/branches/core5/src/libraries/network/Connection.h
===================================================================
--- code/branches/core5/src/libraries/network/Connection.h 2009-10-01 09:07:57 UTC (rev 5846)
+++ code/branches/core5/src/libraries/network/Connection.h 2009-10-01 09:09:05 UTC (rev 5847)
@@ -63,7 +63,7 @@
static Connection* getInstance(){ return Connection::instance_; }
int service(ENetEvent* event);
- void disconnectPeer(ENetPeer *peer);
+ virtual void disconnectPeer(ENetPeer *peer);
void processQueue();
virtual void addClient(ENetEvent* event)=0;
Modified: code/branches/core5/src/libraries/network/Server.cc
===================================================================
--- code/branches/core5/src/libraries/network/Server.cc 2009-10-01 09:07:57 UTC (rev 5846)
+++ code/branches/core5/src/libraries/network/Server.cc 2009-10-01 09:09:05 UTC (rev 5847)
@@ -329,8 +329,6 @@
GamestateManager::removeClient(client);
// inform all the listeners
ClientConnectionListener::broadcastClientDisconnected(client->getID());
-
- delete client; //remove client from list
}
bool Server::chat(const std::string& message){
Modified: code/branches/core5/src/libraries/network/ServerConnection.cc
===================================================================
--- code/branches/core5/src/libraries/network/ServerConnection.cc 2009-10-01 09:07:57 UTC (rev 5846)
+++ code/branches/core5/src/libraries/network/ServerConnection.cc 2009-10-01 09:09:05 UTC (rev 5847)
@@ -30,7 +30,7 @@
#include <cassert>
#include <string>
-#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
#include <enet/enet.h>
#include "util/Debug.h"
@@ -102,6 +102,7 @@
void ServerConnection::disconnectClient(ClientInformation *client)
{
Connection::disconnectPeer( client->getPeer() );
+ std::cout << "disconnecting peer and removing client" << endl;
delete client;
}
@@ -118,14 +119,14 @@
void ServerConnection::disconnectClient(int clientID){
ClientInformation *client = ClientInformation::findClient(clientID);
if(client)
- disconnectClient(client);
+ ServerConnection::disconnectClient(client);
}
void ServerConnection::disconnectClients() {
ENetEvent event;
ClientInformation *temp = ClientInformation::getBegin();
while(temp!=0){
- disconnectClient( temp );
+ ServerConnection::disconnectClient( temp );
temp = temp->next();
}
temp = ClientInformation::getBegin();
Modified: code/branches/core5/src/libraries/network/ServerConnection.h
===================================================================
--- code/branches/core5/src/libraries/network/ServerConnection.h 2009-10-01 09:07:57 UTC (rev 5846)
+++ code/branches/core5/src/libraries/network/ServerConnection.h 2009-10-01 09:09:05 UTC (rev 5847)
@@ -58,7 +58,7 @@
static bool addPacket(ENetPacket *packet, unsigned int ID);
static bool addPacketAll(ENetPacket *packet);
virtual void disconnectClient(ClientInformation *client);
- void disconnectPeer( ENetEvent* event );
+ virtual void disconnectPeer( ENetEvent* event );
void disconnectClient(int clientID);
protected:
ServerConnection();
More information about the Orxonox-commit
mailing list