From 7933e5d1f9b71f0631b763a9ef67d11763469232 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Sat, 20 Sep 2014 11:27:37 -0700 Subject: [PATCH] Use deleted members to prevent copying in rippled (RIPD-268) --- src/ripple/app/ledger/Ledger.h | 4 +++- src/ripple/app/main/LocalCredentials.h | 15 +++++++-------- src/ripple/app/websocket/WSConnection.h | 8 +++----- src/ripple/app/websocket/WSServerHandler.h | 5 ++++- src/ripple/sslutil/CAutoBN_CTX.h | 10 ++++------ src/ripple/testoverlay/api/PeerType.h | 4 +++- src/ripple/types/HashMaps.h | 12 +++++------- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/ripple/app/ledger/Ledger.h b/src/ripple/app/ledger/Ledger.h index a56764e1a..22de78e09 100644 --- a/src/ripple/app/ledger/Ledger.h +++ b/src/ripple/app/ledger/Ledger.h @@ -60,7 +60,6 @@ class SqliteStatement; class Ledger : public std::enable_shared_from_this , public CountedObject - , public beast::Uncopyable { public: static char const* getCountedObjectName () { return "Ledger"; } @@ -118,6 +117,9 @@ public: Ledger (bool dummy, Ledger & previous); // ledger after this one Ledger (Ledger & target, bool isMutable); // snapshot + Ledger (Ledger const&) = delete; + Ledger& operator= (Ledger const&) = delete; + ~Ledger (); static Ledger::pointer getSQL (std::string const& sqlStatement); diff --git a/src/ripple/app/main/LocalCredentials.h b/src/ripple/app/main/LocalCredentials.h index 1691882ea..7722cb5b9 100644 --- a/src/ripple/app/main/LocalCredentials.h +++ b/src/ripple/app/main/LocalCredentials.h @@ -23,10 +23,12 @@ namespace ripple { /** Holds the cryptographic credentials identifying this instance of the server. */ -class LocalCredentials : public beast::Uncopyable +class LocalCredentials { public: LocalCredentials (); + LocalCredentials (LocalCredentials const&) = delete; + LocalCredentials& operator= (LocalCredentials const&) = delete; // Begin processing. // - Maintain peer connectivity through validation and peer management. @@ -50,17 +52,14 @@ public: bool dataStore (std::string const& strKey, std::string const& strValue); private: - LocalCredentials (LocalCredentials const&); // disallowed - LocalCredentials& operator= (const LocalCredentials&); // disallowed - - bool nodeIdentityLoad (); - bool nodeIdentityCreate (); + bool nodeIdentityLoad (); + bool nodeIdentityCreate (); private: std::recursive_mutex mLock; - RippleAddress mNodePublicKey; - RippleAddress mNodePrivateKey; + RippleAddress mNodePublicKey; + RippleAddress mNodePrivateKey; LedgerIndex mLedger; // ledger we last synched to }; diff --git a/src/ripple/app/websocket/WSConnection.h b/src/ripple/app/websocket/WSConnection.h index f43629d8b..b374acf5e 100644 --- a/src/ripple/app/websocket/WSConnection.h +++ b/src/ripple/app/websocket/WSConnection.h @@ -31,7 +31,6 @@ class WSConnection : public std::enable_shared_from_this , public InfoSub , public CountedObject - , public beast::Uncopyable { public: static char const* getCountedObjectName () { return "WSConnection"; } @@ -43,6 +42,9 @@ protected: Resource::Consumer usage, InfoSub::Source& source, bool isPublic, beast::IP::Endpoint const& remoteAddress, boost::asio::io_service& io_service); + WSConnection(WSConnection const&) = delete; + WSConnection& operator= (WSConnection const&) = delete; + virtual ~WSConnection (); virtual void preDestroy () = 0; @@ -69,10 +71,6 @@ protected: bool m_receiveQueueRunning; bool m_isDead; boost::asio::io_service& m_io_service; - -private: - WSConnection (WSConnection const&); - WSConnection& operator= (WSConnection const&); }; //------------------------------------------------------------------------------ diff --git a/src/ripple/app/websocket/WSServerHandler.h b/src/ripple/app/websocket/WSServerHandler.h index b6eebc26b..2c7094195 100644 --- a/src/ripple/app/websocket/WSServerHandler.h +++ b/src/ripple/app/websocket/WSServerHandler.h @@ -35,7 +35,7 @@ class WSConnectionType; struct WSServerHandlerLog; // This tag helps with mutex tracking -struct WSServerHandlerBase : public beast::Uncopyable +struct WSServerHandlerBase { }; @@ -90,6 +90,9 @@ public: { } + WSServerHandler(WSServerHandler const&) = delete; + WSServerHandler& operator= (WSServerHandler const&) = delete; + bool getPublic () { return mPublic; diff --git a/src/ripple/sslutil/CAutoBN_CTX.h b/src/ripple/sslutil/CAutoBN_CTX.h index 21d8d1f19..8a81435be 100644 --- a/src/ripple/sslutil/CAutoBN_CTX.h +++ b/src/ripple/sslutil/CAutoBN_CTX.h @@ -29,15 +29,10 @@ namespace ripple { -class CAutoBN_CTX : public beast::Uncopyable +class CAutoBN_CTX { protected: BN_CTX* pctx; - CAutoBN_CTX& operator= (BN_CTX* pnew) - { - pctx = pnew; - return *this; - } public: CAutoBN_CTX () @@ -54,6 +49,9 @@ public: BN_CTX_free (pctx); } + CAutoBN_CTX (CAutoBN_CTX const&) = delete; + CAutoBN_CTX& operator= (CAutoBN_CTX const&) = delete; + operator BN_CTX* () { return pctx; diff --git a/src/ripple/testoverlay/api/PeerType.h b/src/ripple/testoverlay/api/PeerType.h index 60775b191..c066163c2 100644 --- a/src/ripple/testoverlay/api/PeerType.h +++ b/src/ripple/testoverlay/api/PeerType.h @@ -29,7 +29,6 @@ namespace TestOverlay template class PeerType : public Config - , public beast::Uncopyable { public: typedef typename Config::Peer Peer; @@ -51,6 +50,9 @@ public: { } + PeerType (PeerType const&) = delete; + PeerType& operator= (PeerType const&) = delete; + /** Return the pending Results data associated with this peer. */ /** @{ */ Results& results () diff --git a/src/ripple/types/HashMaps.h b/src/ripple/types/HashMaps.h index b35c04083..93ec0644d 100644 --- a/src/ripple/types/HashMaps.h +++ b/src/ripple/types/HashMaps.h @@ -29,7 +29,7 @@ namespace ripple { done by seeding the hashing function with a random number generated at program startup. */ -class HashMaps : public beast::Uncopyable +class HashMaps { public: /** Golden ratio constant used in hashing functions. @@ -89,13 +89,11 @@ public: } private: - HashMaps () - { - } + HashMaps () = default; + ~HashMaps () = default; - ~HashMaps () - { - } + HashMaps (HashMaps const&) = delete; + HashMaps& operator= (HashMaps const&) = delete; /** Creates and holds a nonce for a type. */