Merge branch 'feature-cleanup' of github.com:vinniefalco/rippled into develop

This commit is contained in:
JoelKatz
2013-07-03 18:36:17 -07:00
31 changed files with 2802 additions and 3272 deletions

View File

@@ -266,7 +266,20 @@ private:
};
Application::Application ()
//
// VFALCO NOTE Change this to control whether or not the Application
// object is destroyed on exit
//
#if 1
// Application object will be deleted on exit. If the code doesn't exit
// cleanly this could cause hangs or crashes on exit.
//
: SharedSingleton <Application> (SingletonLifetime::persistAfterCreation)
#else
// This will make it so that the Application object is not deleted on exit.
//
: SharedSingleton <Application> (SingletonLifetime::neverDestroyed)
#endif
, mIOService ((theConfig.NODE_SIZE >= 2) ? 2 : 1)
, mIOWork (mIOService)
, mAuxWork (mAuxService)
@@ -308,6 +321,21 @@ Application::Application ()
HashMaps::getInstance ().initializeNonce <size_t> ();
}
Application::~Application ()
{
// VFALCO TODO Wrap these in ScopedPointer
delete mTxnDB;
delete mLedgerDB;
delete mWalletDB;
delete mHashNodeDB;
delete mNetNodeDB;
delete mPathFindDB;
delete mHashNodeLDB;
if (mEphemeralLDB != nullptr)
delete mEphemeralLDB;
}
// VFALCO TODO Tidy these up into some class with accessors.
//
extern const char* RpcDBInit[], *TxnDBInit[], *LedgerDBInit[], *WalletDBInit[], *HashNodeDBInit[],
@@ -666,10 +694,18 @@ void Application::run ()
if (mWSPrivateDoor)
mWSPrivateDoor->stop ();
getApp().getLoadManager().stopThread();
// VFALCO TODO Try to not have to do this early, by using observers to
// eliminate LoadManager's dependency inversions.
//
// This deletes the object and therefore, stops the thread.
m_loadManager = nullptr;
mSweepTimer.cancel();
WriteLog (lsINFO, Application) << "Done.";
// VFALCO NOTE This is a sign that something is wrong somewhere, it
// shouldn't be necessary to sleep until some flag is set.
while (mShutdown)
boost::this_thread::sleep (boost::posix_time::milliseconds (100));
}
@@ -705,21 +741,6 @@ void Application::sweep ()
mSweepTimer.async_wait (BIND_TYPE (&Application::sweep, this));
}
Application::~Application ()
{
// VFALCO TODO Wrap these in ScopedPointer
delete mTxnDB;
delete mLedgerDB;
delete mWalletDB;
delete mHashNodeDB;
delete mNetNodeDB;
delete mPathFindDB;
delete mHashNodeLDB;
if (mEphemeralLDB != nullptr)
delete mEphemeralLDB;
}
void Application::startNewLedger ()
{
// New stuff.

View File

@@ -208,23 +208,27 @@ class ILoadManager
public:
/** Create a new manager.
The manager thread begins running immediately.
@note The thresholds for warnings and punishments are in
the ctor-initializer
*/
static ILoadManager* New ();
/** Destroy the manager.
The destructor returns only after the thread has stopped.
*/
virtual ~ILoadManager () { }
/** Start the associated thread.
This is here to prevent the deadlock detector from activating during
a lengthy program initialization.
@note In stand-alone mode, this might not get called.
*/
// VFALCO TODO Simplify the two stage initialization to one stage (construction).
// NOTE In stand-alone mode the load manager thread isn't started
virtual void startThread () = 0;
virtual void stopThread () = 0;
/** Turn on deadlock detection.

View File

@@ -67,7 +67,6 @@ public:
, mDebitWarn (-500)
, mDebitLimit (-1000)
, mArmed (false)
, mRunning (false)
, mDeadLock (0)
, mCosts (LT_MAX)
{
@@ -110,6 +109,8 @@ public:
addCost (Cost (LT_RequestData, -5, flagDisk | flagNet));
addCost (Cost (LT_CheapQuery, -1, flagCpu));
UptimeTimer::getInstance ().beginManualUpdates ();
}
private:
@@ -117,29 +118,12 @@ private:
{
UptimeTimer::getInstance ().endManualUpdates ();
if (mRunning)
{
m_thread.interrupt ();
m_thread.join ();
}
m_thread.interrupt ();
}
void startThread ()
{
UptimeTimer::getInstance ().beginManualUpdates ();
m_thread.start (this);
mRunning = true;
}
void stopThread()
{
if (mRunning)
{
m_thread.interrupt ();
m_thread.join ();
mRunning = false;
}
}
void canonicalize (LoadSource& source, int now) const
@@ -417,7 +401,7 @@ private:
int mDebitWarn; // when a source drops below this, we warn
int mDebitLimit; // when a source drops below this, we cut it off (should be negative)
bool mArmed, mRunning;
bool mArmed;
int mDeadLock; // Detect server deadlocks

View File

@@ -38,6 +38,7 @@ bool powResultInfo (POWResult powCode, std::string& strToken, std::string& strHu
return iIndex >= 0;
}
// VFALCO TODO Move these to a header because they are used by ripple_ProofOfWorkFactory.cpp
const uint256 ProofOfWork::sMinTarget ("00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
const int ProofOfWork::sMaxIterations (1 << 23);
const int ProofOfWork::sMaxDifficulty (30);

View File

@@ -1,38 +0,0 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
#ifndef RIPPLE_VERSION_H
#define RIPPLE_VERSION_H
//
// Versions
//
// VFALCO TODO Roll this together into ripple_BuildVersion
#define SERVER_VERSION_MAJOR 0
#define SERVER_VERSION_MINOR 9
#define SERVER_VERSION_SUB "-b"
#define SERVER_NAME "Ripple"
#define SV_STRINGIZE(x) SV_STRINGIZE2(x)
#define SV_STRINGIZE2(x) #x
#define SERVER_VERSION \
(SERVER_NAME "-" SV_STRINGIZE(SERVER_VERSION_MAJOR) "." SV_STRINGIZE(SERVER_VERSION_MINOR) SERVER_VERSION_SUB)
// Version we prefer to speak:
#define PROTO_VERSION_MAJOR 1
#define PROTO_VERSION_MINOR 2
// Version we will speak to:
#define MIN_PROTO_MAJOR 1
#define MIN_PROTO_MINOR 2
#define MAKE_VERSION_INT(maj,min) ((maj << 16) | min)
#define GET_VERSION_MAJOR(ver) (ver >> 16)
#define GET_VERSION_MINOR(ver) (ver & 0xff)
#endif
// vim:ts=4