- Attempt to use libcurl in a thread safe manner

This commit is contained in:
Mark Vejvoda
2010-06-23 14:49:20 +00:00
parent e0b9089eeb
commit 87b4706940
14 changed files with 220 additions and 158 deletions

View File

@@ -33,7 +33,7 @@ BaseThread::BaseThread() : Thread() {
BaseThread::~BaseThread() {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
shutdownAndWait();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
}
void BaseThread::signalQuit() {
@@ -98,20 +98,20 @@ void BaseThread::shutdownAndWait(BaseThread *pThread) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
pThread->signalQuit();
sleep(0);
//sleep(0);
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 7; ) {
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 5; ) {
if(pThread->getRunningStatus() == false) {
break;
}
sleep(0);
sleep(1);
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
//sleep(0);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
}
//sleep(0);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
}
void BaseThread::shutdownAndWait() {

View File

@@ -145,7 +145,7 @@ void SimpleTaskThread::execute() {
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
setRunningStatus(false);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
}
void SimpleTaskThread::setTaskSignalled(bool value) {

View File

@@ -708,6 +708,7 @@ float Socket::getThreadedPingMS(std::string host) {
if(pingThread == NULL) {
lastThreadedPing = 0;
pingThread = new SimpleTaskThread(this,0,50);
pingThread->setUniqueID(__FILE__ + "_" + __FUNCTION);
pingThread->start();
}
@@ -1216,6 +1217,7 @@ void ClientSocket::startBroadCastClientThread(DiscoveredServersInterface *cb) {
ClientSocket::stopBroadCastClientThread();
broadCastClientThread = new BroadCastClientSocketThread(cb);
broadCastClientThread->setUniqueID(string(__FILE__) + string("_") + string(__FUNCTION__));
broadCastClientThread->start();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -1495,6 +1497,7 @@ void ServerSocket::startBroadCastThread() {
stopBroadCastThread();
broadCastThread = new BroadCastSocketThread();
broadCastThread->setUniqueID(string(__FILE__) + string("_") + string(__FUNCTION__));
broadCastThread->start();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);