Tidy up LeakChecked and configuration macro

This commit is contained in:
Vinnie Falco
2013-06-30 09:04:09 -07:00
parent e3974c112e
commit 4d7fe731d8
16 changed files with 203 additions and 164 deletions

View File

@@ -124,22 +124,24 @@ int rippleMain (int argc, char** argv)
// Checks the heap at every allocation and deallocation (slow).
//
Debug::setAlwaysCheckHeap (false);
//Debug::setAlwaysCheckHeap (false);
// Keeps freed memory blocks and fills them with a guard value.
//
Debug::setHeapDelayedFree (false);
//Debug::setHeapDelayedFree (false);
// At exit, reports all memory blocks which have not been freed.
//
#if 1
Debug::setHeapReportLeaks (false);
//Debug::setHeapReportLeaks (false);
#else
// This is some temporary leak checking test code
//
Debug::setHeapReportLeaks (true);
malloc (512); // Any leaks before this line in the output are from static initializations.
ThreadWithCallQueue t ("test");
GlobalPagedFreeStore::getInstance ();
t.start ();

View File

@@ -2254,6 +2254,7 @@ void PeerImp::doProofOfWork (Job&, boost::weak_ptr <Peer> peer, ProofOfWork::poi
void PeerImp::doFetchPack (const boost::shared_ptr<protocol::TMGetObjectByHash>& packet)
{
// VFALCO TODO Invert this dependency using an observer and shared state object.
if (getApp().getFeeTrack ().isLoaded ())
{
WriteLog (lsINFO, Peer) << "Too busy to make fetch pack";
@@ -2386,12 +2387,13 @@ Peer::pointer Peer::New (boost::asio::io_service& io_service,
return Peer::pointer (new PeerImp (io_service, ctx, id, inbound));
}
void Peer::applyLoadCharge (const boost::weak_ptr<Peer>& wp, LoadType l)
void Peer::applyLoadCharge (boost::weak_ptr <Peer>& peerToPunish,
LoadType loadThatWasImposed)
{
Peer::pointer p = wp.lock ();
Peer::pointer p = peerToPunish.lock ();
if (p)
p->applyLoadCharge (l);
if (p != nullptr)
{
p->applyLoadCharge (loadThatWasImposed);
}
}
// vim:ts=4

View File

@@ -4,8 +4,8 @@
*/
//==============================================================================
#ifndef RIPPLE_PEER_H
#define RIPPLE_PEER_H
#ifndef RIPPLE_PEER_H_INCLUDED
#define RIPPLE_PEER_H_INCLUDED
// VFALCO TODO Couldn't this be a struct?
typedef std::pair <std::string, int> ipPort;
@@ -15,8 +15,8 @@ class Peer
, LeakChecked <Peer>
{
public:
typedef boost::shared_ptr<Peer> pointer;
typedef const boost::shared_ptr<Peer>& ref;
typedef boost::shared_ptr <Peer> pointer;
typedef pointer const& ref;
static int const psbGotHello = 0;
static int const psbSentHello = 1;
@@ -52,9 +52,6 @@ public:
virtual void detach (const char*, bool onIOStrand) = 0;
//virtual bool samePeer (Peer::ref p) = 0;
//virtual bool samePeer (const Peer& p) = 0;
virtual void sendPacket (const PackedMessage::pointer& packet, bool onStrand) = 0;
virtual void sendGetPeers () = 0;
@@ -62,7 +59,12 @@ public:
virtual void applyLoadCharge (LoadType) = 0;
// VFALCO NOTE what's with this odd parameter passing? Why the static member?
static void applyLoadCharge (const boost::weak_ptr<Peer>&, LoadType);
//
/** Adjust this peer's load balance based on the type of load imposed.
@note Formerly named punishPeer
*/
static void applyLoadCharge (boost::weak_ptr <Peer>& peerTOCharge, LoadType loadThatWasImposed);
virtual Json::Value getJson () = 0;
@@ -90,4 +92,3 @@ public:
};
#endif
// vim:ts=4