mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 21:51:17 +02:00
- added more debug code and fixed a server bug where client connecting at the same time a server opens a slot would result in a crash sometimes.
This commit is contained in:
@@ -286,7 +286,7 @@ bool EndsWith(const string &str, const string& key)
|
||||
//finds all filenames like path and gets their checksum of all files combined
|
||||
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum) {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// !!! OLD local CACHE
|
||||
//static std::map<string,int32> crcTreeCache;
|
||||
@@ -309,7 +309,7 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string path
|
||||
for(size_t idx = 0; idx < count; ++idx) {
|
||||
string path = paths[idx] + pathSearchString;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s], filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s], filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
||||
|
||||
getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum);
|
||||
}
|
||||
@@ -326,7 +326,7 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string path
|
||||
|
||||
//finds all filenames like path and gets their checksum of all files combined
|
||||
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
||||
|
||||
// !!! OLD local CACHE
|
||||
//static std::map<string,int32> crcTreeCache;
|
||||
@@ -377,7 +377,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
|
||||
}
|
||||
|
||||
if(addFile) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
||||
|
||||
checksum.addFile(p);
|
||||
fileMatchCount++;
|
||||
@@ -445,7 +445,7 @@ vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(ve
|
||||
getFolderTreeContentsCheckSumListRecursively(path, filterFileExt, &checksumFiles);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
crcTreeCache[cacheKey] = checksumFiles;
|
||||
return crcTreeCache[cacheKey];
|
||||
@@ -453,7 +453,7 @@ vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(ve
|
||||
|
||||
//finds all filenames like path and gets the checksum of each file
|
||||
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
||||
|
||||
//static std::map<string,vector<std::pair<string,int32> > > crcTreeCache;
|
||||
string cacheLookupId = string(__FILE__) + intToStr(__LINE__);
|
||||
@@ -467,7 +467,7 @@ vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(co
|
||||
|
||||
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
||||
|
||||
std::string mypath = path;
|
||||
/** Stupid win32 is searching for all files without extension when *. is
|
||||
|
@@ -872,32 +872,26 @@ int Socket::getDataToRead(){
|
||||
|
||||
int Socket::send(const void *data, int dataSize) {
|
||||
ssize_t bytesSent= 0;
|
||||
if(isSocketValid() == true)
|
||||
{
|
||||
if(isSocketValid() == true) {
|
||||
bytesSent = ::send(sock, reinterpret_cast<const char*>(data), dataSize, 0);
|
||||
}
|
||||
if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN)
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,bytesSent,getLastSocketErrorFormattedText().c_str());
|
||||
if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText().c_str());
|
||||
//throwException(szBuf);
|
||||
}
|
||||
else if(bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN)
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #1 EAGAIN during send, trying again...\n",__FILE__,__FUNCTION__);
|
||||
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__);
|
||||
|
||||
time_t tStartTimer = time(NULL);
|
||||
while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= 5))
|
||||
{
|
||||
if(Socket::isWritable(true) == true)
|
||||
{
|
||||
while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= 5)) {
|
||||
if(Socket::isWritable(true) == true) {
|
||||
bytesSent = ::send(sock, reinterpret_cast<const char*>(data), dataSize, 0);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #2 EAGAIN during send, trying again returned: %d\n",__FILE__,__FUNCTION__,bytesSent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(bytesSent <= 0)
|
||||
{
|
||||
if(bytesSent <= 0) {
|
||||
int iErr = getLastSocketError();
|
||||
disconnectSocket();
|
||||
|
||||
@@ -914,24 +908,19 @@ int Socket::receive(void *data, int dataSize)
|
||||
{
|
||||
ssize_t bytesReceived = 0;
|
||||
|
||||
if(isSocketValid() == true)
|
||||
{
|
||||
if(isSocketValid() == true) {
|
||||
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
|
||||
}
|
||||
if(bytesReceived < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN)
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] ERROR READING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,bytesReceived,getLastSocketErrorFormattedText().c_str());
|
||||
if(bytesReceived < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR READING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,getLastSocketErrorFormattedText().c_str());
|
||||
//throwException(szBuf);
|
||||
}
|
||||
else if(bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN)
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #1 EAGAIN during receive, trying again...\n",__FILE__,__FUNCTION__);
|
||||
else if(bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during receive, trying again...\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
time_t tStartTimer = time(NULL);
|
||||
while((bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= 5))
|
||||
{
|
||||
if(Socket::isReadable() == true)
|
||||
{
|
||||
while((bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= 5)) {
|
||||
if(Socket::isReadable() == true) {
|
||||
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #2 EAGAIN during receive, trying again returned: %d\n",__FILE__,__FUNCTION__,bytesReceived);
|
||||
@@ -939,8 +928,7 @@ int Socket::receive(void *data, int dataSize)
|
||||
}
|
||||
}
|
||||
|
||||
if(bytesReceived <= 0)
|
||||
{
|
||||
if(bytesReceived <= 0) {
|
||||
int iErr = getLastSocketError();
|
||||
disconnectSocket();
|
||||
|
||||
@@ -952,26 +940,21 @@ int Socket::receive(void *data, int dataSize)
|
||||
|
||||
int Socket::peek(void *data, int dataSize){
|
||||
ssize_t err = 0;
|
||||
if(isSocketValid() == true)
|
||||
{
|
||||
if(isSocketValid() == true) {
|
||||
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
|
||||
}
|
||||
if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN)
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] ERROR PEEKING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,err,getLastSocketErrorFormattedText().c_str());
|
||||
if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR PEEKING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText().c_str());
|
||||
//throwException(szBuf);
|
||||
|
||||
disconnectSocket();
|
||||
}
|
||||
else if(err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN)
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #1 EAGAIN during peek, trying again...\n",__FILE__,__FUNCTION__);
|
||||
else if(err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during peek, trying again...\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
time_t tStartTimer = time(NULL);
|
||||
while((err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= 5))
|
||||
{
|
||||
if(Socket::isReadable() == true)
|
||||
{
|
||||
while((err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= 5)) {
|
||||
if(Socket::isReadable() == true) {
|
||||
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #2 EAGAIN during peek, trying again returned: %d\n",__FILE__,__FUNCTION__,err);
|
||||
@@ -979,8 +962,7 @@ int Socket::peek(void *data, int dataSize){
|
||||
}
|
||||
}
|
||||
|
||||
if(err <= 0)
|
||||
{
|
||||
if(err <= 0) {
|
||||
int iErr = getLastSocketError();
|
||||
disconnectSocket();
|
||||
|
||||
@@ -1007,8 +989,7 @@ void Socket::setBlock(bool block, PLATFORM_SOCKET socket){
|
||||
}
|
||||
}
|
||||
|
||||
bool Socket::isReadable()
|
||||
{
|
||||
bool Socket::isReadable() {
|
||||
if(isSocketValid() == false) return false;
|
||||
#ifndef WIN32
|
||||
struct timeval tv;
|
||||
@@ -1023,10 +1004,8 @@ bool Socket::isReadable()
|
||||
FD_SET(sock, &set);
|
||||
|
||||
int i= select(sock+1, &set, NULL, NULL, &tv);
|
||||
if(i < 0)
|
||||
{
|
||||
if(difftime(time(NULL),lastDebugEvent) >= 1)
|
||||
{
|
||||
if(i < 0) {
|
||||
if(difftime(time(NULL),lastDebugEvent) >= 1) {
|
||||
lastDebugEvent = time(NULL);
|
||||
|
||||
//throwException("Error selecting socket");
|
||||
@@ -1037,8 +1016,7 @@ bool Socket::isReadable()
|
||||
return (i == 1);
|
||||
}
|
||||
|
||||
bool Socket::isWritable(bool waitOnDelayedResponse)
|
||||
{
|
||||
bool Socket::isWritable(bool waitOnDelayedResponse) {
|
||||
if(isSocketValid() == false) return false;
|
||||
|
||||
#ifndef WIN32
|
||||
@@ -1057,10 +1035,8 @@ bool Socket::isWritable(bool waitOnDelayedResponse)
|
||||
do
|
||||
{
|
||||
int i = select(sock+1, NULL, &set, NULL, &tv);
|
||||
if(i < 0 )
|
||||
{
|
||||
if(difftime(time(NULL),lastDebugEvent) >= 1)
|
||||
{
|
||||
if(i < 0 ) {
|
||||
if(difftime(time(NULL),lastDebugEvent) >= 1) {
|
||||
lastDebugEvent = time(NULL);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] error while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,i,getLastSocketErrorFormattedText().c_str());
|
||||
@@ -1069,21 +1045,17 @@ bool Socket::isWritable(bool waitOnDelayedResponse)
|
||||
|
||||
//throwException("Error selecting socket");
|
||||
}
|
||||
else if(i == 0)
|
||||
{
|
||||
if(difftime(time(NULL),lastDebugEvent) >= 1)
|
||||
{
|
||||
else if(i == 0) {
|
||||
if(difftime(time(NULL),lastDebugEvent) >= 1) {
|
||||
lastDebugEvent = time(NULL);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s] TIMEOUT while selecting socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,i,getLastSocketErrorFormattedText().c_str());
|
||||
}
|
||||
|
||||
if(waitOnDelayedResponse == false)
|
||||
{
|
||||
if(waitOnDelayedResponse == false) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
result = true;
|
||||
}
|
||||
} while(waitOnDelayedResponse == true && result == false);
|
||||
@@ -1092,17 +1064,14 @@ bool Socket::isWritable(bool waitOnDelayedResponse)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Socket::isConnected()
|
||||
{
|
||||
bool Socket::isConnected() {
|
||||
//if the socket is not writable then it is not conencted
|
||||
if(isWritable(false) == false)
|
||||
{
|
||||
if(isWritable(false) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//if the socket is readable it is connected if we can read a byte from it
|
||||
if(isReadable())
|
||||
{
|
||||
if(isReadable()) {
|
||||
char tmp;
|
||||
int err = peek(&tmp, sizeof(tmp));
|
||||
return (err > 0);
|
||||
|
@@ -103,7 +103,9 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||
if(display == 0) {
|
||||
throw std::runtime_error("Couldn't create font: display is 0");
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] trying to load font %s\n",__FILE__,__FUNCTION__,__LINE__,type.c_str());
|
||||
|
||||
XFontStruct* fontInfo = XLoadQueryFont(display, type.c_str());
|
||||
if(!fontInfo) {
|
||||
fontInfo = XLoadQueryFont(display, "fixed");
|
||||
@@ -121,7 +123,7 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||
}
|
||||
metrics.setHeight(height);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] height = %f\n",__FILE__,__FUNCTION__,__LINE__,height);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] height = %f\n",__FILE__,__FUNCTION__,__LINE__,height);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -171,15 +173,15 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
glXUseXFont(fontInfo->fid, 0, charCount, base);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
GLenum glerror = ::glGetError();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] glerror = %d\n",__FILE__,__FUNCTION__,__LINE__,glerror);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] glerror = %d\n",__FILE__,__FUNCTION__,__LINE__,glerror);
|
||||
|
||||
XFreeFont(display, fontInfo);
|
||||
|
||||
|
Reference in New Issue
Block a user