mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 09:41:29 -05:00
removed ifdef for the different sleep methods. Now only usleep is used, on all systems. Patch from Phenom
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7629 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c17de671bb
commit
880efee332
@ -632,13 +632,7 @@ void FileIndexMonitor::run()
|
|||||||
if(!isRunning())
|
if(!isRunning())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
usleep(1*1000*1000); // 1 sec
|
||||||
#ifndef WINDOWS_SYS
|
|
||||||
sleep(1);
|
|
||||||
#else
|
|
||||||
Sleep(1000);
|
|
||||||
#endif
|
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
||||||
|
|
||||||
/* check dirs if they've changed */
|
/* check dirs if they've changed */
|
||||||
if (internal_setSharedDirectories())
|
if (internal_setSharedDirectories())
|
||||||
@ -698,16 +692,10 @@ void FileIndexMonitor::updateCycle()
|
|||||||
while(isRunning() && moretodo)
|
while(isRunning() && moretodo)
|
||||||
{
|
{
|
||||||
/* sleep a bit for each loop */
|
/* sleep a bit for each loop */
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
||||||
// csoler: I'm disabling this since it causes a very long update cycle when the number
|
// csoler: I'm disabling this since it causes a very long update cycle when the number
|
||||||
// of directories to go through is very large.
|
// of directories to go through is very large.
|
||||||
//
|
//
|
||||||
// #ifndef WINDOWS_SYS
|
// usleep(100*1000); /* 100 msec */
|
||||||
// usleep(100000); /* 1/10 sec */
|
|
||||||
// #else
|
|
||||||
// Sleep(100);
|
|
||||||
// #endif
|
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
||||||
|
|
||||||
/* check if directories have been updated */
|
/* check if directories have been updated */
|
||||||
|
|
||||||
@ -1127,14 +1115,8 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
|||||||
|
|
||||||
size += to_hash[i].fentries[j].size ;
|
size += to_hash[i].fentries[j].size ;
|
||||||
|
|
||||||
/* don't hit the disk too hard! */
|
// don't hit the disk too hard!
|
||||||
#ifndef WINDOWS_SYS
|
usleep(10*1000); // 10 msec
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
||||||
usleep(10000); /* 10 msec */
|
|
||||||
#else
|
|
||||||
|
|
||||||
Sleep(10);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Save the hashing result every 60 seconds, so has to save what is already hashed.
|
// Save the hashing result every 60 seconds, so has to save what is already hashed.
|
||||||
#ifdef FIM_DEBUG
|
#ifdef FIM_DEBUG
|
||||||
@ -1144,11 +1126,10 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
|||||||
if(hashed_size > last_save_size + MAX_SIZE_WITHOUT_SAVING)
|
if(hashed_size > last_save_size + MAX_SIZE_WITHOUT_SAVING)
|
||||||
{
|
{
|
||||||
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_SAVE_FILE_INDEX, "") ;
|
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_SAVE_FILE_INDEX, "") ;
|
||||||
#ifdef WINDOWS_SYS
|
|
||||||
Sleep(1000) ;
|
//Waiting 1 sec before pass to other hash ??is it really needed??
|
||||||
#else
|
usleep(1*1000*1000); // 1 sec
|
||||||
sleep(1) ;
|
|
||||||
#endif
|
|
||||||
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
||||||
fi.updateHashIndex() ;
|
fi.updateHashIndex() ;
|
||||||
FileIndexMonitor::locked_saveFileIndexes(true) ;
|
FileIndexMonitor::locked_saveFileIndexes(true) ;
|
||||||
|
@ -217,11 +217,8 @@ void ftController::run()
|
|||||||
|
|
||||||
while(isRunning())
|
while(isRunning())
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
//Waiting 1 sec before start
|
||||||
Sleep(1000);
|
usleep(1*1000*1000); // 1 sec
|
||||||
#else
|
|
||||||
sleep(1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "ftController::run()";
|
std::cerr << "ftController::run()";
|
||||||
|
@ -39,9 +39,9 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
/* For Thread Behaviour */
|
/* For Thread Behaviour */
|
||||||
const uint32_t DMULTIPLEX_MIN = 10; /* 1ms sleep */
|
const uint32_t DMULTIPLEX_MIN = 10; /* 10 msec sleep */
|
||||||
const uint32_t DMULTIPLEX_MAX = 1000; /* 1 sec sleep */
|
const uint32_t DMULTIPLEX_MAX = 1000; /* 1 sec sleep */
|
||||||
const double DMULTIPLEX_RELAX = 0.5; /* ??? */
|
const double DMULTIPLEX_RELAX = 0.5; /* relax factor to calculate sleep time if not working in /libretroshare/src/util/rsthreads.cc */
|
||||||
|
|
||||||
static const uint32_t MAX_CHECKING_CHUNK_WAIT_DELAY = 120 ; //! TTL for an inactive chunk
|
static const uint32_t MAX_CHECKING_CHUNK_WAIT_DELAY = 120 ; //! TTL for an inactive chunk
|
||||||
const uint32_t MAX_SIMULTANEOUS_CRC_REQUESTS = 20 ;
|
const uint32_t MAX_SIMULTANEOUS_CRC_REQUESTS = 20 ;
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h> /* for (u)sleep() */
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "util/rsdebug.h"
|
#include "util/rsdebug.h"
|
||||||
|
@ -147,18 +147,13 @@ RsGenExchange::~RsGenExchange()
|
|||||||
void RsGenExchange::run()
|
void RsGenExchange::run()
|
||||||
{
|
{
|
||||||
|
|
||||||
double timeDelta = 0.1; // slow tick
|
double timeDelta = 0.1; // slow tick in sec
|
||||||
|
|
||||||
while(isRunning())
|
while(isRunning()) {
|
||||||
{
|
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
#ifndef WINDOWS_SYS
|
usleep((int) (timeDelta * 1000 *1000)); // timeDelta sec
|
||||||
usleep((int) (timeDelta * 1000000));
|
}//while(isRunning())
|
||||||
#else
|
|
||||||
Sleep((int) (timeDelta * 1000));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGenExchange::tick()
|
void RsGenExchange::tick()
|
||||||
|
@ -487,46 +487,35 @@ void RsGxsNetService::locked_createTransactionFromPending(MsgCircleIdsRequestVet
|
|||||||
locked_pushMsgRespFromList(itemL, msgPend->mPeerId, transN);
|
locked_pushMsgRespFromList(itemL, msgPend->mPeerId, transN);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsGxsNetService::locked_canReceive(const RsGxsGrpMetaData * const grpMeta,
|
/*bool RsGxsNetService::locked_canReceive(const RsGxsGrpMetaData * const grpMeta
|
||||||
const RsPeerId& peerId)
|
, const RsPeerId& peerId )
|
||||||
{
|
{
|
||||||
|
|
||||||
double timeDelta = 0.2;
|
double timeDelta = 0.2;
|
||||||
|
|
||||||
if(grpMeta->mCircleType == GXS_CIRCLE_TYPE_EXTERNAL)
|
if(grpMeta->mCircleType == GXS_CIRCLE_TYPE_EXTERNAL) {
|
||||||
{
|
|
||||||
int i=0;
|
int i=0;
|
||||||
mCircles->loadCircle(grpMeta->mCircleId);
|
mCircles->loadCircle(grpMeta->mCircleId);
|
||||||
|
|
||||||
// check 5 times at most
|
// check 5 times at most
|
||||||
// spin for 1 second at most
|
// spin for 1 second at most
|
||||||
while(i < 5)
|
while(i < 5) {
|
||||||
{
|
|
||||||
#ifndef WINDOWS_SYS
|
|
||||||
usleep((int) (timeDelta * 1000000));
|
|
||||||
#else
|
|
||||||
Sleep((int) (timeDelta * 1000));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(mCircles->isLoaded(grpMeta->mCircleId))
|
if(mCircles->isLoaded(grpMeta->mCircleId)) {
|
||||||
{
|
|
||||||
const RsPgpId& pgpId = mPgpUtils->getPGPId(peerId);
|
const RsPgpId& pgpId = mPgpUtils->getPGPId(peerId);
|
||||||
return mCircles->canSend(grpMeta->mCircleId, pgpId);
|
return mCircles->canSend(grpMeta->mCircleId, pgpId);
|
||||||
}
|
}//if(mCircles->isLoaded(grpMeta->mCircleId))
|
||||||
|
|
||||||
|
|
||||||
|
usleep((int) (timeDelta * 1000 * 1000));// timeDelta sec
|
||||||
i++;
|
i++;
|
||||||
}
|
}//while(i < 5)
|
||||||
|
|
||||||
}
|
} else {//if(grpMeta->mCircleType == GXS_CIRCLE_TYPE_EXTERNAL)
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}//else (grpMeta->mCircleType == GXS_CIRCLE_TYPE_EXTERNAL)
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void RsGxsNetService::collateGrpFragments(GrpFragments fragments,
|
void RsGxsNetService::collateGrpFragments(GrpFragments fragments,
|
||||||
std::map<RsGxsGroupId, GrpFragments>& partFragments) const
|
std::map<RsGxsGroupId, GrpFragments>& partFragments) const
|
||||||
@ -939,26 +928,19 @@ bool RsGxsNetService::locked_processTransac(RsNxsTransac* item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsNetService::run(){
|
void RsGxsNetService::run(){
|
||||||
|
|
||||||
|
|
||||||
double timeDelta = 0.5;
|
double timeDelta = 0.5;
|
||||||
int updateCounter = 0;
|
int updateCounter = 0;
|
||||||
|
|
||||||
while(isRunning()){
|
while(isRunning()){
|
||||||
|
//Start waiting as nothing to do in runup
|
||||||
|
usleep((int) (timeDelta * 1000 * 1000)); // timeDelta sec
|
||||||
|
|
||||||
#ifndef WINDOWS_SYS
|
if(updateCounter >= 20) {
|
||||||
usleep((int) (timeDelta * 1000000));
|
|
||||||
#else
|
|
||||||
Sleep((int) (timeDelta * 1000));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(updateCounter == 20)
|
|
||||||
{
|
|
||||||
updateServerSyncTS();
|
updateServerSyncTS();
|
||||||
updateCounter = 0;
|
updateCounter = 0;
|
||||||
}
|
} else {//if(updateCounter >= 20)
|
||||||
else
|
|
||||||
updateCounter++;
|
updateCounter++;
|
||||||
|
}//else (updateCounter >= 20)
|
||||||
|
|
||||||
// process active transactions
|
// process active transactions
|
||||||
processTransactions();
|
processTransactions();
|
||||||
@ -971,7 +953,7 @@ void RsGxsNetService::run(){
|
|||||||
|
|
||||||
processExplicitGroupRequests();
|
processExplicitGroupRequests();
|
||||||
|
|
||||||
}
|
}//while(isRunning())
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsNetService::updateServerSyncTS()
|
void RsGxsNetService::updateServerSyncTS()
|
||||||
|
@ -340,7 +340,7 @@ private:
|
|||||||
const RsGxsGroupId& grpId, uint32_t& transN,
|
const RsGxsGroupId& grpId, uint32_t& transN,
|
||||||
std::list<RsNxsItem*>& reqList);
|
std::list<RsNxsItem*>& reqList);
|
||||||
|
|
||||||
bool locked_canReceive(const RsGxsGrpMetaData * const grpMeta, const RsPeerId& peerId);
|
//bool locked_canReceive(const RsGxsGrpMetaData * const grpMeta, const RsPeerId& peerId);
|
||||||
|
|
||||||
void processExplicitGroupRequests();
|
void processExplicitGroupRequests();
|
||||||
|
|
||||||
|
@ -182,32 +182,26 @@ void AuthGPG::run()
|
|||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (isRunning())
|
while (isRunning()) {
|
||||||
{
|
usleep(100 * 1000); //100 msec
|
||||||
#ifdef WIN32
|
|
||||||
Sleep(100);
|
|
||||||
#else
|
|
||||||
usleep(100000);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* every 100 milliseconds */
|
/// every 100 milliseconds
|
||||||
processServices();
|
processServices();
|
||||||
|
|
||||||
/* every ten seconds */
|
/// every ten seconds
|
||||||
if (++count >= 100 || _force_sync_database)
|
if (++count >= 100 || _force_sync_database) {
|
||||||
{
|
RsStackMutex stack(gpgMtxService); ///******* LOCKED ******
|
||||||
RsStackMutex stack(gpgMtxService); /******* LOCKED ******/
|
|
||||||
|
|
||||||
// The call does multiple things at once:
|
/// The call does multiple things at once:
|
||||||
// - checks whether the keyring has changed in memory
|
/// - checks whether the keyring has changed in memory
|
||||||
// - checks whether the keyring has changed on disk.
|
/// - checks whether the keyring has changed on disk.
|
||||||
// - merges/updates according to status.
|
/// - merges/updates according to status.
|
||||||
//
|
///
|
||||||
PGPHandler::syncDatabase() ;
|
PGPHandler::syncDatabase() ;
|
||||||
count = 0;
|
count = 0;
|
||||||
_force_sync_database = false ;
|
_force_sync_database = false ;
|
||||||
}
|
}//if (++count >= 100 || _force_sync_database)
|
||||||
}
|
}//while (isRunning())
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthGPG::processServices()
|
void AuthGPG::processServices()
|
||||||
|
@ -3422,7 +3422,7 @@ void p3ChatService::handleRecvDHPublicKey(RsChatDHPublicKeyItem *item)
|
|||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
std::cerr << " Cannot get key. Waiting for caching. try " << i << "/6" << std::endl;
|
std::cerr << " Cannot get key. Waiting for caching. try " << i << "/6" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
usleep(500000) ; // sleep for 500 msec.
|
usleep(500 * 1000) ; // sleep for 500 msec.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break ;
|
break ;
|
||||||
@ -3529,7 +3529,7 @@ bool p3ChatService::locked_sendDHPublicKey(const DistantChatPeerInfo& pinfo)
|
|||||||
if(!mIdService->getPrivateKey(pinfo.own_gxs_id,signature_key) || signature_key.keyData.bin_data == NULL)
|
if(!mIdService->getPrivateKey(pinfo.own_gxs_id,signature_key) || signature_key.keyData.bin_data == NULL)
|
||||||
{
|
{
|
||||||
std::cerr << " Cannot get key. Waiting for caching. try " << i << "/6" << std::endl;
|
std::cerr << " Cannot get key. Waiting for caching. try " << i << "/6" << std::endl;
|
||||||
usleep(500000) ; // sleep for 500 msec.
|
usleep(500 * 1000) ; // sleep for 500 msec.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break ;
|
break ;
|
||||||
|
@ -2005,7 +2005,7 @@ bool p3MsgService::decryptMessage(const std::string& mId)
|
|||||||
if(!mIdService->getKey(senders_id,signature_key) || signature_key.keyData.bin_data == NULL)
|
if(!mIdService->getKey(senders_id,signature_key) || signature_key.keyData.bin_data == NULL)
|
||||||
{
|
{
|
||||||
std::cerr << " Cannot get key. Waiting for caching. try " << i << "/6" << std::endl;
|
std::cerr << " Cannot get key. Waiting for caching. try " << i << "/6" << std::endl;
|
||||||
usleep(500000) ; // sleep for 500 msec.
|
usleep(500 * 1000) ; // sleep for 500 msec.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break ;
|
break ;
|
||||||
|
@ -746,11 +746,7 @@ bool RsDirUtil::renameFile(const std::string& from, const std::string& to)
|
|||||||
#endif
|
#endif
|
||||||
/* set errno? */
|
/* set errno? */
|
||||||
return false ;
|
return false ;
|
||||||
#ifdef WIN32
|
usleep(100 * 1000); // 100 msec
|
||||||
Sleep(200); /* 200 milliseconds */
|
|
||||||
#else
|
|
||||||
usleep(100000); /* 100000 microseconds */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (loops >= 30)
|
if (loops >= 30)
|
||||||
return false ;
|
return false ;
|
||||||
@ -956,11 +952,7 @@ RsStackFileLock::RsStackFileLock(const std::string& file_path)
|
|||||||
while(RsDirUtil::createLockFile(file_path,_file_handle))
|
while(RsDirUtil::createLockFile(file_path,_file_handle))
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot acquire file lock " << file_path << ", waiting 1 sec." << std::endl;
|
std::cerr << "Cannot acquire file lock " << file_path << ", waiting 1 sec." << std::endl;
|
||||||
#ifdef WINDOWS_SYS
|
sleep(1 * 1000 * 1000) ; // 1 sec
|
||||||
Sleep(1000) ;
|
|
||||||
#else
|
|
||||||
sleep(1) ;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#ifdef RSDIR_DEBUG
|
#ifdef RSDIR_DEBUG
|
||||||
std::cerr << "Acquired file handle " << _file_handle << ", lock file:" << file_path << std::endl;
|
std::cerr << "Acquired file handle " << _file_handle << ", lock file:" << file_path << std::endl;
|
||||||
@ -1364,11 +1356,7 @@ bool RsDirUtil::renameWideFile(const std::wstring& from, const std::wstring& to)
|
|||||||
#endif
|
#endif
|
||||||
/* set errno? */
|
/* set errno? */
|
||||||
return false ;
|
return false ;
|
||||||
#ifdef WIN32
|
usleep(100 * 1000); //100 msec
|
||||||
Sleep(100000); /* us */
|
|
||||||
#else
|
|
||||||
usleep(100000); /* us */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (loops >= 30)
|
if (loops >= 30)
|
||||||
return false ;
|
return false ;
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "rsthreads.h"
|
#include "rsthreads.h"
|
||||||
#include <unistd.h> /* for usleep() */
|
#include <unistd.h> // for usleep()
|
||||||
#include <errno.h> /* for usleep() */
|
#include <errno.h> // for errno
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@ -35,10 +35,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WINDOWS_SYS) && defined(__MINGW64_VERSION_MAJOR)
|
|
||||||
#include <windows.h> // for Sleep
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*******
|
/*******
|
||||||
* #define DEBUG_THREADS 1
|
* #define DEBUG_THREADS 1
|
||||||
* #define RSMUTEX_ABORT 1 // Catch wrong pthreads mode.
|
* #define RSMUTEX_ABORT 1 // Catch wrong pthreads mode.
|
||||||
@ -176,11 +172,7 @@ void RsQueueThread::run()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
usleep(mLastSleep * 1000); // mLastSleep msec
|
||||||
Sleep(mLastSleep);
|
|
||||||
#else
|
|
||||||
usleep(1000 * mLastSleep);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user