- more bugfixes for slot switching and joining in progress games

- disallow server to toggle pause state when client is joining
- fix dmp extension on linux
This commit is contained in:
Mark Vejvoda
2013-03-06 14:29:49 +00:00
parent b8357b8696
commit 560ed46cc0
14 changed files with 205 additions and 90 deletions

View File

@@ -980,8 +980,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
{
bool bResult = false;
if(socketTriggeredList.empty() == false)
{
if(socketTriggeredList.empty() == false) {
/* Watch stdin (fd 0) to see when it has input. */
fd_set rfds;
FD_ZERO(&rfds);
@@ -989,11 +988,9 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
string socketDebugList = "";
PLATFORM_SOCKET imaxsocket = 0;
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
itermap != socketTriggeredList.end(); ++itermap)
{
itermap != socketTriggeredList.end(); ++itermap) {
PLATFORM_SOCKET socket = itermap->first;
if(Socket::isSocketValid(&socket) == true)
{
if(Socket::isSocketValid(&socket) == true) {
FD_SET(socket, &rfds);
imaxsocket = max(socket,imaxsocket);
@@ -1004,8 +1001,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
}
}
if(imaxsocket > 0)
{
if(imaxsocket > 0) {
/* Wait up to 0 seconds. */
struct timeval tv;
tv.tv_sec = 0;
@@ -1017,24 +1013,19 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
//MutexSafeWrapper safeMutex(&dataSynchAccessor);
retval = select((int)imaxsocket + 1, &rfds, NULL, NULL, &tv);
}
if(retval < 0)
{
if(retval < 0) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d, ERROR SELECTING SOCKET DATA retval = %d error = %s, socketDebugList [%s]\n",__FILE__,__FUNCTION__,__LINE__,retval,getLastSocketErrorFormattedText().c_str(),socketDebugList.c_str());
}
else if(retval)
{
else if(retval) {
bResult = true;
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
itermap != socketTriggeredList.end(); ++itermap)
{
itermap != socketTriggeredList.end(); ++itermap) {
PLATFORM_SOCKET socket = itermap->first;
if (FD_ISSET(socket, &rfds))
{
if (FD_ISSET(socket, &rfds)) {
itermap->second = true;
}
else
{
else {
itermap->second = false;
}
}

View File

@@ -16,6 +16,7 @@
#include <algorithm>
#include "platform_util.h"
#include "platform_common.h"
#include <memory>
using namespace std;
@@ -136,6 +137,9 @@ public:
}
};
const bool debugMutexLock = false;
const int debugMutexLockMillisecondThreshold = 2000;
Mutex::Mutex(string ownerId) {
mutexAccessor = SDL_CreateMutex();
SDLMutexSafeWrapper safeMutex(&mutexAccessor);
@@ -151,7 +155,10 @@ Mutex::Mutex(string ownerId) {
}
deleteownerId = "";
//chronoPerf = new Chrono();
chronoPerf = NULL;
if(debugMutexLock == true) {
chronoPerf = new Chrono();
}
}
Mutex::~Mutex() {
@@ -168,8 +175,10 @@ Mutex::~Mutex() {
throw megaglest_runtime_error(szBuf);
}
//delete chronoPerf;
//chronoPerf = NULL;
if(debugMutexLock == true) {
delete chronoPerf;
chronoPerf = NULL;
}
if(mutex != NULL) {
deleteownerId = ownerId;
@@ -184,16 +193,21 @@ void Mutex::p() {
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s] deleteownerId [%s]",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,refCount,ownerId.c_str(),deleteownerId.c_str());
throw megaglest_runtime_error(szBuf);
}
//Chrono chrono;
//chrono.start();
std::auto_ptr<Chrono> chronoLockPerf;
if(debugMutexLock == true) {
chronoLockPerf.reset(new Chrono());
chronoLockPerf->start();
}
SDL_mutexP(mutex);
refCount++;
//if(chrono.getMillis() > 2000) {
// printf("Last ownerid: [%s]\n",lastownerId.c_str());
//}
//chronoPerf->start();
if(debugMutexLock == true) {
if(chronoLockPerf->getMillis() >= debugMutexLockMillisecondThreshold) {
printf("\n**WARNING possible mutex lock detected ms [%lld] Last ownerid: [%s]\n",(long long int)chronoLockPerf->getMillis(),lastownerId.c_str());
}
chronoPerf->start();
}
}
void Mutex::v() {
@@ -205,9 +219,15 @@ void Mutex::v() {
refCount--;
lastownerId = ownerId;
//if(chronoPerf->getMillis() > 2000) {
// lastownerId = PlatformExceptionHandler::getStackTrace();
//}
if(debugMutexLock == true) {
if(chronoPerf->getMillis() >= debugMutexLockMillisecondThreshold) {
printf("About to get stacktrace for stuck mutex ...\n");
string oldLastownerId = lastownerId;
lastownerId = PlatformExceptionHandler::getStackTrace();
printf("\n**WARNING possible mutex lock (on unlock) detected ms [%lld] Last ownerid: [%s]\noldLastownerId: [%s]\n",(long long int)chronoPerf->getMillis(),lastownerId.c_str(),oldLastownerId.c_str());
}
}
SDL_mutexV(mutex);
}