- added a very useful way to track mutex usage and performance timings of mutex locking to discover thread lock issues

This commit is contained in:
Mark Vejvoda
2011-01-31 23:01:39 +00:00
parent b8075eaf01
commit 0b4eef10c5
15 changed files with 195 additions and 172 deletions

View File

@@ -13,6 +13,7 @@
#include "base_thread.h"
#include "platform_common.h"
#include "util.h"
#include "conversion.h"
#include <time.h>
using namespace Shared::Util;
@@ -48,14 +49,14 @@ Mutex * BaseThread::getMutexThreadOwnerValid() {
}
void BaseThread::setThreadOwnerValid(bool value) {
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid);
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,string(__FILE__) + "_" + intToStr(__LINE__));
threadOwnerValid = value;
safeMutex.ReleaseLock();
}
bool BaseThread::getThreadOwnerValid() {
bool ret = false;
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid);
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,string(__FILE__) + "_" + intToStr(__LINE__));
ret = threadOwnerValid;
safeMutex.ReleaseLock();
@@ -73,7 +74,7 @@ void BaseThread::signalQuit() {
void BaseThread::setQuitStatus(bool value) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
MutexSafeWrapper safeMutex(&mutexQuit);
MutexSafeWrapper safeMutex(&mutexQuit,string(__FILE__) + "_" + intToStr(__LINE__));
quit = value;
safeMutex.ReleaseLock();
@@ -84,7 +85,7 @@ bool BaseThread::getQuitStatus() {
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
bool retval = false;
MutexSafeWrapper safeMutex(&mutexQuit);
MutexSafeWrapper safeMutex(&mutexQuit,string(__FILE__) + "_" + intToStr(__LINE__));
retval = quit;
safeMutex.ReleaseLock();
@@ -95,7 +96,7 @@ bool BaseThread::getQuitStatus() {
bool BaseThread::getHasBeginExecution() {
bool retval = false;
MutexSafeWrapper safeMutex(&mutexBeginExecution);
MutexSafeWrapper safeMutex(&mutexBeginExecution,string(__FILE__) + "_" + intToStr(__LINE__));
retval = hasBeginExecution;
safeMutex.ReleaseLock();
@@ -107,7 +108,7 @@ bool BaseThread::getHasBeginExecution() {
void BaseThread::setHasBeginExecution(bool value) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
MutexSafeWrapper safeMutex(&mutexBeginExecution);
MutexSafeWrapper safeMutex(&mutexBeginExecution,string(__FILE__) + "_" + intToStr(__LINE__));
hasBeginExecution = value;
safeMutex.ReleaseLock();
@@ -118,7 +119,7 @@ bool BaseThread::getRunningStatus() {
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
bool retval = false;
MutexSafeWrapper safeMutex(&mutexRunning);
MutexSafeWrapper safeMutex(&mutexRunning,string(__FILE__) + "_" + intToStr(__LINE__));
retval = running;
safeMutex.ReleaseLock();
@@ -134,7 +135,7 @@ bool BaseThread::getRunningStatus() {
void BaseThread::setRunningStatus(bool value) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] value = %d\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),value);
MutexSafeWrapper safeMutex(&mutexRunning);
MutexSafeWrapper safeMutex(&mutexRunning,string(__FILE__) + "_" + intToStr(__LINE__));
running = value;
setHasBeginExecution(true);
safeMutex.ReleaseLock();
@@ -143,14 +144,14 @@ void BaseThread::setRunningStatus(bool value) {
}
void BaseThread::setExecutingTask(bool value) {
MutexSafeWrapper safeMutex(&mutexExecutingTask);
MutexSafeWrapper safeMutex(&mutexExecutingTask,string(__FILE__) + "_" + intToStr(__LINE__));
executingTask = value;
safeMutex.ReleaseLock();
}
bool BaseThread::getExecutingTask() {
bool retval = false;
MutexSafeWrapper safeMutex(&mutexExecutingTask);
MutexSafeWrapper safeMutex(&mutexExecutingTask,string(__FILE__) + "_" + intToStr(__LINE__));
retval = executingTask;
safeMutex.ReleaseLock();
@@ -159,7 +160,7 @@ bool BaseThread::getExecutingTask() {
bool BaseThread::getDeleteSelfOnExecutionDone() {
bool retval = false;
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone);
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,string(__FILE__) + "_" + intToStr(__LINE__));
retval = deleteSelfOnExecutionDone;
safeMutex.ReleaseLock();
@@ -167,7 +168,7 @@ bool BaseThread::getDeleteSelfOnExecutionDone() {
}
void BaseThread::setDeleteSelfOnExecutionDone(bool value) {
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone);
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,string(__FILE__) + "_" + intToStr(__LINE__));
deleteSelfOnExecutionDone = value;
}

View File

@@ -14,6 +14,7 @@
#include "util.h"
#include "platform_common.h"
#include <algorithm>
#include "conversion.h"
#include "leak_dumper.h"
using namespace std;
@@ -86,13 +87,13 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
this->needTaskSignal = needTaskSignal;
setTaskSignalled(false);
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp);
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,string(__FILE__) + "_" + intToStr(__LINE__));
lastExecuteTimestamp = time(NULL);
}
bool SimpleTaskThread::isThreadExecutionLagging() {
bool result = false;
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp);
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,string(__FILE__) + "_" + intToStr(__LINE__));
result = (difftime(time(NULL),lastExecuteTimestamp) >= 5.0);
safeMutex.ReleaseLock();
@@ -139,7 +140,7 @@ void SimpleTaskThread::execute() {
ExecutingTaskSafeWrapper safeExecutingTaskMutex(this);
this->simpleTaskInterface->simpleTask(this);
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp);
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,string(__FILE__) + "_" + intToStr(__LINE__));
lastExecuteTimestamp = time(NULL);
safeMutex.ReleaseLock();
}
@@ -179,7 +180,7 @@ void SimpleTaskThread::execute() {
void SimpleTaskThread::setTaskSignalled(bool value) {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
MutexSafeWrapper safeMutex(&mutexTaskSignaller);
MutexSafeWrapper safeMutex(&mutexTaskSignaller,string(__FILE__) + "_" + intToStr(__LINE__));
taskSignalled = value;
safeMutex.ReleaseLock();
@@ -190,7 +191,7 @@ bool SimpleTaskThread::getTaskSignalled() {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
bool retval = false;
MutexSafeWrapper safeMutex(&mutexTaskSignaller);
MutexSafeWrapper safeMutex(&mutexTaskSignaller,string(__FILE__) + "_" + intToStr(__LINE__));
retval = taskSignalled;
safeMutex.ReleaseLock();
@@ -207,7 +208,7 @@ LogFileThread::LogFileThread() : BaseThread() {
}
void LogFileThread::addLogEntry(SystemFlags::DebugType type, string logEntry) {
MutexSafeWrapper safeMutex(&mutexLogList);
MutexSafeWrapper safeMutex(&mutexLogList,string(__FILE__) + "_" + intToStr(__LINE__));
LogFileEntry entry;
entry.type = type;
entry.entry = logEntry;
@@ -273,14 +274,14 @@ void LogFileThread::execute() {
}
std::size_t LogFileThread::getLogEntryBufferCount() {
MutexSafeWrapper safeMutex(&mutexLogList);
MutexSafeWrapper safeMutex(&mutexLogList,string(__FILE__) + "_" + intToStr(__LINE__));
std::size_t logCount = logList.size();
safeMutex.ReleaseLock();
return logCount;
}
void LogFileThread::saveToDisk(bool forceSaveAll,bool logListAlreadyLocked) {
MutexSafeWrapper safeMutex(NULL);
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
if(logListAlreadyLocked == false) {
safeMutex.setMutex(&mutexLogList);
}

View File

@@ -19,6 +19,7 @@
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include "conversion.h"
using namespace Shared::Util;
using namespace Shared::PlatformCommon;
@@ -101,7 +102,7 @@ void event_join(irc_session_t * session, const char * event, const char * origin
bool foundNick = false;
MutexSafeWrapper safeMutex(ctx->getMutexNickList());
MutexSafeWrapper safeMutex(ctx->getMutexNickList(),string(__FILE__) + "_" + intToStr(__LINE__));
std::vector<string> nickList = ctx->getCachedNickList();
for(unsigned int i = 0;
i < nickList.size(); ++i) {
@@ -202,7 +203,7 @@ void event_channel(irc_session_t * session, const char * event, const char * ori
IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
if(ctx != NULL) {
MutexSafeWrapper safeMutex(ctx->getMutexIRCCB());
MutexSafeWrapper safeMutex(ctx->getMutexIRCCB(),string(__FILE__) + "_" + intToStr(__LINE__));
IRCCallbackInterface *cb = ctx->getCallbackObj(false);
if(cb != NULL) {
cb->IRC_CallbackEvent(IRC_evt_chatText, realNick, params, count);
@@ -282,7 +283,7 @@ void event_leave(irc_session_t *session, const char *event, const char *origin,
IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
if(ctx != NULL) {
MutexSafeWrapper safeMutex(ctx->getMutexNickList());
MutexSafeWrapper safeMutex(ctx->getMutexNickList(),string(__FILE__) + "_" + intToStr(__LINE__));
std::vector<string> &nickList = ctx->getCachedNickList();
for(unsigned int i = 0;
i < nickList.size(); ++i) {
@@ -334,7 +335,7 @@ void event_numeric(irc_session_t * session, unsigned int event, const char * ori
IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
if(ctx != NULL) {
MutexSafeWrapper safeMutex(ctx->getMutexNickList());
MutexSafeWrapper safeMutex(ctx->getMutexNickList(),string(__FILE__) + "_" + intToStr(__LINE__));
ctx->setCachedNickList(nickList);
}
}
@@ -407,7 +408,7 @@ std::vector<string> IRCThread::GetIRCConnectedNickList(string target, bool waitF
}
}
MutexSafeWrapper safeMutex(&mutexNickList);
MutexSafeWrapper safeMutex(&mutexNickList,string(__FILE__) + "_" + intToStr(__LINE__));
std::vector<string> nickList = eventData;
safeMutex.ReleaseLock();
@@ -424,7 +425,7 @@ bool IRCThread::isConnected() {
}
std::vector<string> IRCThread::getNickList() {
MutexSafeWrapper safeMutex(&mutexNickList);
MutexSafeWrapper safeMutex(&mutexNickList,string(__FILE__) + "_" + intToStr(__LINE__));
std::vector<string> nickList = eventData;
safeMutex.ReleaseLock();
@@ -432,14 +433,14 @@ std::vector<string> IRCThread::getNickList() {
}
IRCCallbackInterface * IRCThread::getCallbackObj(bool lockObj) {
MutexSafeWrapper safeMutex(NULL);
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
if(lockObj == true) {
safeMutex.setMutex(&mutexIRCCB);
}
return callbackObj;
}
void IRCThread::setCallbackObj(IRCCallbackInterface *cb) {
MutexSafeWrapper safeMutex(&mutexIRCCB);
MutexSafeWrapper safeMutex(&mutexIRCCB,string(__FILE__) + "_" + intToStr(__LINE__));
callbackObj=cb;
}
@@ -541,7 +542,7 @@ void IRCThread::execute() {
// Delete ourself when the thread is done (no other actions can happen after this
// such as the mutex which modifies the running status of this method
MutexSafeWrapper safeMutex(&mutexIRCCB);
MutexSafeWrapper safeMutex(&mutexIRCCB,string(__FILE__) + "_" + intToStr(__LINE__));
IRCCallbackInterface *cb = getCallbackObj(false);
if(cb != NULL) {
cb->IRC_CallbackEvent(IRC_evt_exitThread, NULL, NULL, 0);

View File

@@ -18,6 +18,7 @@
#include <curl/types.h>
#include <curl/easy.h>
#include <algorithm>
#include "conversion.h"
using namespace Shared::Util;
using namespace Shared::PlatformCommon;
@@ -185,7 +186,7 @@ int file_progress(struct FtpFile *out,double download_total, double download_now
stats.upload_now = upload_now;
stats.currentFilename = out->currentFilename;
MutexSafeWrapper safeMutex(out->ftpServer->getProgressMutex());
MutexSafeWrapper safeMutex(out->ftpServer->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
out->ftpServer->getCallBackObject()->FTPClient_CallbackEvent(out->itemName, ftp_cct_DownloadProgress, ftp_crt_SUCCESS, &stats);
}
@@ -309,21 +310,21 @@ void FTPClientThread::getMapFromServer(string mapFileName) {
}
}
MutexSafeWrapper safeMutex(this->getProgressMutex());
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
if(this->pCBObject != NULL) {
this->pCBObject->FTPClient_CallbackEvent(mapFileName,ftp_cct_Map,result,NULL);
}
}
void FTPClientThread::addMapToRequests(string mapFilename) {
MutexSafeWrapper safeMutex(&mutexMapFileList);
MutexSafeWrapper safeMutex(&mutexMapFileList,string(__FILE__) + "_" + intToStr(__LINE__));
if(std::find(mapFileList.begin(),mapFileList.end(),mapFilename) == mapFileList.end()) {
mapFileList.push_back(mapFilename);
}
}
void FTPClientThread::addTilesetToRequests(string tileSetName) {
MutexSafeWrapper safeMutex(&mutexTilesetList);
MutexSafeWrapper safeMutex(&mutexTilesetList,string(__FILE__) + "_" + intToStr(__LINE__));
if(std::find(tilesetList.begin(),tilesetList.end(),tileSetName) == tilesetList.end()) {
tilesetList.push_back(tileSetName);
}
@@ -335,7 +336,7 @@ void FTPClientThread::getTilesetFromServer(string tileSetName) {
result = getTilesetFromServer(tileSetName, "", FTP_TILESETS_USERNAME, FTP_COMMON_PASSWORD);
}
MutexSafeWrapper safeMutex(this->getProgressMutex());
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
if(this->pCBObject != NULL) {
this->pCBObject->FTPClient_CallbackEvent(tileSetName,ftp_cct_Tileset,result,NULL);
}
@@ -492,12 +493,12 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName,
}
FTPClientCallbackInterface * FTPClientThread::getCallBackObject() {
MutexSafeWrapper safeMutex(this->getProgressMutex());
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
return pCBObject;
}
void FTPClientThread::setCallBackObject(FTPClientCallbackInterface *value) {
MutexSafeWrapper safeMutex(this->getProgressMutex());
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
pCBObject = value;
}
@@ -515,7 +516,7 @@ void FTPClientThread::execute() {
try {
while(this->getQuitStatus() == false) {
MutexSafeWrapper safeMutex(&mutexMapFileList);
MutexSafeWrapper safeMutex(&mutexMapFileList,string(__FILE__) + "_" + intToStr(__LINE__));
if(mapFileList.size() > 0) {
string mapFilename = mapFileList[0];
mapFileList.erase(mapFileList.begin() + 0);
@@ -531,7 +532,7 @@ void FTPClientThread::execute() {
break;
}
MutexSafeWrapper safeMutex2(&mutexTilesetList);
MutexSafeWrapper safeMutex2(&mutexTilesetList,string(__FILE__) + "_" + intToStr(__LINE__));
if(tilesetList.size() > 0) {
string tileset = tilesetList[0];
tilesetList.erase(tilesetList.begin() + 0);

View File

@@ -811,7 +811,7 @@ void Socket::simpleTask(BaseThread *callingThread) {
for(std::map<string,double>::iterator iterMap = pingCache.begin();
iterMap != pingCache.end(); iterMap++) {
MutexSafeWrapper safeMutex(&pingThreadAccessor);
MutexSafeWrapper safeMutex(&pingThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
iterMap->second = getAveragePingMS(iterMap->first, 1);
safeMutex.ReleaseLock();
}
@@ -835,7 +835,7 @@ void Socket::disconnectSocket() {
if(isSocketValid() == true) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] calling shutdown and close for socket = %d...\n",__FILE__,__FUNCTION__,sock);
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
::shutdown(sock,2);
#ifndef WIN32
::close(sock);
@@ -1032,7 +1032,7 @@ int Socket::send(const void *data, int dataSize) {
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
errno = 0;
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
#ifdef __APPLE__
@@ -1066,7 +1066,7 @@ int Socket::send(const void *data, int dataSize) {
if(isConnected() == 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);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
#ifdef __APPLE__
bytesSent = ::send(sock, (const char *)data, dataSize, SO_NOSIGPIPE);
#else
@@ -1106,7 +1106,7 @@ int Socket::send(const void *data, int dataSize) {
if(isConnected() == 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);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
const char *sendBuf = (const char *)data;
#ifdef __APPLE__
bytesSent = ::send(sock, &sendBuf[totalBytesSent], dataSize - totalBytesSent, SO_NOSIGPIPE);
@@ -1163,7 +1163,7 @@ int Socket::receive(void *data, int dataSize) {
ssize_t bytesReceived = 0;
if(isSocketValid() == true) {
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
}
if(bytesReceived < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
@@ -1184,7 +1184,7 @@ int Socket::receive(void *data, int dataSize) {
break;
}
else if(Socket::isReadable() == true) {
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during receive, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived);
@@ -1207,7 +1207,7 @@ int Socket::peek(void *data, int dataSize) {
ssize_t err = 0;
if(isSocketValid() == true) {
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
}
if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
@@ -1230,7 +1230,7 @@ int Socket::peek(void *data, int dataSize) {
break;
}
else if(Socket::isReadable() == true) {
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during peek, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,err);
@@ -1285,7 +1285,7 @@ bool Socket::isReadable() {
int i = 0;
{
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
i= select((int)sock + 1, &set, NULL, NULL, &tv);
}
if(i < 0) {
@@ -1323,7 +1323,7 @@ bool Socket::isWritable(bool waitOnDelayedResponse) {
int i = 0;
{
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
i = select((int)sock + 1, NULL, &set, NULL, &tv);
}
if(i < 0 ) {
@@ -1506,7 +1506,7 @@ void ClientSocket::connect(const Ip &ip, int port)
FD_SET(sock, &myset);
{
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
err = select((int)sock + 1, NULL, &myset, NULL, &tv);
}
@@ -1887,7 +1887,7 @@ Socket *ServerSocket::accept() {
struct sockaddr_in cli_addr;
socklen_t clilen = sizeof(cli_addr);
char client_host[100]="";
MutexSafeWrapper safeMutex(&dataSynchAccessor);
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
PLATFORM_SOCKET newSock= ::accept(sock, (struct sockaddr *) &cli_addr, &clilen);
safeMutex.ReleaseLock();