mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-12 19:12:28 -04:00
- Added basic infrastructure to plugin system in libretroshare and retroshare-gui.
- ported LinksCloud to a new plugin, and removed it from main sources Next moves: - add gui for managing plugins - handle windows compilation git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4275 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3925a7114a
commit
a2c91a7924
28 changed files with 4676 additions and 243 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
|
||||
#include "rsserver/p3face.h"
|
||||
#include "retroshare/rsplugin.h"
|
||||
|
||||
#include "tcponudp/tou.h"
|
||||
#include <sstream>
|
||||
|
@ -55,7 +56,6 @@ RsServer::RsServer(RsIface &i, NotifyBase &callback)
|
|||
mChannels = NULL;
|
||||
mForums = NULL;
|
||||
/* caches (that need ticking) */
|
||||
mRanking = NULL;
|
||||
|
||||
/* Config */
|
||||
mConfigMgr = NULL;
|
||||
|
@ -96,185 +96,148 @@ static double getCurrentTS()
|
|||
void RsServer::run()
|
||||
{
|
||||
|
||||
double timeDelta = 0.25;
|
||||
double minTimeDelta = 0.1; // 25;
|
||||
double maxTimeDelta = 0.5;
|
||||
double kickLimit = 0.15;
|
||||
double timeDelta = 0.25;
|
||||
double minTimeDelta = 0.1; // 25;
|
||||
double maxTimeDelta = 0.5;
|
||||
double kickLimit = 0.15;
|
||||
|
||||
double avgTickRate = timeDelta;
|
||||
double avgTickRate = timeDelta;
|
||||
|
||||
double lastts, ts;
|
||||
lastts = ts = getCurrentTS();
|
||||
double lastts, ts;
|
||||
lastts = ts = getCurrentTS();
|
||||
|
||||
long lastSec = 0; /* for the slower ticked stuff */
|
||||
long lastSec = 0; /* for the slower ticked stuff */
|
||||
|
||||
int min = 0;
|
||||
int loop = 0;
|
||||
int min = 0;
|
||||
int loop = 0;
|
||||
|
||||
while(isRunning())
|
||||
{
|
||||
#ifndef WINDOWS_SYS
|
||||
usleep((int) (timeDelta * 1000000));
|
||||
#else
|
||||
Sleep((int) (timeDelta * 1000));
|
||||
#endif
|
||||
|
||||
ts = getCurrentTS();
|
||||
double delta = ts - lastts;
|
||||
|
||||
/* for the fast ticked stuff */
|
||||
if (delta > timeDelta)
|
||||
while(isRunning())
|
||||
{
|
||||
#ifdef DEBUG_TICK
|
||||
std::cerr << "Delta: " << delta << std::endl;
|
||||
std::cerr << "Time Delta: " << timeDelta << std::endl;
|
||||
std::cerr << "Avg Tick Rate: " << avgTickRate << std::endl;
|
||||
#ifndef WINDOWS_SYS
|
||||
usleep((int) (timeDelta * 1000000));
|
||||
#else
|
||||
Sleep((int) (timeDelta * 1000));
|
||||
#endif
|
||||
|
||||
lastts = ts;
|
||||
ts = getCurrentTS();
|
||||
double delta = ts - lastts;
|
||||
|
||||
/******************************** RUN SERVER *****************/
|
||||
lockRsCore();
|
||||
|
||||
int moreToTick = ftserver -> tick();
|
||||
|
||||
#ifdef DEBUG_TICK
|
||||
std::cerr << "RsServer::run() ftserver->tick(): moreToTick: " << moreToTick << std::endl;
|
||||
#endif
|
||||
|
||||
unlockRsCore();
|
||||
|
||||
/* tick the connection Manager */
|
||||
mConnMgr->tick();
|
||||
/******************************** RUN SERVER *****************/
|
||||
|
||||
/* adjust tick rate depending on whether there is more.
|
||||
*/
|
||||
|
||||
avgTickRate = 0.2 * timeDelta + 0.8 * avgTickRate;
|
||||
|
||||
if (1 == moreToTick)
|
||||
/* for the fast ticked stuff */
|
||||
if (delta > timeDelta)
|
||||
{
|
||||
timeDelta = 0.9 * avgTickRate;
|
||||
if (timeDelta > kickLimit)
|
||||
#ifdef DEBUG_TICK
|
||||
std::cerr << "Delta: " << delta << std::endl;
|
||||
std::cerr << "Time Delta: " << timeDelta << std::endl;
|
||||
std::cerr << "Avg Tick Rate: " << avgTickRate << std::endl;
|
||||
#endif
|
||||
|
||||
lastts = ts;
|
||||
|
||||
/******************************** RUN SERVER *****************/
|
||||
lockRsCore();
|
||||
|
||||
int moreToTick = ftserver -> tick();
|
||||
|
||||
#ifdef DEBUG_TICK
|
||||
std::cerr << "RsServer::run() ftserver->tick(): moreToTick: " << moreToTick << std::endl;
|
||||
#endif
|
||||
|
||||
unlockRsCore();
|
||||
|
||||
/* tick the connection Manager */
|
||||
mConnMgr->tick();
|
||||
/******************************** RUN SERVER *****************/
|
||||
|
||||
/* adjust tick rate depending on whether there is more.
|
||||
*/
|
||||
|
||||
avgTickRate = 0.2 * timeDelta + 0.8 * avgTickRate;
|
||||
|
||||
if (1 == moreToTick)
|
||||
{
|
||||
/* force next tick in one sec
|
||||
* if we are reading data.
|
||||
*/
|
||||
timeDelta = kickLimit;
|
||||
avgTickRate = kickLimit;
|
||||
timeDelta = 0.9 * avgTickRate;
|
||||
if (timeDelta > kickLimit)
|
||||
{
|
||||
/* force next tick in one sec
|
||||
* if we are reading data.
|
||||
*/
|
||||
timeDelta = kickLimit;
|
||||
avgTickRate = kickLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timeDelta = 1.1 * avgTickRate;
|
||||
}
|
||||
|
||||
/* limiter */
|
||||
if (timeDelta < minTimeDelta)
|
||||
{
|
||||
timeDelta = minTimeDelta;
|
||||
}
|
||||
else if (timeDelta > maxTimeDelta)
|
||||
{
|
||||
timeDelta = maxTimeDelta;
|
||||
}
|
||||
|
||||
/* Fast Updates */
|
||||
|
||||
|
||||
/* now we have the slow ticking stuff */
|
||||
/* stuff ticked once a second (but can be slowed down) */
|
||||
if ((int) ts > lastSec)
|
||||
{
|
||||
lastSec = (int) ts;
|
||||
|
||||
// Every second! (UDP keepalive).
|
||||
//tou_tick_stunkeepalive();
|
||||
|
||||
// every five loops (> 5 secs)
|
||||
if (loop % 5 == 0)
|
||||
else
|
||||
{
|
||||
// update_quick_stats();
|
||||
timeDelta = 1.1 * avgTickRate;
|
||||
}
|
||||
|
||||
// Update All Every 5 Seconds.
|
||||
// These Update Functions do the locking themselves.
|
||||
/* limiter */
|
||||
if (timeDelta < minTimeDelta)
|
||||
{
|
||||
timeDelta = minTimeDelta;
|
||||
}
|
||||
else if (timeDelta > maxTimeDelta)
|
||||
{
|
||||
timeDelta = maxTimeDelta;
|
||||
}
|
||||
|
||||
/* Fast Updates */
|
||||
|
||||
|
||||
/* now we have the slow ticking stuff */
|
||||
/* stuff ticked once a second (but can be slowed down) */
|
||||
if ((int) ts > lastSec)
|
||||
{
|
||||
lastSec = (int) ts;
|
||||
|
||||
// Every second! (UDP keepalive).
|
||||
//tou_tick_stunkeepalive();
|
||||
|
||||
// every five loops (> 5 secs)
|
||||
if (loop % 5 == 0)
|
||||
{
|
||||
// update_quick_stats();
|
||||
|
||||
// Update All Every 5 Seconds.
|
||||
// These Update Functions do the locking themselves.
|
||||
#ifdef DEBUG_TICK
|
||||
std::cerr << "RsServer::run() Updates()" << std::endl;
|
||||
std::cerr << "RsServer::run() Updates()" << std::endl;
|
||||
#endif
|
||||
|
||||
// These two have been completed!
|
||||
//std::cerr << "RsServer::run() UpdateAllCerts()" << std::endl;
|
||||
//UpdateAllCerts();
|
||||
//std::cerr << "RsServer::run() UpdateAllNetwork()" << std::endl;
|
||||
//UpdateAllNetwork();
|
||||
|
||||
// currently Dummy Functions.
|
||||
//std::cerr << "RsServer::run() UpdateAllTransfers()" << std::endl;
|
||||
|
||||
//std::cerr << "RsServer::run() ";
|
||||
//std::cerr << "UpdateRemotePeople()"<<std::endl;
|
||||
//UpdateRemotePeople();
|
||||
|
||||
//std::cerr << "RsServer::run() UpdateAllFiles()" << std::endl;
|
||||
//UpdateAllFiles();
|
||||
|
||||
//std::cerr << "RsServer::run() UpdateAllConfig()" << std::endl;
|
||||
UpdateAllConfig();
|
||||
UpdateAllConfig();
|
||||
|
||||
|
||||
mConfigMgr->tick(); /* saves stuff */
|
||||
|
||||
//std::cerr << "RsServer::run() CheckDHT()" << std::endl;
|
||||
//CheckNetworking();
|
||||
}
|
||||
|
||||
// every 60 loops (> 1 min)
|
||||
if (++loop >= 60)
|
||||
{
|
||||
loop = 0;
|
||||
|
||||
/* force saving FileTransferStatus TODO */
|
||||
//ftserver->saveFileTransferStatus();
|
||||
|
||||
/* see if we need to resave certs */
|
||||
//AuthSSL::getAuthSSL()->CheckSaveCertificates();
|
||||
|
||||
/* hour loop */
|
||||
if (++min >= 60)
|
||||
{
|
||||
min = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tick slow services */
|
||||
#ifndef MINIMAL_LIBRS
|
||||
if (mRanking)
|
||||
mRanking->tick();
|
||||
#endif // MINIMAL_LIBRS
|
||||
if(rsPlugins)
|
||||
rsPlugins->slowTickPlugins((time_t)ts);
|
||||
|
||||
#if 0
|
||||
std::string opt;
|
||||
std::string val = "VALUE";
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "SEC:" << lastSec;
|
||||
opt = out.str();
|
||||
}
|
||||
// slow update tick as well.
|
||||
// update();
|
||||
} // end of slow tick.
|
||||
|
||||
mGeneralConfig->setSetting(opt, val);
|
||||
#endif
|
||||
|
||||
mConfigMgr->tick(); /* saves stuff */
|
||||
|
||||
}
|
||||
|
||||
// every 60 loops (> 1 min)
|
||||
if (++loop >= 60)
|
||||
{
|
||||
loop = 0;
|
||||
|
||||
/* force saving FileTransferStatus TODO */
|
||||
//ftserver->saveFileTransferStatus();
|
||||
|
||||
/* see if we need to resave certs */
|
||||
//AuthSSL::getAuthSSL()->CheckSaveCertificates();
|
||||
|
||||
/* hour loop */
|
||||
if (++min >= 60)
|
||||
{
|
||||
min = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// slow update tick as well.
|
||||
// update();
|
||||
} // end of slow tick.
|
||||
|
||||
} // end of only once a second.
|
||||
}
|
||||
return;
|
||||
} // end of only once a second.
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue