- FINALLY fixed freeze with tomreyn's fuzzer and helped further stabilize mutexes and network messages in threads.

This commit is contained in:
Mark Vejvoda
2011-01-13 08:17:18 +00:00
parent 6f601777ef
commit 469cf14b92
7 changed files with 963 additions and 1099 deletions

View File

@@ -808,7 +808,7 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
printf("\n%s=x\t\t\tdisplays merged ini settings information.",GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS]); printf("\n%s=x\t\t\tdisplays merged ini settings information.",GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS]);
printf("\n \t\tWhere x is an optional property name to filter (default shows all)."); printf("\n \t\tWhere x is an optional property name to filter (default shows all).");
printf("\n \t\texample: %s %s=DebugMode",argv0,GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS]); printf("\n \t\texample: %s %s=DebugMode",argv0,GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS]);
printf("\n%s\t\t\tdisables stack backtrace on errors.",GAME_ARGS[GAME_ARG_DISABLE_BACKTRACE]); printf("\n%s\t\tdisables stack backtrace on errors.",GAME_ARGS[GAME_ARG_DISABLE_BACKTRACE]);
printf("\n%s\t\t\tdisplays verbose information in the console.",GAME_ARGS[GAME_ARG_VERBOSE_MODE]); printf("\n%s\t\t\tdisplays verbose information in the console.",GAME_ARGS[GAME_ARG_VERBOSE_MODE]);
printf("\n\n"); printf("\n\n");

View File

