mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 13:23:59 +02:00
- bugfixes for experimental game data synch check in lobby
- added a fix for socket sending when the send buffer is full and we have more data to send
This commit is contained in:
@@ -508,7 +508,7 @@ void ConnectionSlot::update(bool checkForNewClients) {
|
||||
vctFileList = getFolderTreeContentsCheckSumListRecursively(config.getPathListForType(ptTechs,scenarioDir),"/" + serverInterface->getGameSettings()->getTech() + "/*", ".xml", &vctFileList);
|
||||
}
|
||||
|
||||
string report = networkMessageSynchNetworkGameDataStatus.getTechCRCFileMismatchReport(vctFileList);
|
||||
string report = networkMessageSynchNetworkGameDataStatus.getTechCRCFileMismatchReport(serverInterface->getGameSettings()->getTech(),vctFileList);
|
||||
this->setNetworkGameDataSynchCheckTechMismatchReport(report);
|
||||
}
|
||||
if(networkGameDataSynchCheckOkMap == false) {
|
||||
@@ -532,7 +532,7 @@ void ConnectionSlot::update(bool checkForNewClients) {
|
||||
vctFileList = getFolderTreeContentsCheckSumListRecursively(config.getPathListForType(ptTechs,scenarioDir),"/" + serverInterface->getGameSettings()->getTech() + "/*", ".xml", NULL);
|
||||
//}
|
||||
|
||||
string report = networkMessageSynchNetworkGameDataStatus.getTechCRCFileMismatchReport(vctFileList);
|
||||
string report = networkMessageSynchNetworkGameDataStatus.getTechCRCFileMismatchReport(serverInterface->getGameSettings()->getTech(),vctFileList);
|
||||
this->setNetworkGameDataSynchCheckTechMismatchReport(report);
|
||||
}
|
||||
}
|
||||
|
@@ -504,7 +504,7 @@ NetworkMessageSynchNetworkGameData::NetworkMessageSynchNetworkGameData(const Gam
|
||||
}
|
||||
|
||||
string NetworkMessageSynchNetworkGameData::getTechCRCFileMismatchReport(vector<std::pair<string,int32> > &vctFileList) {
|
||||
string result = "Filecount local: " + intToStr(vctFileList.size()) + " remote: " + intToStr(data.header.techCRCFileCount) + "\n";
|
||||
string result = "Techtree: [" + data.header.tech.getString() + "] Filecount local: " + intToStr(vctFileList.size()) + " remote: " + intToStr(data.header.techCRCFileCount) + "\n";
|
||||
for(int idx = 0; idx < vctFileList.size(); ++idx) {
|
||||
std::pair<string,int32> &fileInfo = vctFileList[idx];
|
||||
bool fileFound = false;
|
||||
@@ -683,8 +683,8 @@ NetworkMessageSynchNetworkGameDataStatus::NetworkMessageSynchNetworkGameDataStat
|
||||
}
|
||||
}
|
||||
|
||||
string NetworkMessageSynchNetworkGameDataStatus::getTechCRCFileMismatchReport(vector<std::pair<string,int32> > &vctFileList) {
|
||||
string result = "Filecount local: " + intToStr(vctFileList.size()) + " remote: " + intToStr(data.header.techCRCFileCount) + "\n";
|
||||
string NetworkMessageSynchNetworkGameDataStatus::getTechCRCFileMismatchReport(string techtree, vector<std::pair<string,int32> > &vctFileList) {
|
||||
string result = "Techtree: [" + techtree + "] Filecount local: " + intToStr(vctFileList.size()) + " remote: " + intToStr(data.header.techCRCFileCount) + "\n";
|
||||
for(int idx = 0; idx < vctFileList.size(); ++idx) {
|
||||
std::pair<string,int32> &fileInfo = vctFileList[idx];
|
||||
bool fileFound = false;
|
||||
|
@@ -464,7 +464,7 @@ public:
|
||||
const NetworkString<maxStringSize> * getTechCRCFileList() const {return &data.detail.techCRCFileList[0];}
|
||||
const int32 * getTechCRCFileCRCList() const {return data.detail.techCRCFileCRCList;}
|
||||
|
||||
string getTechCRCFileMismatchReport(vector<std::pair<string,int32> > &vctFileList);
|
||||
string getTechCRCFileMismatchReport(string techtree, vector<std::pair<string,int32> > &vctFileList);
|
||||
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
@@ -1001,20 +1001,21 @@ int Socket::send(const void *data, int dataSize) {
|
||||
else if(bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during send, trying again...\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor);
|
||||
int attemptCount = 0;
|
||||
time_t tStartTimer = time(NULL);
|
||||
while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= 5)) {
|
||||
while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) &&
|
||||
(difftime(time(NULL),tStartTimer) <= 5)) {
|
||||
attemptCount++;
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
|
||||
|
||||
if(Socket::isWritable(true) == true) {
|
||||
//if(Socket::isWritable(true) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data);
|
||||
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor);
|
||||
bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #2 EAGAIN during send, trying again returned: %d\n",__FILE__,__FUNCTION__,bytesSent);
|
||||
}
|
||||
//}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
|
||||
}
|
||||
}
|
||||
@@ -1022,6 +1023,7 @@ int Socket::send(const void *data, int dataSize) {
|
||||
if(bytesSent > 0 && bytesSent < dataSize) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] need to send more data, trying again getLastSocketError() = %d, bytesSent = %d, dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketError(),bytesSent,dataSize);
|
||||
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor);
|
||||
int totalBytesSent = bytesSent;
|
||||
int attemptCount = 0;
|
||||
time_t tStartTimer = time(NULL);
|
||||
@@ -1031,10 +1033,9 @@ int Socket::send(const void *data, int dataSize) {
|
||||
attemptCount++;
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, totalBytesSent = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,totalBytesSent);
|
||||
|
||||
if(bytesSent > 0 || Socket::isWritable(true) == true) {
|
||||
//if(bytesSent > 0 || Socket::isWritable(true) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data);
|
||||
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor);
|
||||
const char *sendBuf = (const char *)data;
|
||||
bytesSent = ::send(sock, &sendBuf[totalBytesSent], dataSize - totalBytesSent, MSG_NOSIGNAL);
|
||||
|
||||
@@ -1042,10 +1043,12 @@ int Socket::send(const void *data, int dataSize) {
|
||||
totalBytesSent += bytesSent;
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] retry send returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent);
|
||||
}
|
||||
//}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] bytesSent = %d, totalBytesSent = %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,totalBytesSent);
|
||||
|
||||
if(bytesSent > 0) {
|
||||
bytesSent = totalBytesSent;
|
||||
}
|
||||
@@ -1173,7 +1176,7 @@ bool Socket::isReadable() {
|
||||
|
||||
int i = 0;
|
||||
{
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor);
|
||||
//MutexSafeWrapper safeMutex(&dataSynchAccessor);
|
||||
i= select(sock+1, &set, NULL, NULL, &tv);
|
||||
}
|
||||
if(i < 0) {
|
||||
@@ -1208,7 +1211,7 @@ bool Socket::isWritable(bool waitOnDelayedResponse) {
|
||||
{
|
||||
int i = 0;
|
||||
{
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor);
|
||||
//MutexSafeWrapper safeMutex(&dataSynchAccessor);
|
||||
i = select(sock+1, NULL, &set, NULL, &tv);
|
||||
}
|
||||
if(i < 0 ) {
|
||||
|
Reference in New Issue
Block a user