mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
* Added second (temporary) switch to turtle.
* Use session switch for OperatingMode. * made OperatingMode temporary - not saved. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5895 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
80dfa620b2
commit
90415627a2
@ -119,8 +119,8 @@ extern RsServerConfig *rsConfig;
|
||||
|
||||
#define RS_OPMODE_FULL 0x0001
|
||||
#define RS_OPMODE_NOTURTLE 0x0002
|
||||
#define RS_OPMODE_GAMING 0x0004
|
||||
#define RS_OPMODE_MINIMAL 0x0008
|
||||
#define RS_OPMODE_GAMING 0x0003
|
||||
#define RS_OPMODE_MINIMAL 0x0004
|
||||
|
||||
|
||||
class RsConfigStartup
|
||||
|
@ -88,9 +88,14 @@ class RsTurtle
|
||||
RsTurtle() {}
|
||||
virtual ~RsTurtle() {}
|
||||
|
||||
// This is saved permanently.
|
||||
virtual void setEnabled(bool) = 0 ;
|
||||
virtual bool enabled() const = 0 ;
|
||||
|
||||
// This is temporary, used by Operating Mode.
|
||||
virtual void setSessionEnabled(bool) = 0 ;
|
||||
virtual bool sessionEnabled() const = 0 ;
|
||||
|
||||
// Lauches a search request through the pipes, and immediately returns
|
||||
// the request id, which will be further used by the gui to store results
|
||||
// as they come back.
|
||||
|
@ -23,6 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <retroshare/rsturtle.h>
|
||||
#include "rsserver/p3serverconfig.h"
|
||||
#include "services/p3bwctrl.h"
|
||||
|
||||
@ -46,10 +47,14 @@ p3ServerConfig::p3ServerConfig(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr
|
||||
|
||||
mGeneralConfig = genCfg;
|
||||
|
||||
RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/
|
||||
|
||||
mUserLevel = RSCONFIG_USER_LEVEL_NEW; /* START LEVEL */
|
||||
mRateDownload = DEFAULT_DOWNLOAD_KB_RATE;
|
||||
mRateUpload = DEFAULT_UPLOAD_KB_RATE;
|
||||
|
||||
mOpMode = RS_OPMODE_FULL;
|
||||
|
||||
rsConfig = this;
|
||||
}
|
||||
|
||||
@ -320,6 +325,7 @@ uint32_t p3ServerConfig::getConnectModes()
|
||||
|
||||
uint32_t p3ServerConfig::getOperatingMode()
|
||||
{
|
||||
#ifdef SAVE_OPERATING_MODE
|
||||
std::string modestr = mGeneralConfig->getSetting(RS_CONFIG_OPERATING_STRING);
|
||||
uint32_t mode = RS_OPMODE_FULL;
|
||||
|
||||
@ -340,11 +346,16 @@ uint32_t p3ServerConfig::getOperatingMode()
|
||||
mode = RS_OPMODE_MINIMAL;
|
||||
}
|
||||
return mode;
|
||||
#else
|
||||
RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/
|
||||
return mOpMode;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool p3ServerConfig::setOperatingMode(uint32_t opMode)
|
||||
{
|
||||
#ifdef SAVE_OPERATING_MODE
|
||||
std::string modestr = "FULL";
|
||||
switch(opMode)
|
||||
{
|
||||
@ -364,6 +375,12 @@ bool p3ServerConfig::setOperatingMode(uint32_t opMode)
|
||||
break;
|
||||
}
|
||||
mGeneralConfig->setSetting(RS_CONFIG_OPERATING_STRING, modestr);
|
||||
#else
|
||||
{
|
||||
RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/
|
||||
mOpMode = opMode;
|
||||
}
|
||||
#endif
|
||||
return switchToOperatingMode(opMode);
|
||||
}
|
||||
|
||||
@ -372,6 +389,7 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
||||
{
|
||||
float dl_rate = 0;
|
||||
float ul_rate = 0;
|
||||
bool turtle_enabled = true;
|
||||
|
||||
{
|
||||
RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/
|
||||
@ -379,6 +397,9 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
||||
ul_rate = mRateUpload;
|
||||
}
|
||||
|
||||
std::cerr << "p3ServerConfig::switchToOperatingMode(" << opMode << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
switch (opMode)
|
||||
{
|
||||
default:
|
||||
@ -388,17 +409,20 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
||||
/* switch on popups, enable hashing */
|
||||
//setMaxRate(true, mri); // In / Download
|
||||
//setMaxRate(false, mro); // Out / Upload.
|
||||
turtle_enabled = true;
|
||||
break;
|
||||
case RS_OPMODE_NOTURTLE:
|
||||
/* switch on all transfers - except turtle, enable hashing */
|
||||
/* 100% bandwidth */
|
||||
/* switch on popups, enable hashing */
|
||||
turtle_enabled = false;
|
||||
|
||||
break;
|
||||
case RS_OPMODE_GAMING:
|
||||
/* switch on all transfers */
|
||||
/* reduce bandwidth to 25% */
|
||||
/* switch off popups, enable hashing */
|
||||
turtle_enabled = true;
|
||||
|
||||
dl_rate *= 0.25;
|
||||
ul_rate *= 0.25;
|
||||
@ -408,6 +432,7 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
||||
/* reduce bandwidth to 10%, but make sure there is enough for VoIP */
|
||||
/* switch on popups, enable hashing */
|
||||
|
||||
turtle_enabled = false;
|
||||
|
||||
dl_rate *= 0.10;
|
||||
ul_rate *= 0.10;
|
||||
@ -427,8 +452,16 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
||||
{
|
||||
mPqiHandler -> setMaxRate(true, dl_rate);
|
||||
mPqiHandler -> setMaxRate(false, ul_rate);
|
||||
|
||||
std::cerr << "p3ServerConfig::switchToOperatingMode() D/L: " << dl_rate << " U/L: " << ul_rate;
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
|
||||
std::cerr << "p3ServerConfig::switchToOperatingMode() Turtle Mode: " << turtle_enabled;
|
||||
std::cerr << std::endl;
|
||||
|
||||
rsTurtle->setSessionEnabled(turtle_enabled);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@ bool findConfigurationOption(uint32_t key, std::string &keystr);
|
||||
float mRateDownload;
|
||||
float mRateUpload;
|
||||
|
||||
uint32_t mOpMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -105,6 +105,8 @@ p3turtle::p3turtle(p3LinkMgr *lm,ftServer *fs)
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
_turtle_routing_enabled = true ;
|
||||
_turtle_routing_session_enabled = true;
|
||||
|
||||
_ft_server = fs ;
|
||||
_ft_controller = fs->getController() ;
|
||||
|
||||
@ -140,6 +142,25 @@ bool p3turtle::enabled() const
|
||||
return _turtle_routing_enabled ;
|
||||
}
|
||||
|
||||
|
||||
void p3turtle::setSessionEnabled(bool b)
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
_turtle_routing_session_enabled = b;
|
||||
|
||||
if(b)
|
||||
std::cerr << "Enabling turtle routing for this Session" << std::endl;
|
||||
else
|
||||
std::cerr << "Disabling turtle routing for this Session" << std::endl;
|
||||
}
|
||||
|
||||
bool p3turtle::sessionEnabled() const
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
return _turtle_routing_session_enabled ;
|
||||
}
|
||||
|
||||
|
||||
int p3turtle::tick()
|
||||
{
|
||||
// Handle tunnel trafic
|
||||
@ -173,7 +194,7 @@ int p3turtle::tick()
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << "Calling tunnel management." << std::endl ;
|
||||
#endif
|
||||
if(_turtle_routing_enabled)
|
||||
if(_turtle_routing_enabled && _turtle_routing_session_enabled)
|
||||
manageTunnels() ;
|
||||
|
||||
{
|
||||
@ -728,7 +749,7 @@ int p3turtle::handleIncoming()
|
||||
{
|
||||
nhandled++;
|
||||
|
||||
if(!_turtle_routing_enabled)
|
||||
if(!(_turtle_routing_enabled && _turtle_routing_session_enabled))
|
||||
delete item ;
|
||||
else
|
||||
{
|
||||
|
@ -223,6 +223,11 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
||||
virtual void setEnabled(bool) ;
|
||||
virtual bool enabled() const ;
|
||||
|
||||
// This is temporary, used by Operating Mode.
|
||||
// Turtle operates when both enabled() && sessionEnabled() are true.
|
||||
virtual void setSessionEnabled(bool);
|
||||
virtual bool sessionEnabled() const;
|
||||
|
||||
// Lauches a search request through the pipes, and immediately returns
|
||||
// the request id, which will be further used by the gui to store results
|
||||
// as they come back.
|
||||
@ -431,6 +436,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
||||
|
||||
float _max_tr_up_rate ;
|
||||
bool _turtle_routing_enabled ;
|
||||
bool _turtle_routing_session_enabled ;
|
||||
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
// debug function
|
||||
|
Loading…
Reference in New Issue
Block a user