@@ -277,17 +277,14 @@ ConnectionSlot::~ConnectionSlot() {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
} }
void ConnectionSlot::update() { void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
try {
clearThreadErrorList();
if(slotThreadWorker != NULL) { if(slotThreadWorker != NULL) {
slotThreadWorker->purgeCompletedEvents(); slotThreadWorker->purgeCompletedEvents();
} }
update(true);
}
void ConnectionSlot::update(bool checkForNewClients) {
clearThreadErrorList();
try {
if(socket == NULL) { if(socket == NULL) {
if(networkGameDataSynchCheckOkMap) networkGameDataSynchCheckOkMap = false; if(networkGameDataSynchCheckOkMap) networkGameDataSynchCheckOkMap = false;
if(networkGameDataSynchCheckOkTile) networkGameDataSynchCheckOkTile = false; if(networkGameDataSynchCheckOkTile) networkGameDataSynchCheckOkTile = false;
@@ -295,7 +292,6 @@ void ConnectionSlot::update(bool checkForNewClients) {
this->setReceivedDataSynchCheck(false); this->setReceivedDataSynchCheck(false);
// Is the listener socket ready to be read? // Is the listener socket ready to be read?
//if(serverInterface->getServerSocket()->isReadable() == true)
if(checkForNewClients == true) { if(checkForNewClients == true) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] BEFORE accept new client connection, serverInterface->getOpenSlotCount() = %d\n",__FILE__,__FUNCTION__,serverInterface->getOpenSlotCount()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] BEFORE accept new client connection, serverInterface->getOpenSlotCount() = %d\n",__FILE__,__FUNCTION__,serverInterface->getOpenSlotCount());
bool hasOpenSlots = (serverInterface->getOpenSlotCount() > 0); bool hasOpenSlots = (serverInterface->getOpenSlotCount() > 0);
@@ -466,7 +462,6 @@ void ConnectionSlot::update(bool checkForNewClients) {
//check consistency //check consistency
bool compatible = checkVersionComptability(getNetworkVersionString(), networkMessageIntro.getVersionString()); bool compatible = checkVersionComptability(getNetworkVersionString(), networkMessageIntro.getVersionString());
if(compatible == false) { if(compatible == false) {
//if(networkMessageIntro.getVersionString() != getNetworkVersionString()) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
bool versionMatched = false; bool versionMatched = false;
@@ -479,10 +474,10 @@ void ConnectionSlot::update(bool checkForNewClients) {
"\nClient: " + networkMessageIntro.getVersionString() + " player [" + playerNameStr + "]"; "\nClient: " + networkMessageIntro.getVersionString() + " player [" + playerNameStr + "]";
printf("%s\n",sErr.c_str()); printf("%s\n",sErr.c_str());
serverInterface->sendTextMessage("Server and client binary mismatch!!",-1, true); serverInterface->sendTextMessage("Server and client binary mismatch!!",-1, true,lockedSlotIndex);
serverInterface->sendTextMessage(" Server:" + getNetworkVersionString(),-1, true); serverInterface->sendTextMessage(" Server:" + getNetworkVersionString(),-1, true,lockedSlotIndex);
serverInterface->sendTextMessage(" Client: "+ networkMessageIntro.getVersionString(),-1, true); serverInterface->sendTextMessage(" Client: "+ networkMessageIntro.getVersionString(),-1, true,lockedSlotIndex);
serverInterface->sendTextMessage(" Client player [" + playerNameStr + "]",-1, true); serverInterface->sendTextMessage(" Client player [" + playerNameStr + "]",-1, true,lockedSlotIndex);
} }
else { else {
versionMatched = true; versionMatched = true;
@@ -492,18 +487,11 @@ void ConnectionSlot::update(bool checkForNewClients) {
"\nClient: " + networkMessageIntro.getVersionString() + " player [" + playerNameStr + "]"; "\nClient: " + networkMessageIntro.getVersionString() + " player [" + playerNameStr + "]";
printf("%s\n",sErr.c_str()); printf("%s\n",sErr.c_str());
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,sErr.c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,sErr.c_str());
//sendTextMessage("Server and client have different platform mismatch.",-1, true);
//sendTextMessage(" Server:" + networkMessageIntro.getVersionString(),-1, true);
//sendTextMessage(" Client: "+ getNetworkVersionString(),-1, true);
//sendTextMessage(" Client player [" + playerNameStr + "]",-1, true);
} }
if(Config::getInstance().getBool("PlatformConsistencyChecks","true") && if(Config::getInstance().getBool("PlatformConsistencyChecks","true") &&
versionMatched == false) { // error message and disconnect only if checked versionMatched == false) { // error message and disconnect only if checked
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,sErr.c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,sErr.c_str());
//DisplayErrorMessage(sErr);
//quit= true;
close(); close();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,sErr.c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,sErr.c_str());
return; return;

View File

@@ -100,7 +100,7 @@ public:
// class ConnectionSlot // class ConnectionSlot
// ===================================================== // =====================================================
class ConnectionSlot: public NetworkInterface{ class ConnectionSlot: public NetworkInterface {
private: private:
ServerInterface* serverInterface; ServerInterface* serverInterface;
Socket* socket; Socket* socket;
@@ -127,8 +127,7 @@ public:
ConnectionSlot(ServerInterface* serverInterface, int playerIndex); ConnectionSlot(ServerInterface* serverInterface, int playerIndex);
~ConnectionSlot(); ~ConnectionSlot();
void update(bool checkForNewClients); void update(bool checkForNewClients,int lockedSlotIndex);
virtual void update();
void setPlayerIndex(int value) { playerIndex = value; } void setPlayerIndex(int value) { playerIndex = value; }
int getPlayerIndex() {return playerIndex;} int getPlayerIndex() {return playerIndex;}
@@ -181,6 +180,8 @@ protected:
Mutex * getServerSynchAccessor(); Mutex * getServerSynchAccessor();
std::vector<std::string> threadErrorList; std::vector<std::string> threadErrorList;
Mutex socketSynchAccessor; Mutex socketSynchAccessor;
virtual void update() {}
}; };
}}//end namespace }}//end namespace

View File

@@ -418,6 +418,12 @@ NetworkMessageText::NetworkMessageText(const string &text, int teamIndex, int pl
data.playerIndex = playerIndex; data.playerIndex = playerIndex;
} }
NetworkMessageText * NetworkMessageText::getCopy() const {
NetworkMessageText *copy = new NetworkMessageText();
copy->data = this->data;
return copy;
}
bool NetworkMessageText::receive(Socket* socket){ bool NetworkMessageText::receive(Socket* socket){
bool result = NetworkMessage::receive(socket, &data, sizeof(data)); bool result = NetworkMessage::receive(socket, &data, sizeof(data));

View File

@@ -319,6 +319,7 @@ public:
virtual bool receive(Socket* socket); virtual bool receive(Socket* socket);
virtual void send(Socket* socket) const; virtual void send(Socket* socket) const;
NetworkMessageText * getCopy() const;
}; };
#pragma pack(pop) #pragma pack(pop)

File diff suppressed because it is too large Load Diff

View File

@@ -70,6 +70,9 @@ private:
Mutex broadcastMessageQueueThreadAccessor; Mutex broadcastMessageQueueThreadAccessor;
vector<pair<const NetworkMessage *,int> > broadcastMessageQueue; vector<pair<const NetworkMessage *,int> > broadcastMessageQueue;
Mutex inBroadcastMessageThreadAccessor;
bool inBroadcastMessage;
public: public:
ServerInterface(); ServerInterface();
virtual ~ServerInterface(); virtual ~ServerInterface();
@@ -83,11 +86,7 @@ public:
virtual void close(); virtual void close();
virtual void update(); virtual void update();
virtual void updateLobby() virtual void updateLobby() { };
{
}
;
virtual void updateKeyframe(int frameCount); virtual void updateKeyframe(int frameCount);
virtual void waitUntilReady(Checksum *checksum); virtual void waitUntilReady(Checksum *checksum);
virtual void sendTextMessage(const string & text, int teamIndex, bool echoLocal = false); virtual void sendTextMessage(const string & text, int teamIndex, bool echoLocal = false);
@@ -159,8 +158,7 @@ public:
} }
public: public:
Mutex *getServerSynchAccessor() Mutex *getServerSynchAccessor() {
{
return &serverSynchAccessor; return &serverSynchAccessor;
} }
@@ -177,10 +175,12 @@ private:
int64 getNextEventId(); int64 getNextEventId();
void processTextMessageQueue(); void processTextMessageQueue();
void processBroadCastMessageQueue(); void processBroadCastMessageQueue();
void fsf(std::map<PLATFORM_SOCKET,bool> & socketTriggeredList, std::map<int,ConnectionSlotEvent> & eventList, std::map<int,bool> & mapSlotSignalledList);
protected: protected:
void signalClientsToRecieveDataX(std::map<PLATFORM_SOCKET,bool> & socketTriggeredList, std::map<int,ConnectionSlotEvent> & eventList, std::map<int,bool> & mapSlotSignalledList); void signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool> & socketTriggeredList, std::map<int,ConnectionSlotEvent> & eventList, std::map<int,bool> & mapSlotSignalledList);
void test(std::map<PLATFORM_SOCKET,bool> & socketTriggeredList, std::map<int,ConnectionSlotEvent> & eventList, std::map<int,bool> & mapSlotSignalledList); void checkForCompletedClients(std::map<int,bool> & mapSlotSignalledList,std::vector <string> &errorMsgList,std::map<int,ConnectionSlotEvent> &eventList);
void checForLaggingClients(std::map<int,bool> &mapSlotSignalledList, std::map<int,ConnectionSlotEvent> &eventList, std::map<PLATFORM_SOCKET,bool> &socketTriggeredList,std::vector <string> &errorMsgList);
void executeNetworkCommandsFromClients();
void dispatchPendingChatMessages(std::vector <string> &errorMsgList);
}; };
}}//end namespace }}//end namespace