- 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 \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%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\n");

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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