http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TSSLSocket.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp index e8f38dd..d8b16e1 100644 --- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp @@ -52,8 +52,8 @@ #include <thrift/transport/PlatformSocket.h> #include <thrift/TToString.h> -using namespace std; using namespace apache::thrift::concurrency; +using std::string; struct CRYPTO_dynlock_value { Mutex mutex; @@ -212,33 +212,33 @@ SSL* SSLContext::createSSL() { } // TSSLSocket implementation -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx) : TSocket(), server_(false), ssl_(NULL), ctx_(ctx) { init(); } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, boost::shared_ptr<THRIFT_SOCKET> interruptListener) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) : TSocket(), server_(false), ssl_(NULL), ctx_(ctx) { init(); interruptListener_ = interruptListener; } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket) : TSocket(socket), server_(false), ssl_(NULL), ctx_(ctx) { init(); } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) : TSocket(socket, interruptListener), server_(false), ssl_(NULL), ctx_(ctx) { init(); } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, string host, int port) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, string host, int port) : TSocket(host, port), server_(false), ssl_(NULL), ctx_(ctx) { init(); } -TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, string host, int port, boost::shared_ptr<THRIFT_SOCKET> interruptListener) +TSSLSocket::TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, string host, int port, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) : TSocket(host, port), server_(false), ssl_(NULL), ctx_(ctx) { init(); interruptListener_ = interruptListener; @@ -807,7 +807,7 @@ TSSLSocketFactory::TSSLSocketFactory(SSLProtocol protocol) : server_(false) { randomize(); } count_++; - ctx_ = boost::shared_ptr<SSLContext>(new SSLContext(protocol)); + ctx_ = stdcxx::shared_ptr<SSLContext>(new SSLContext(protocol)); } TSSLSocketFactory::~TSSLSocketFactory() { @@ -819,47 +819,47 @@ TSSLSocketFactory::~TSSLSocketFactory() { } } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket() { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket() { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(boost::shared_ptr<THRIFT_SOCKET> interruptListener) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, interruptListener)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, interruptListener)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(THRIFT_SOCKET socket) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(THRIFT_SOCKET socket) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket, interruptListener)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket, interruptListener)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host, int port) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host, int port) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port)); setup(ssl); return ssl; } -boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host, int port, boost::shared_ptr<THRIFT_SOCKET> interruptListener) { - boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port, interruptListener)); +stdcxx::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host, int port, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) { + stdcxx::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port, interruptListener)); setup(ssl); return ssl; } -void TSSLSocketFactory::setup(boost::shared_ptr<TSSLSocket> ssl) { +void TSSLSocketFactory::setup(stdcxx::shared_ptr<TSSLSocket> ssl) { ssl->server(server()); if (access_ == NULL && !server()) { - access_ = boost::shared_ptr<AccessManager>(new DefaultClientAccessManager); + access_ = stdcxx::shared_ptr<AccessManager>(new DefaultClientAccessManager); } if (access_ != NULL) { ssl->access(access_);
http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TSSLSocket.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.h b/lib/cpp/src/thrift/transport/TSSLSocket.h index 023db94..8527209 100644 --- a/lib/cpp/src/thrift/transport/TSSLSocket.h +++ b/lib/cpp/src/thrift/transport/TSSLSocket.h @@ -22,10 +22,11 @@ // Put this first to avoid WIN32 build failure #include <thrift/transport/TSocket.h> -#include <string> -#include <boost/shared_ptr.hpp> + #include <openssl/ssl.h> +#include <string> #include <thrift/concurrency/Mutex.h> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -96,7 +97,7 @@ public: * * @param manager Instance of AccessManager */ - virtual void access(boost::shared_ptr<AccessManager> manager) { access_ = manager; } + virtual void access(stdcxx::shared_ptr<AccessManager> manager) { access_ = manager; } /** * Set eventSafe flag if libevent is used. */ @@ -110,37 +111,37 @@ protected: /** * Constructor. */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx); /** * Constructor with an interrupt signal. */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Constructor, create an instance of TSSLSocket given an existing socket. * * @param socket An existing socket */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket); /** * Constructor, create an instance of TSSLSocket given an existing socket that can be interrupted. * * @param socket An existing socket */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Constructor. * * @param host Remote host name * @param port Remote port number */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, std::string host, int port); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, std::string host, int port); /** * Constructor with an interrupt signal. * * @param host Remote host name * @param port Remote port number */ - TSSLSocket(boost::shared_ptr<SSLContext> ctx, std::string host, int port, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + TSSLSocket(stdcxx::shared_ptr<SSLContext> ctx, std::string host, int port, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Authorize peer access after SSL handshake completes. */ @@ -169,14 +170,14 @@ protected: bool server_; SSL* ssl_; - boost::shared_ptr<SSLContext> ctx_; - boost::shared_ptr<AccessManager> access_; + stdcxx::shared_ptr<SSLContext> ctx_; + stdcxx::shared_ptr<AccessManager> access_; friend class TSSLSocketFactory; private: bool handshakeCompleted_; int readRetryCount_; - bool eventSafe_; + bool eventSafe_; void init(); }; @@ -210,37 +211,37 @@ public: /** * Create an instance of TSSLSocket with a fresh new socket. */ - virtual boost::shared_ptr<TSSLSocket> createSocket(); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(); /** * Create an instance of TSSLSocket with a fresh new socket, which is interruptable. */ - virtual boost::shared_ptr<TSSLSocket> createSocket(boost::shared_ptr<THRIFT_SOCKET> interruptListener); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Create an instance of TSSLSocket with the given socket. * * @param socket An existing socket. */ - virtual boost::shared_ptr<TSSLSocket> createSocket(THRIFT_SOCKET socket); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(THRIFT_SOCKET socket); /** * Create an instance of TSSLSocket with the given socket which is interruptable. * * @param socket An existing socket. */ - virtual boost::shared_ptr<TSSLSocket> createSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Create an instance of TSSLSocket. * * @param host Remote host to be connected to * @param port Remote port to be connected to */ - virtual boost::shared_ptr<TSSLSocket> createSocket(const std::string& host, int port); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(const std::string& host, int port); /** * Create an instance of TSSLSocket. * * @param host Remote host to be connected to * @param port Remote port to be connected to */ - virtual boost::shared_ptr<TSSLSocket> createSocket(const std::string& host, int port, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + virtual stdcxx::shared_ptr<TSSLSocket> createSocket(const std::string& host, int port, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Set ciphers to be used in SSL handshake process. * @@ -298,13 +299,13 @@ public: * * @param manager The AccessManager instance */ - virtual void access(boost::shared_ptr<AccessManager> manager) { access_ = manager; } + virtual void access(stdcxx::shared_ptr<AccessManager> manager) { access_ = manager; } static void setManualOpenSSLInitialization(bool manualOpenSSLInitialization) { manualOpenSSLInitialization_ = manualOpenSSLInitialization; } protected: - boost::shared_ptr<SSLContext> ctx_; + stdcxx::shared_ptr<SSLContext> ctx_; /** * Override this method for custom password callback. It may be called @@ -317,11 +318,11 @@ protected: private: bool server_; - boost::shared_ptr<AccessManager> access_; + stdcxx::shared_ptr<AccessManager> access_; static concurrency::Mutex mutex_; static uint64_t count_; static bool manualOpenSSLInitialization_; - void setup(boost::shared_ptr<TSSLSocket> ssl); + void setup(stdcxx::shared_ptr<TSSLSocket> ssl); static int passwordCallback(char* password, int size, int, void* data); }; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TServerSocket.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp index da869e0..a704b06 100644 --- a/lib/cpp/src/thrift/transport/TServerSocket.cpp +++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp @@ -46,7 +46,7 @@ #include <thrift/transport/TSocket.h> #include <thrift/transport/TServerSocket.h> #include <thrift/transport/PlatformSocket.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX @@ -75,12 +75,13 @@ void destroyer_of_fine_sockets(THRIFT_SOCKET* ssock) { delete ssock; } +using std::string; + namespace apache { namespace thrift { namespace transport { -using namespace std; -using boost::shared_ptr; +using stdcxx::shared_ptr; TGetAddrInfoWrapper::TGetAddrInfoWrapper(const char* node, const char* service, @@ -248,7 +249,7 @@ void TServerSocket::listen() { } else { childInterruptSockWriter_ = sv[1]; pChildInterruptSockReader_ - = boost::shared_ptr<THRIFT_SOCKET>(new THRIFT_SOCKET(sv[0]), destroyer_of_fine_sockets); + = stdcxx::shared_ptr<THRIFT_SOCKET>(new THRIFT_SOCKET(sv[0]), destroyer_of_fine_sockets); } // Validate port number http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TServerSocket.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TServerSocket.h b/lib/cpp/src/thrift/transport/TServerSocket.h index 58254ee..cb11dc4 100644 --- a/lib/cpp/src/thrift/transport/TServerSocket.h +++ b/lib/cpp/src/thrift/transport/TServerSocket.h @@ -20,10 +20,9 @@ #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_ #define _THRIFT_TRANSPORT_TSERVERSOCKET_H_ 1 -#include <thrift/transport/TServerTransport.h> +#include <thrift/stdcxx.h> #include <thrift/transport/PlatformSocket.h> -#include <thrift/cxxfunctional.h> -#include <boost/shared_ptr.hpp> +#include <thrift/transport/TServerTransport.h> #include <sys/types.h> #ifdef HAVE_SYS_SOCKET_H @@ -147,10 +146,10 @@ public: void close(); protected: - boost::shared_ptr<TTransport> acceptImpl(); - virtual boost::shared_ptr<TSocket> createSocket(THRIFT_SOCKET client); + stdcxx::shared_ptr<TTransport> acceptImpl(); + virtual stdcxx::shared_ptr<TSocket> createSocket(THRIFT_SOCKET client); bool interruptableChildren_; - boost::shared_ptr<THRIFT_SOCKET> pChildInterruptSockReader_; // if interruptableChildren_ this is shared with child TSockets + stdcxx::shared_ptr<THRIFT_SOCKET> pChildInterruptSockReader_; // if interruptableChildren_ this is shared with child TSockets private: void notify(THRIFT_SOCKET notifySock); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TServerTransport.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TServerTransport.h b/lib/cpp/src/thrift/transport/TServerTransport.h index 51cb3e8..9d5a3d5 100644 --- a/lib/cpp/src/thrift/transport/TServerTransport.h +++ b/lib/cpp/src/thrift/transport/TServerTransport.h @@ -22,7 +22,7 @@ #include <thrift/transport/TTransport.h> #include <thrift/transport/TTransportException.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -56,8 +56,8 @@ public: * @return A new TTransport object * @throws TTransportException if there is an error */ - boost::shared_ptr<TTransport> accept() { - boost::shared_ptr<TTransport> result = acceptImpl(); + stdcxx::shared_ptr<TTransport> accept() { + stdcxx::shared_ptr<TTransport> result = acceptImpl(); if (!result) { throw TTransportException("accept() may not return NULL"); } @@ -105,7 +105,7 @@ protected: * @return A newly allocated TTransport object * @throw TTransportException If an error occurs */ - virtual boost::shared_ptr<TTransport> acceptImpl() = 0; + virtual stdcxx::shared_ptr<TTransport> acceptImpl() = 0; }; } } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TShortReadTransport.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TShortReadTransport.h b/lib/cpp/src/thrift/transport/TShortReadTransport.h index f2ecae1..550b6ba 100644 --- a/lib/cpp/src/thrift/transport/TShortReadTransport.h +++ b/lib/cpp/src/thrift/transport/TShortReadTransport.h @@ -38,7 +38,7 @@ namespace test { */ class TShortReadTransport : public TVirtualTransport<TShortReadTransport> { public: - TShortReadTransport(boost::shared_ptr<TTransport> transport, double full_prob) + TShortReadTransport(stdcxx::shared_ptr<TTransport> transport, double full_prob) : transport_(transport), fullProb_(full_prob) {} bool isOpen() { return transport_->isOpen(); } @@ -68,10 +68,10 @@ public: void consume(uint32_t len) { return transport_->consume(len); } - boost::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; } + stdcxx::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; } protected: - boost::shared_ptr<TTransport> transport_; + stdcxx::shared_ptr<TTransport> transport_; double fullProb_; }; } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TSocket.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp index 8f0f06c..7f8d7af 100644 --- a/lib/cpp/src/thrift/transport/TSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSocket.cpp @@ -63,12 +63,12 @@ inline SOCKOPT_CAST_T* cast_sockopt(T* v) { return reinterpret_cast<SOCKOPT_CAST_T*>(v); } +using std::string; + namespace apache { namespace thrift { namespace transport { -using namespace std; - /** * TSocket implementation. * @@ -141,7 +141,7 @@ TSocket::TSocket(THRIFT_SOCKET socket) #endif } -TSocket::TSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener) +TSocket::TSocket(THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener) : port_(0), socket_(socket), peerPort_(0), http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TSocket.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TSocket.h b/lib/cpp/src/thrift/transport/TSocket.h index 69d2533..1f95e68 100644 --- a/lib/cpp/src/thrift/transport/TSocket.h +++ b/lib/cpp/src/thrift/transport/TSocket.h @@ -257,7 +257,7 @@ public: * Constructor to create socket from file descriptor that * can be interrupted safely. */ - TSocket(THRIFT_SOCKET socket, boost::shared_ptr<THRIFT_SOCKET> interruptListener); + TSocket(THRIFT_SOCKET socket, stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener); /** * Set a cache of the peer address (used when trivially available: e.g. @@ -294,7 +294,7 @@ protected: * A shared socket pointer that will interrupt a blocking read if data * becomes available on it */ - boost::shared_ptr<THRIFT_SOCKET> interruptListener_; + stdcxx::shared_ptr<THRIFT_SOCKET> interruptListener_; /** Connect timeout in ms */ int connTimeout_; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TSocketPool.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TSocketPool.cpp b/lib/cpp/src/thrift/transport/TSocketPool.cpp index ccab258..963c69b 100644 --- a/lib/cpp/src/thrift/transport/TSocketPool.cpp +++ b/lib/cpp/src/thrift/transport/TSocketPool.cpp @@ -24,13 +24,15 @@ #include <thrift/transport/TSocketPool.h> +using std::pair; +using std::string; +using std::vector; + namespace apache { namespace thrift { namespace transport { -using namespace std; - -using boost::shared_ptr; +using stdcxx::shared_ptr; /** * TSocketPoolServer implementation http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TSocketPool.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TSocketPool.h b/lib/cpp/src/thrift/transport/TSocketPool.h index 78f0ebf..bd49e55 100644 --- a/lib/cpp/src/thrift/transport/TSocketPool.h +++ b/lib/cpp/src/thrift/transport/TSocketPool.h @@ -92,7 +92,7 @@ public: * * @param servers list of TSocketPoolServers */ - TSocketPool(const std::vector<boost::shared_ptr<TSocketPoolServer> >& servers); + TSocketPool(const std::vector<stdcxx::shared_ptr<TSocketPoolServer> >& servers); /** * Socket pool constructor @@ -115,17 +115,17 @@ public: /** * Add a server to the pool */ - void addServer(boost::shared_ptr<TSocketPoolServer>& server); + void addServer(stdcxx::shared_ptr<TSocketPoolServer>& server); /** * Set list of servers in this pool */ - void setServers(const std::vector<boost::shared_ptr<TSocketPoolServer> >& servers); + void setServers(const std::vector<stdcxx::shared_ptr<TSocketPoolServer> >& servers); /** * Get list of servers in this pool */ - void getServers(std::vector<boost::shared_ptr<TSocketPoolServer> >& servers); + void getServers(std::vector<stdcxx::shared_ptr<TSocketPoolServer> >& servers); /** * Sets how many times to keep retrying a host in the connect function. @@ -163,13 +163,13 @@ public: void close(); protected: - void setCurrentServer(const boost::shared_ptr<TSocketPoolServer>& server); + void setCurrentServer(const stdcxx::shared_ptr<TSocketPoolServer>& server); /** List of servers to connect to */ - std::vector<boost::shared_ptr<TSocketPoolServer> > servers_; + std::vector<stdcxx::shared_ptr<TSocketPoolServer> > servers_; /** Current server */ - boost::shared_ptr<TSocketPoolServer> currentServer_; + stdcxx::shared_ptr<TSocketPoolServer> currentServer_; /** How many times to retry each host in connect */ int numRetries_; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TTransport.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TTransport.h b/lib/cpp/src/thrift/transport/TTransport.h index d06b0f8..de03290 100644 --- a/lib/cpp/src/thrift/transport/TTransport.h +++ b/lib/cpp/src/thrift/transport/TTransport.h @@ -21,7 +21,7 @@ #define _THRIFT_TRANSPORT_TTRANSPORT_H_ 1 #include <thrift/Thrift.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TTransportException.h> #include <string> @@ -260,7 +260,7 @@ public: /** * Default implementation does nothing, just returns the transport given. */ - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) { + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> trans) { return trans; } }; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TTransportUtils.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TTransportUtils.cpp b/lib/cpp/src/thrift/transport/TTransportUtils.cpp index 0f24c95..869b1fa 100644 --- a/lib/cpp/src/thrift/transport/TTransportUtils.cpp +++ b/lib/cpp/src/thrift/transport/TTransportUtils.cpp @@ -94,8 +94,8 @@ void TPipedTransport::flush() { } TPipedFileReaderTransport::TPipedFileReaderTransport( - boost::shared_ptr<TFileReaderTransport> srcTrans, - boost::shared_ptr<TTransport> dstTrans) + stdcxx::shared_ptr<TFileReaderTransport> srcTrans, + stdcxx::shared_ptr<TTransport> dstTrans) : TPipedTransport(srcTrans, dstTrans), srcTrans_(srcTrans) { } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TTransportUtils.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TTransportUtils.h b/lib/cpp/src/thrift/transport/TTransportUtils.h index c221836..4e8ce26 100644 --- a/lib/cpp/src/thrift/transport/TTransportUtils.h +++ b/lib/cpp/src/thrift/transport/TTransportUtils.h @@ -63,7 +63,7 @@ public: */ class TPipedTransport : virtual public TTransport { public: - TPipedTransport(boost::shared_ptr<TTransport> srcTrans, boost::shared_ptr<TTransport> dstTrans) + TPipedTransport(stdcxx::shared_ptr<TTransport> srcTrans, stdcxx::shared_ptr<TTransport> dstTrans) : srcTrans_(srcTrans), dstTrans_(dstTrans), rBufSize_(512), @@ -86,8 +86,8 @@ public: } } - TPipedTransport(boost::shared_ptr<TTransport> srcTrans, - boost::shared_ptr<TTransport> dstTrans, + TPipedTransport(stdcxx::shared_ptr<TTransport> srcTrans, + stdcxx::shared_ptr<TTransport> dstTrans, uint32_t sz) : srcTrans_(srcTrans), dstTrans_(dstTrans), @@ -170,7 +170,7 @@ public: void flush(); - boost::shared_ptr<TTransport> getTargetTransport() { return dstTrans_; } + stdcxx::shared_ptr<TTransport> getTargetTransport() { return dstTrans_; } /* * Override TTransport *_virt() functions to invoke our implementations. @@ -181,8 +181,8 @@ public: virtual void write_virt(const uint8_t* buf, uint32_t len) { this->write(buf, len); } protected: - boost::shared_ptr<TTransport> srcTrans_; - boost::shared_ptr<TTransport> dstTrans_; + stdcxx::shared_ptr<TTransport> srcTrans_; + stdcxx::shared_ptr<TTransport> dstTrans_; uint8_t* rBuf_; uint32_t rBufSize_; @@ -204,7 +204,7 @@ protected: class TPipedTransportFactory : public TTransportFactory { public: TPipedTransportFactory() {} - TPipedTransportFactory(boost::shared_ptr<TTransport> dstTrans) { + TPipedTransportFactory(stdcxx::shared_ptr<TTransport> dstTrans) { initializeTargetTransport(dstTrans); } virtual ~TPipedTransportFactory() {} @@ -212,11 +212,11 @@ public: /** * Wraps the base transport into a piped transport. */ - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> srcTrans) { - return boost::shared_ptr<TTransport>(new TPipedTransport(srcTrans, dstTrans_)); + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> srcTrans) { + return stdcxx::shared_ptr<TTransport>(new TPipedTransport(srcTrans, dstTrans_)); } - virtual void initializeTargetTransport(boost::shared_ptr<TTransport> dstTrans) { + virtual void initializeTargetTransport(stdcxx::shared_ptr<TTransport> dstTrans) { if (dstTrans_.get() == NULL) { dstTrans_ = dstTrans; } else { @@ -225,7 +225,7 @@ public: } protected: - boost::shared_ptr<TTransport> dstTrans_; + stdcxx::shared_ptr<TTransport> dstTrans_; }; /** @@ -236,8 +236,8 @@ protected: */ class TPipedFileReaderTransport : public TPipedTransport, public TFileReaderTransport { public: - TPipedFileReaderTransport(boost::shared_ptr<TFileReaderTransport> srcTrans, - boost::shared_ptr<TTransport> dstTrans); + TPipedFileReaderTransport(stdcxx::shared_ptr<TFileReaderTransport> srcTrans, + stdcxx::shared_ptr<TTransport> dstTrans); ~TPipedFileReaderTransport(); @@ -273,7 +273,7 @@ public: protected: // shouldn't be used TPipedFileReaderTransport(); - boost::shared_ptr<TFileReaderTransport> srcTrans_; + stdcxx::shared_ptr<TFileReaderTransport> srcTrans_; }; /** @@ -283,23 +283,23 @@ protected: class TPipedFileReaderTransportFactory : public TPipedTransportFactory { public: TPipedFileReaderTransportFactory() {} - TPipedFileReaderTransportFactory(boost::shared_ptr<TTransport> dstTrans) + TPipedFileReaderTransportFactory(stdcxx::shared_ptr<TTransport> dstTrans) : TPipedTransportFactory(dstTrans) {} virtual ~TPipedFileReaderTransportFactory() {} - boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> srcTrans) { - boost::shared_ptr<TFileReaderTransport> pFileReaderTransport - = boost::dynamic_pointer_cast<TFileReaderTransport>(srcTrans); + stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> srcTrans) { + stdcxx::shared_ptr<TFileReaderTransport> pFileReaderTransport + = stdcxx::dynamic_pointer_cast<TFileReaderTransport>(srcTrans); if (pFileReaderTransport.get() != NULL) { return getFileReaderTransport(pFileReaderTransport); } else { - return boost::shared_ptr<TTransport>(); + return stdcxx::shared_ptr<TTransport>(); } } - boost::shared_ptr<TFileReaderTransport> getFileReaderTransport( - boost::shared_ptr<TFileReaderTransport> srcTrans) { - return boost::shared_ptr<TFileReaderTransport>( + stdcxx::shared_ptr<TFileReaderTransport> getFileReaderTransport( + stdcxx::shared_ptr<TFileReaderTransport> srcTrans) { + return stdcxx::shared_ptr<TFileReaderTransport>( new TPipedFileReaderTransport(srcTrans, dstTrans_)); } }; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/transport/TZlibTransport.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TZlibTransport.h b/lib/cpp/src/thrift/transport/TZlibTransport.h index 18ca588..4803c61 100644 --- a/lib/cpp/src/thrift/transport/TZlibTransport.h +++ b/lib/cpp/src/thrift/transport/TZlibTransport.h @@ -78,7 +78,7 @@ public: * @param cwbuf_size Compressed buffer size for writing. * @param comp_level Compression level (0=none[fast], 6=default, 9=max[slow]). */ - TZlibTransport(boost::shared_ptr<TTransport> transport, + TZlibTransport(stdcxx::shared_ptr<TTransport> transport, int urbuf_size = DEFAULT_URBUF_SIZE, int crbuf_size = DEFAULT_CRBUF_SIZE, int uwbuf_size = DEFAULT_UWBUF_SIZE, @@ -193,7 +193,7 @@ protected: // Larger (or equal) writes are dumped straight to zlib. static const uint32_t MIN_DIRECT_DEFLATE_SIZE = 32; - boost::shared_ptr<TTransport> transport_; + stdcxx::shared_ptr<TTransport> transport_; int urpos_; int uwpos_; @@ -229,8 +229,8 @@ public: virtual ~TZlibTransportFactory() {} - virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TTransport>(new TZlibTransport(trans)); + virtual stdcxx::shared_ptr<TTransport> getTransport(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TTransport>(new TZlibTransport(trans)); } }; } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/windows/TWinsockSingleton.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/windows/TWinsockSingleton.h b/lib/cpp/src/thrift/windows/TWinsockSingleton.h index dc1b52f..0eab6d4 100644 --- a/lib/cpp/src/thrift/windows/TWinsockSingleton.h +++ b/lib/cpp/src/thrift/windows/TWinsockSingleton.h @@ -32,7 +32,6 @@ // boost #include <boost/noncopyable.hpp> -#include <boost/scoped_ptr.hpp> #if USE_BOOST_THREAD #include <boost/thread/once.hpp> @@ -42,6 +41,8 @@ #error For windows you must choose USE_BOOST_THREAD or USE_STD_THREAD #endif +#include <thrift/stdcxx.h> + namespace apache { namespace thrift { namespace transport { @@ -53,7 +54,7 @@ namespace transport { class TWinsockSingleton : private boost::noncopyable { public: - typedef boost::scoped_ptr<TWinsockSingleton> instance_ptr; + typedef stdcxx::shared_ptr<TWinsockSingleton> instance_ptr; private: TWinsockSingleton(void); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/AllProtocolTests.tcc ---------------------------------------------------------------------- diff --git a/lib/cpp/test/AllProtocolTests.tcc b/lib/cpp/test/AllProtocolTests.tcc index 3e0b833..b6df656 100644 --- a/lib/cpp/test/AllProtocolTests.tcc +++ b/lib/cpp/test/AllProtocolTests.tcc @@ -28,7 +28,7 @@ #include "GenericHelpers.h" -using boost::shared_ptr; +using apache::thrift::stdcxx::shared_ptr; using namespace apache::thrift; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/Benchmark.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp index 69e6414..afde7d4 100644 --- a/lib/cpp/test/Benchmark.cpp +++ b/lib/cpp/test/Benchmark.cpp @@ -23,8 +23,9 @@ #include <iostream> #define _USE_MATH_DEFINES #include <math.h> -#include "thrift/transport/TBufferTransports.h" #include "thrift/protocol/TBinaryProtocol.h" +#include "thrift/stdcxx.h" +#include "thrift/transport/TBufferTransports.h" #include "gen-cpp/DebugProtoTest_types.h" #ifdef HAVE_SYS_TIME_H @@ -48,11 +49,11 @@ public: }; int main() { - using namespace std; using namespace thrift::test::debug; using namespace apache::thrift::transport; using namespace apache::thrift::protocol; - using namespace boost; + using std::cout; + using std::endl; OneOfEach ooe; ooe.im_true = true; @@ -67,7 +68,7 @@ int main() { ooe.base64 = "\1\2\3\255"; int num = 100000; - boost::shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer(num*1000)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer(num*1000)); uint8_t* data = NULL; uint32_t datasize = 0; @@ -88,7 +89,7 @@ int main() { buf->getBuffer(&data, &datasize); { - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer> prot(buf2); OneOfEach ooe2; double elapsed = 0.0; @@ -116,7 +117,7 @@ int main() { { OneOfEach ooe2; - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer, TNetworkLittleEndian> prot(buf2); double elapsed = 0.0; Timer timer; @@ -142,7 +143,7 @@ int main() { } { - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer> prot(buf2); OneOfEach ooe2; double elapsed = 0.0; @@ -181,7 +182,7 @@ int main() { buf->getBuffer(&data, &datasize); { - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer> prot(buf2); ListDoublePerf listDoublePerf2; double elapsed = 0.0; @@ -205,7 +206,7 @@ int main() { { ListDoublePerf listDoublePerf2; - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer, TNetworkLittleEndian> prot(buf2); double elapsed = 0.0; Timer timer; @@ -227,7 +228,7 @@ int main() { } { - boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize)); TBinaryProtocolT<TMemoryBuffer> prot(buf2); ListDoublePerf listDoublePerf2; double elapsed = 0.0; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt index 6d4aa5e..1a6062d 100644 --- a/lib/cpp/test/CMakeLists.txt +++ b/lib/cpp/test/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -298,7 +298,21 @@ target_link_libraries(TNonblockingServerTest LINK_AGAINST_THRIFT_LIBRARY(TNonblockingServerTest thrift) LINK_AGAINST_THRIFT_LIBRARY(TNonblockingServerTest thriftnb) add_test(NAME TNonblockingServerTest COMMAND TNonblockingServerTest) -endif() + +if(OPENSSL_FOUND AND WITH_OPENSSL) + set(TNonblockingSSLServerTest_SOURCES TNonblockingSSLServerTest.cpp) + add_executable(TNonblockingSSLServerTest ${TNonblockingSSLServerTest_SOURCES}) + include_directories(${LIBEVENT_INCLUDE_DIRS}) + target_link_libraries(TNonblockingSSLServerTest + testgencpp_cob + ${LIBEVENT_LIBRARIES} + ${Boost_LIBRARIES} + ) + LINK_AGAINST_THRIFT_LIBRARY(TNonblockingSSLServerTest thrift) + LINK_AGAINST_THRIFT_LIBRARY(TNonblockingSSLServerTest thriftnb) + add_test(NAME TNonblockingSSLServerTest COMMAND TNonblockingSSLServerTest -- "${CMAKE_CURRENT_SOURCE_DIR}/../../../test/keys") +endif(OPENSSL_FOUND AND WITH_OPENSSL) +endif(WITH_LIBEVENT) if(OPENSSL_FOUND AND WITH_OPENSSL) add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp) http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/DebugProtoTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/DebugProtoTest.cpp b/lib/cpp/test/DebugProtoTest.cpp index c070af2..e04600a 100644 --- a/lib/cpp/test/DebugProtoTest.cpp +++ b/lib/cpp/test/DebugProtoTest.cpp @@ -21,14 +21,14 @@ #include <cmath> #include "gen-cpp/DebugProtoTest_types.h" #include <thrift/protocol/TDebugProtocol.h> -#include <boost/scoped_ptr.hpp> +#include <thrift/stdcxx.h> #define BOOST_TEST_MODULE DebugProtoTest #include <boost/test/unit_test.hpp> using namespace thrift::test::debug; -static boost::scoped_ptr<OneOfEach> ooe; +static ::apache::thrift::stdcxx::shared_ptr<OneOfEach> ooe; void testCaseSetup_1() { ooe.reset(new OneOfEach); @@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_1) { "Expected:\n" << expected_result << "\nGotten:\n" << result); } -static boost::scoped_ptr<Nesting> n; +static ::apache::thrift::stdcxx::shared_ptr<Nesting> n; void testCaseSetup_2() { testCaseSetup_1(); @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_2) { "Expected:\n" << expected_result << "\nGotten:\n" << result); } -static boost::scoped_ptr<HolyMoley> hm; +static ::apache::thrift::stdcxx::shared_ptr<HolyMoley> hm; void testCaseSetup_3() { testCaseSetup_2(); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/GenericHelpers.h ---------------------------------------------------------------------- diff --git a/lib/cpp/test/GenericHelpers.h b/lib/cpp/test/GenericHelpers.h index c175561..e131c42 100644 --- a/lib/cpp/test/GenericHelpers.h +++ b/lib/cpp/test/GenericHelpers.h @@ -20,13 +20,10 @@ #ifndef _THRIFT_TEST_GENERICHELPERS_H_ #define _THRIFT_TEST_GENERICHELPERS_H_ 1 -#include <thrift/protocol/TBinaryProtocol.h> -#include <thrift/transport/TBufferTransports.h> +#include <thrift/protocol/TProtocol.h> +#include <thrift/stdcxx.h> #include <thrift/Thrift.h> -using boost::shared_ptr; -using namespace apache::thrift::protocol; - /* ClassName Helper for cleaner exceptions */ class ClassNames { public: @@ -66,43 +63,43 @@ class GenericIO { public: /* Write functions */ - static uint32_t write(shared_ptr<TProtocol> proto, const int8_t& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const int8_t& val) { return proto->writeByte(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const int16_t& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const int16_t& val) { return proto->writeI16(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const int32_t& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const int32_t& val) { return proto->writeI32(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const double& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const double& val) { return proto->writeDouble(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const int64_t& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const int64_t& val) { return proto->writeI64(val); } - static uint32_t write(shared_ptr<TProtocol> proto, const std::string& val) { + static uint32_t write(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, const std::string& val) { return proto->writeString(val); } /* Read functions */ - static uint32_t read(shared_ptr<TProtocol> proto, int8_t& val) { return proto->readByte(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, int8_t& val) { return proto->readByte(val); } - static uint32_t read(shared_ptr<TProtocol> proto, int16_t& val) { return proto->readI16(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, int16_t& val) { return proto->readI16(val); } - static uint32_t read(shared_ptr<TProtocol> proto, int32_t& val) { return proto->readI32(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, int32_t& val) { return proto->readI32(val); } - static uint32_t read(shared_ptr<TProtocol> proto, int64_t& val) { return proto->readI64(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, int64_t& val) { return proto->readI64(val); } - static uint32_t read(shared_ptr<TProtocol> proto, double& val) { return proto->readDouble(val); } + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, double& val) { return proto->readDouble(val); } - static uint32_t read(shared_ptr<TProtocol> proto, std::string& val) { + static uint32_t read(apache::thrift::stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> proto, std::string& val) { return proto->readString(val); } }; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/JSONProtoTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/JSONProtoTest.cpp b/lib/cpp/test/JSONProtoTest.cpp index 2ac7adc..77bc250 100644 --- a/lib/cpp/test/JSONProtoTest.cpp +++ b/lib/cpp/test/JSONProtoTest.cpp @@ -21,19 +21,20 @@ #include <cmath> #include <iomanip> #include <sstream> -#include <thrift/transport/TBufferTransports.h> #include <thrift/protocol/TJSONProtocol.h> -#include <boost/scoped_ptr.hpp> +#include <thrift/stdcxx.h> +#include <thrift/transport/TBufferTransports.h> #include "gen-cpp/DebugProtoTest_types.h" #define BOOST_TEST_MODULE JSONProtoTest #include <boost/test/unit_test.hpp> using namespace thrift::test::debug; +using namespace apache::thrift; using apache::thrift::transport::TMemoryBuffer; using apache::thrift::protocol::TJSONProtocol; -static boost::scoped_ptr<OneOfEach> ooe; +static stdcxx::shared_ptr<OneOfEach> ooe; void testCaseSetup_1() { ooe.reset(new OneOfEach); @@ -66,7 +67,7 @@ BOOST_AUTO_TEST_CASE(test_json_proto_1) { "Expected:\n" << expected_result << "\nGotten:\n" << result); } -static boost::scoped_ptr<Nesting> n; +static stdcxx::shared_ptr<Nesting> n; void testCaseSetup_2() { testCaseSetup_1(); @@ -106,7 +107,7 @@ BOOST_AUTO_TEST_CASE(test_json_proto_2) { "Expected:\n" << expected_result << "\nGotten:\n" << result); } -static boost::scoped_ptr<HolyMoley> hm; +static stdcxx::shared_ptr<HolyMoley> hm; void testCaseSetup_3() { testCaseSetup_2(); @@ -184,8 +185,8 @@ BOOST_AUTO_TEST_CASE(test_json_proto_3) { BOOST_AUTO_TEST_CASE(test_json_proto_4) { testCaseSetup_1(); - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); ooe->write(proto.get()); OneOfEach ooe2; @@ -197,8 +198,8 @@ BOOST_AUTO_TEST_CASE(test_json_proto_4) { BOOST_AUTO_TEST_CASE(test_json_proto_5) { testCaseSetup_3(); - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); hm->write(proto.get()); HolyMoley hm2; @@ -235,8 +236,8 @@ BOOST_AUTO_TEST_CASE(test_json_proto_6) { } BOOST_AUTO_TEST_CASE(test_json_proto_7) { - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); Base64 base; base.a = 123; @@ -264,9 +265,9 @@ BOOST_AUTO_TEST_CASE(test_json_proto_8) { "\",3,1,2,3]}}"; const std::size_t bufSiz = strlen(json_string) * sizeof(char); - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( (uint8_t*)(json_string), static_cast<uint32_t>(bufSiz))); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); OneOfEach ooe2; @@ -293,9 +294,9 @@ BOOST_AUTO_TEST_CASE(test_json_unicode_escaped) { "\",3,1,2,3]}}"; const char* expected_zomg_unicode = "\xe0\xb8\x81 \xf0\x9d\x94\xbe"; - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( (uint8_t*)(json_string), sizeof(json_string))); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); OneOfEach ooe2; ooe2.read(proto.get()); @@ -314,9 +315,9 @@ BOOST_AUTO_TEST_CASE(test_json_unicode_escaped_missing_low_surrogate) { ":[\"i8\",3,1,2,3]},\"13\":{\"lst\":[\"i16\",3,1,2,3]},\"14\":{\"lst\":[\"i64" "\",3,1,2,3]}}"; - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( (uint8_t*)(json_string), sizeof(json_string))); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); OneOfEach ooe2; BOOST_CHECK_THROW(ooe2.read(proto.get()), @@ -332,9 +333,9 @@ BOOST_AUTO_TEST_CASE(test_json_unicode_escaped_missing_hi_surrogate) { ":[\"i8\",3,1,2,3]},\"13\":{\"lst\":[\"i16\",3,1,2,3]},\"14\":{\"lst\":[\"i64" "\",3,1,2,3]}}"; - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( + stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer( (uint8_t*)(json_string), sizeof(json_string))); - boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); + stdcxx::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer)); OneOfEach ooe2; BOOST_CHECK_THROW(ooe2.read(proto.get()), http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/OpenSSLManualInitTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/OpenSSLManualInitTest.cpp b/lib/cpp/test/OpenSSLManualInitTest.cpp index 5cd5e48..a30b303 100644 --- a/lib/cpp/test/OpenSSLManualInitTest.cpp +++ b/lib/cpp/test/OpenSSLManualInitTest.cpp @@ -28,7 +28,6 @@ #include <openssl/evp.h> #include <thrift/transport/TSSLSocket.h> -using namespace std; using namespace apache::thrift::transport; void make_isolated_sslsocketfactory() { http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/OptionalRequiredTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/OptionalRequiredTest.cpp b/lib/cpp/test/OptionalRequiredTest.cpp index b0e5ef7..55fe249 100644 --- a/lib/cpp/test/OptionalRequiredTest.cpp +++ b/lib/cpp/test/OptionalRequiredTest.cpp @@ -40,7 +40,7 @@ template<typename Struct> void trywrite(const Struct& s, bool should_work) { bool worked; try { - TBinaryProtocol protocol(boost::shared_ptr<TTransport>(new TMemoryBuffer)); + TBinaryProtocol protocol(stdcxx::shared_ptr<TTransport>(new TMemoryBuffer)); s.write(&protocol); worked = true; } catch (TProtocolException & ex) { @@ -52,7 +52,7 @@ void trywrite(const Struct& s, bool should_work) { template <typename Struct1, typename Struct2> void write_to_read(const Struct1& w, Struct2& r) { - TBinaryProtocol protocol(boost::shared_ptr<TTransport>(new TMemoryBuffer)); + TBinaryProtocol protocol(stdcxx::shared_ptr<TTransport>(new TMemoryBuffer)); w.write(&protocol); r.read(&protocol); } @@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE(test_optional_required_11) { o1.im_big.push_back(mymap); BOOST_CHECK(o1 == o2); - TBinaryProtocol protocol(boost::shared_ptr<TTransport>(new TMemoryBuffer)); + TBinaryProtocol protocol(stdcxx::shared_ptr<TTransport>(new TMemoryBuffer)); o1.write(&protocol); o1.im_big.push_back(mymap); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/RecursiveTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/RecursiveTest.cpp b/lib/cpp/test/RecursiveTest.cpp index e3e3f50..ce5569b 100644 --- a/lib/cpp/test/RecursiveTest.cpp +++ b/lib/cpp/test/RecursiveTest.cpp @@ -22,20 +22,21 @@ */ #include "gen-cpp/Recursive_types.h" -#include <thrift/transport/TBufferTransports.h> #include <thrift/protocol/TBinaryProtocol.h> +#include <thrift/stdcxx.h> +#include <thrift/transport/TBufferTransports.h> #define BOOST_TEST_MODULE RecursiveTest #include <boost/test/unit_test.hpp> using apache::thrift::transport::TMemoryBuffer; using apache::thrift::protocol::TBinaryProtocol; -using boost::shared_ptr; +using apache::thrift::stdcxx::shared_ptr; BOOST_AUTO_TEST_CASE(test_recursive_1) { shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer()); shared_ptr<TBinaryProtocol> prot(new TBinaryProtocol(buf)); - + RecTree tree; RecTree child; tree.children.push_back(child); @@ -50,9 +51,9 @@ BOOST_AUTO_TEST_CASE(test_recursive_1) { BOOST_AUTO_TEST_CASE(test_recursive_2) { shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer()); shared_ptr<TBinaryProtocol> prot(new TBinaryProtocol(buf)); - + RecList l; - boost::shared_ptr<RecList> l2(new RecList); + shared_ptr<RecList> l2(new RecList); l.nextitem = l2; l.write(prot.get()); @@ -68,7 +69,7 @@ BOOST_AUTO_TEST_CASE(test_recursive_3) { shared_ptr<TBinaryProtocol> prot(new TBinaryProtocol(buf)); CoRec c; - boost::shared_ptr<CoRec2> r(new CoRec2); + shared_ptr<CoRec2> r(new CoRec2); c.other = r; c.write(prot.get()); @@ -82,7 +83,7 @@ BOOST_AUTO_TEST_CASE(test_recursive_4) { shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer()); shared_ptr<TBinaryProtocol> prot(new TBinaryProtocol(buf)); - boost::shared_ptr<RecList> depthLimit(new RecList); + shared_ptr<RecList> depthLimit(new RecList); depthLimit->nextitem = depthLimit; BOOST_CHECK_THROW(depthLimit->write(prot.get()), apache::thrift::protocol::TProtocolException); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/SecurityTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/SecurityTest.cpp b/lib/cpp/test/SecurityTest.cpp index 23650d6..6eb1fe3 100644 --- a/lib/cpp/test/SecurityTest.cpp +++ b/lib/cpp/test/SecurityTest.cpp @@ -19,13 +19,11 @@ #define BOOST_TEST_MODULE SecurityTest #include <boost/test/unit_test.hpp> -#include <boost/bind.hpp> #include <boost/filesystem.hpp> #include <boost/foreach.hpp> #include <boost/format.hpp> -#include <boost/make_shared.hpp> -#include <boost/shared_ptr.hpp> #include <boost/thread.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TSSLServerSocket.h> #include <thrift/transport/TSSLSocket.h> #include <thrift/transport/TTransport.h> @@ -42,6 +40,9 @@ using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TTransportFactory; +using apache::thrift::stdcxx::bind; +using apache::thrift::stdcxx::shared_ptr; + boost::filesystem::path keyDir; boost::filesystem::path certFile(const std::string& filename) { @@ -54,36 +55,36 @@ struct GlobalFixture GlobalFixture() { using namespace boost::unit_test::framework; - for (int i = 0; i < master_test_suite().argc; ++i) - { - BOOST_TEST_MESSAGE(boost::format("argv[%1%] = \"%2%\"") % i % master_test_suite().argv[i]); - } + for (int i = 0; i < master_test_suite().argc; ++i) + { + BOOST_TEST_MESSAGE(boost::format("argv[%1%] = \"%2%\"") % i % master_test_suite().argv[i]); + } #ifdef __linux__ - // OpenSSL calls send() without MSG_NOSIGPIPE so writing to a socket that has - // disconnected can cause a SIGPIPE signal... - signal(SIGPIPE, SIG_IGN); + // OpenSSL calls send() without MSG_NOSIGPIPE so writing to a socket that has + // disconnected can cause a SIGPIPE signal... + signal(SIGPIPE, SIG_IGN); #endif - TSSLSocketFactory::setManualOpenSSLInitialization(true); - apache::thrift::transport::initializeOpenSSL(); - - keyDir = boost::filesystem::current_path().parent_path().parent_path().parent_path() / "test" / "keys"; - if (!boost::filesystem::exists(certFile("server.crt"))) - { - keyDir = boost::filesystem::path(master_test_suite().argv[master_test_suite().argc - 1]); - if (!boost::filesystem::exists(certFile("server.crt"))) - { - throw std::invalid_argument("The last argument to this test must be the directory containing the test certificate(s)."); - } - } + TSSLSocketFactory::setManualOpenSSLInitialization(true); + apache::thrift::transport::initializeOpenSSL(); + + keyDir = boost::filesystem::current_path().parent_path().parent_path().parent_path() / "test" / "keys"; + if (!boost::filesystem::exists(certFile("server.crt"))) + { + keyDir = boost::filesystem::path(master_test_suite().argv[master_test_suite().argc - 1]); + if (!boost::filesystem::exists(certFile("server.crt"))) + { + throw std::invalid_argument("The last argument to this test must be the directory containing the test certificate(s)."); + } + } } virtual ~GlobalFixture() { - apache::thrift::transport::cleanupOpenSSL(); + apache::thrift::transport::cleanupOpenSSL(); #ifdef __linux__ - signal(SIGPIPE, SIG_DFL); + signal(SIGPIPE, SIG_DFL); #endif } }; @@ -102,8 +103,8 @@ struct SecurityFixture { boost::mutex::scoped_lock lock(mMutex); - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory; - boost::shared_ptr<TSSLServerSocket> pServerSocket; + shared_ptr<TSSLSocketFactory> pServerSocketFactory; + shared_ptr<TSSLServerSocket> pServerSocket; pServerSocketFactory.reset(new TSSLSocketFactory(static_cast<apache::thrift::transport::SSLProtocol>(protocol))); pServerSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); @@ -111,7 +112,7 @@ struct SecurityFixture pServerSocketFactory->loadPrivateKey(certFile("server.key").string().c_str()); pServerSocketFactory->server(true); pServerSocket.reset(new TSSLServerSocket("localhost", 0, pServerSocketFactory)); - boost::shared_ptr<TTransport> connectedClient; + shared_ptr<TTransport> connectedClient; try { @@ -153,8 +154,8 @@ struct SecurityFixture { try { - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory; - boost::shared_ptr<TSSLSocket> pClientSocket; + shared_ptr<TSSLSocketFactory> pClientSocketFactory; + shared_ptr<TSSLSocket> pClientSocket; try { @@ -255,10 +256,10 @@ BOOST_AUTO_TEST_CASE(ssl_security_matrix) mConnected = false; boost::thread_group threads; - threads.create_thread(boost::bind(&SecurityFixture::server, this, static_cast<apache::thrift::transport::SSLProtocol>(si))); + threads.create_thread(bind(&SecurityFixture::server, this, static_cast<apache::thrift::transport::SSLProtocol>(si))); mCVar.wait(lock); // wait for listen() to succeed lock.unlock(); - threads.create_thread(boost::bind(&SecurityFixture::client, this, static_cast<apache::thrift::transport::SSLProtocol>(ci))); + threads.create_thread(bind(&SecurityFixture::client, this, static_cast<apache::thrift::transport::SSLProtocol>(ci))); threads.join_all(); BOOST_CHECK_MESSAGE(mConnected == matrix[ci][si], http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/SpecializationTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/SpecializationTest.cpp b/lib/cpp/test/SpecializationTest.cpp index e851bac..a060b4f 100644 --- a/lib/cpp/test/SpecializationTest.cpp +++ b/lib/cpp/test/SpecializationTest.cpp @@ -82,8 +82,8 @@ BOOST_AUTO_TEST_CASE(test_specialization_1) { stage2.back().message = "nevermore"; hm.bonks["poe"] = stage2; - boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); - boost::shared_ptr<TProtocol> proto(new MyProtocol(buffer)); + apache::thrift::stdcxx::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer()); + apache::thrift::stdcxx::shared_ptr<TProtocol> proto(new MyProtocol(buffer)); ooe.write(proto.get()); OneOfEach ooe2; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/TBufferBaseTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TBufferBaseTest.cpp b/lib/cpp/test/TBufferBaseTest.cpp index 5d0bf45..4e3509e 100644 --- a/lib/cpp/test/TBufferBaseTest.cpp +++ b/lib/cpp/test/TBufferBaseTest.cpp @@ -21,13 +21,14 @@ #include <boost/test/auto_unit_test.hpp> #include <thrift/transport/TBufferTransports.h> #include <thrift/transport/TShortReadTransport.h> +#include <thrift/stdcxx.h> -using std::string; -using boost::shared_ptr; +using apache::thrift::stdcxx::shared_ptr; using apache::thrift::transport::TMemoryBuffer; using apache::thrift::transport::TBufferedTransport; using apache::thrift::transport::TFramedTransport; using apache::thrift::transport::test::TShortReadTransport; +using std::string; // Shamelessly copied from ZlibTransport. TODO: refactor. unsigned int dist[][5000] = { http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/TMemoryBufferTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TMemoryBufferTest.cpp b/lib/cpp/test/TMemoryBufferTest.cpp index 84103e3..1586609 100644 --- a/lib/cpp/test/TMemoryBufferTest.cpp +++ b/lib/cpp/test/TMemoryBufferTest.cpp @@ -21,8 +21,9 @@ #include <iostream> #include <climits> #include <vector> -#include <thrift/transport/TBufferTransports.h> #include <thrift/protocol/TBinaryProtocol.h> +#include <thrift/stdcxx.h> +#include <thrift/transport/TBufferTransports.h> #include "gen-cpp/ThriftTest_types.h" BOOST_AUTO_TEST_SUITE(TMemoryBufferTest) @@ -30,7 +31,7 @@ BOOST_AUTO_TEST_SUITE(TMemoryBufferTest) using apache::thrift::protocol::TBinaryProtocol; using apache::thrift::transport::TMemoryBuffer; using apache::thrift::transport::TTransportException; -using boost::shared_ptr; +using apache::thrift::stdcxx::shared_ptr; using std::cout; using std::endl; using std::string; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/TNonblockingSSLServerTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TNonblockingSSLServerTest.cpp b/lib/cpp/test/TNonblockingSSLServerTest.cpp index f21dd18..3e9700f 100644 --- a/lib/cpp/test/TNonblockingSSLServerTest.cpp +++ b/lib/cpp/test/TNonblockingSSLServerTest.cpp @@ -105,8 +105,8 @@ BOOST_GLOBAL_FIXTURE(GlobalFixtureSSL); BOOST_GLOBAL_FIXTURE(GlobalFixtureSSL) #endif -boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory; +stdcxx::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { + stdcxx::shared_ptr<TSSLSocketFactory> pServerSocketFactory; pServerSocketFactory.reset(new TSSLSocketFactory()); pServerSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); @@ -116,8 +116,8 @@ boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { return pServerSocketFactory; } -boost::shared_ptr<TSSLSocketFactory> createClientSocketFactory() { - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory; +stdcxx::shared_ptr<TSSLSocketFactory> createClientSocketFactory() { + stdcxx::shared_ptr<TSSLSocketFactory> pClientSocketFactory; pClientSocketFactory.reset(new TSSLSocketFactory()); pClientSocketFactory->authenticate(true); @@ -145,12 +145,12 @@ private: struct Runner : public apache::thrift::concurrency::Runnable { int port; - boost::shared_ptr<event_base> userEventBase; - boost::shared_ptr<TProcessor> processor; - boost::shared_ptr<server::TNonblockingServer> server; - boost::shared_ptr<ListenEventHandler> listenHandler; - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory; - boost::shared_ptr<transport::TNonblockingSSLServerSocket> socket; + stdcxx::shared_ptr<event_base> userEventBase; + stdcxx::shared_ptr<TProcessor> processor; + stdcxx::shared_ptr<server::TNonblockingServer> server; + stdcxx::shared_ptr<ListenEventHandler> listenHandler; + stdcxx::shared_ptr<TSSLSocketFactory> pServerSocketFactory; + stdcxx::shared_ptr<transport::TNonblockingSSLServerSocket> socket; Mutex mutex_; Runner() { @@ -198,7 +198,7 @@ private: }; protected: - Fixture() : processor(new test::ParentServiceProcessor(boost::make_shared<Handler>())) {} + Fixture() : processor(new test::ParentServiceProcessor(stdcxx::make_shared<Handler>())) {} ~Fixture() { if (server) { @@ -214,12 +214,12 @@ protected: } int startServer(int port) { - boost::shared_ptr<Runner> runner(new Runner); + stdcxx::shared_ptr<Runner> runner(new Runner); runner->port = port; runner->processor = processor; runner->userEventBase = userEventBase_; - boost::scoped_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory( + apache::thrift::stdcxx::scoped_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory( new apache::thrift::concurrency::PlatformThreadFactory( #if !USE_BOOST_THREAD && !USE_STD_THREAD concurrency::PlatformThreadFactory::OTHER, concurrency::PlatformThreadFactory::NORMAL, @@ -235,11 +235,11 @@ protected: } bool canCommunicate(int serverPort) { - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> socket = pClientSocketFactory->createSocket("localhost", serverPort); + stdcxx::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + stdcxx::shared_ptr<TSSLSocket> socket = pClientSocketFactory->createSocket("localhost", serverPort); socket->open(); - test::ParentServiceClient client(boost::make_shared<protocol::TBinaryProtocol>( - boost::make_shared<transport::TFramedTransport>(socket))); + test::ParentServiceClient client(stdcxx::make_shared<protocol::TBinaryProtocol>( + stdcxx::make_shared<transport::TFramedTransport>(socket))); client.addString("foo"); std::vector<std::string> strings; client.getStrings(strings); @@ -247,12 +247,12 @@ protected: } private: - boost::shared_ptr<event_base> userEventBase_; - boost::shared_ptr<test::ParentServiceProcessor> processor; + stdcxx::shared_ptr<event_base> userEventBase_; + stdcxx::shared_ptr<test::ParentServiceProcessor> processor; protected: - boost::shared_ptr<server::TNonblockingServer> server; + stdcxx::shared_ptr<server::TNonblockingServer> server; private: - boost::shared_ptr<apache::thrift::concurrency::Thread> thread; + stdcxx::shared_ptr<apache::thrift::concurrency::Thread> thread; }; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/TNonblockingServerTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TNonblockingServerTest.cpp b/lib/cpp/test/TNonblockingServerTest.cpp index 36c64b1..74ffd1d 100644 --- a/lib/cpp/test/TNonblockingServerTest.cpp +++ b/lib/cpp/test/TNonblockingServerTest.cpp @@ -19,22 +19,29 @@ #define BOOST_TEST_MODULE TNonblockingServerTest #include <boost/test/unit_test.hpp> -#include <boost/smart_ptr.hpp> #include "thrift/concurrency/Monitor.h" #include "thrift/concurrency/Thread.h" #include "thrift/server/TNonblockingServer.h" #include "thrift/transport/TNonblockingServerSocket.h" +#include "thrift/stdcxx.h" #include "gen-cpp/ParentService.h" #include <event.h> -using namespace apache::thrift; using apache::thrift::concurrency::Guard; using apache::thrift::concurrency::Monitor; using apache::thrift::concurrency::Mutex; +using apache::thrift::concurrency::PlatformThreadFactory; +using apache::thrift::concurrency::Runnable; +using apache::thrift::concurrency::Thread; +using apache::thrift::concurrency::ThreadFactory; using apache::thrift::server::TServerEventHandler; +using apache::thrift::stdcxx::make_shared; +using apache::thrift::stdcxx::shared_ptr; + +using namespace apache::thrift; struct Handler : public test::ParentServiceIf { void addString(const std::string& s) { strings_.push_back(s); } @@ -66,13 +73,13 @@ private: bool ready_; }; - struct Runner : public apache::thrift::concurrency::Runnable { + struct Runner : public Runnable { int port; - boost::shared_ptr<event_base> userEventBase; - boost::shared_ptr<TProcessor> processor; - boost::shared_ptr<server::TNonblockingServer> server; - boost::shared_ptr<ListenEventHandler> listenHandler; - boost::shared_ptr<transport::TNonblockingServerSocket> socket; + shared_ptr<event_base> userEventBase; + shared_ptr<TProcessor> processor; + shared_ptr<server::TNonblockingServer> server; + shared_ptr<ListenEventHandler> listenHandler; + shared_ptr<transport::TNonblockingServerSocket> socket; Mutex mutex_; Runner() { @@ -118,7 +125,7 @@ private: }; protected: - Fixture() : processor(new test::ParentServiceProcessor(boost::make_shared<Handler>())) {} + Fixture() : processor(new test::ParentServiceProcessor(make_shared<Handler>())) {} ~Fixture() { if (server) { @@ -134,15 +141,15 @@ protected: } int startServer(int port) { - boost::shared_ptr<Runner> runner(new Runner); + shared_ptr<Runner> runner(new Runner); runner->port = port; runner->processor = processor; runner->userEventBase = userEventBase_; - boost::scoped_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory( - new apache::thrift::concurrency::PlatformThreadFactory( + shared_ptr<ThreadFactory> threadFactory( + new PlatformThreadFactory( #if !USE_BOOST_THREAD && !USE_STD_THREAD - concurrency::PlatformThreadFactory::OTHER, concurrency::PlatformThreadFactory::NORMAL, + PlatformThreadFactory::OTHER, PlatformThreadFactory::NORMAL, 1, #endif false)); @@ -155,10 +162,10 @@ protected: } bool canCommunicate(int serverPort) { - boost::shared_ptr<transport::TSocket> socket(new transport::TSocket("localhost", serverPort)); + shared_ptr<transport::TSocket> socket(new transport::TSocket("localhost", serverPort)); socket->open(); - test::ParentServiceClient client(boost::make_shared<protocol::TBinaryProtocol>( - boost::make_shared<transport::TFramedTransport>(socket))); + test::ParentServiceClient client(make_shared<protocol::TBinaryProtocol>( + make_shared<transport::TFramedTransport>(socket))); client.addString("foo"); std::vector<std::string> strings; client.getStrings(strings); @@ -166,12 +173,12 @@ protected: } private: - boost::shared_ptr<event_base> userEventBase_; - boost::shared_ptr<test::ParentServiceProcessor> processor; + shared_ptr<event_base> userEventBase_; + shared_ptr<test::ParentServiceProcessor> processor; protected: - boost::shared_ptr<server::TNonblockingServer> server; + shared_ptr<server::TNonblockingServer> server; private: - boost::shared_ptr<apache::thrift::concurrency::Thread> thread; + shared_ptr<concurrency::Thread> thread; }; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/TPipeInterruptTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TPipeInterruptTest.cpp b/lib/cpp/test/TPipeInterruptTest.cpp index 80e4c1f..232e4bb 100644 --- a/lib/cpp/test/TPipeInterruptTest.cpp +++ b/lib/cpp/test/TPipeInterruptTest.cpp @@ -22,17 +22,18 @@ #include <boost/test/test_tools.hpp> #include <boost/test/unit_test_suite.hpp> -#include <boost/bind.hpp> #include <boost/chrono/duration.hpp> #include <boost/date_time/posix_time/posix_time_duration.hpp> #include <boost/thread/thread.hpp> #include <thrift/transport/TPipe.h> #include <thrift/transport/TPipeServer.h> +#include <thrift/stdcxx.h> using apache::thrift::transport::TPipeServer; using apache::thrift::transport::TPipe; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; +using namespace apache::thrift; BOOST_AUTO_TEST_SUITE(TPipeInterruptTest) @@ -51,7 +52,7 @@ static void acceptWorker(TPipeServer *pipe) { { for (;;) { - boost::shared_ptr<TTransport> temp = pipe->accept(); + stdcxx::shared_ptr<TTransport> temp = pipe->accept(); } } catch (...) {/*just want to make sure nothing crashes*/ } @@ -69,8 +70,8 @@ BOOST_AUTO_TEST_CASE(stress_pipe_accept_interruption) { { TPipeServer pipeServer("TPipeInterruptTest"); pipeServer.listen(); - boost::thread acceptThread(boost::bind(acceptWorker, &pipeServer)); - boost::thread interruptThread(boost::bind(interruptWorker, &pipeServer)); + boost::thread acceptThread(stdcxx::bind(acceptWorker, &pipeServer)); + boost::thread interruptThread(stdcxx::bind(interruptWorker, &pipeServer)); try { for (;;) http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/TPipedTransportTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TPipedTransportTest.cpp b/lib/cpp/test/TPipedTransportTest.cpp index 3221fb9..a3ce662 100644 --- a/lib/cpp/test/TPipedTransportTest.cpp +++ b/lib/cpp/test/TPipedTransportTest.cpp @@ -18,6 +18,7 @@ */ #include <thrift/Thrift.h> +#include <thrift/stdcxx.h> #include <thrift/transport/TTransportUtils.h> #include <thrift/transport/TBufferTransports.h> @@ -27,11 +28,12 @@ using apache::thrift::transport::TTransportException; using apache::thrift::transport::TPipedTransport; using apache::thrift::transport::TMemoryBuffer; +using namespace apache::thrift; BOOST_AUTO_TEST_CASE(test_read_write) { - boost::shared_ptr<TMemoryBuffer> underlying(new TMemoryBuffer); - boost::shared_ptr<TMemoryBuffer> pipe(new TMemoryBuffer); - boost::shared_ptr<TPipedTransport> trans(new TPipedTransport(underlying, pipe)); + stdcxx::shared_ptr<TMemoryBuffer> underlying(new TMemoryBuffer); + stdcxx::shared_ptr<TMemoryBuffer> pipe(new TMemoryBuffer); + stdcxx::shared_ptr<TPipedTransport> trans(new TPipedTransport(underlying, pipe)); uint8_t buffer[4]; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/test/TSSLSocketInterruptTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TSSLSocketInterruptTest.cpp b/lib/cpp/test/TSSLSocketInterruptTest.cpp index bf5c7d7..85f6c39 100644 --- a/lib/cpp/test/TSSLSocketInterruptTest.cpp +++ b/lib/cpp/test/TSSLSocketInterruptTest.cpp @@ -19,13 +19,12 @@ #include <boost/test/auto_unit_test.hpp> #include <boost/test/unit_test_suite.hpp> -#include <boost/bind.hpp> #include <boost/chrono/duration.hpp> #include <boost/date_time/posix_time/posix_time_duration.hpp> #include <boost/thread/thread.hpp> #include <boost/filesystem.hpp> #include <boost/format.hpp> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TSSLSocket.h> #include <thrift/transport/TSSLServerSocket.h> #ifdef __linux__ @@ -38,6 +37,9 @@ using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TSSLSocketFactory; +using apache::thrift::stdcxx::static_pointer_cast; +using apache::thrift::stdcxx::shared_ptr; + BOOST_AUTO_TEST_SUITE(TSSLSocketInterruptTest) boost::filesystem::path keyDir; @@ -92,7 +94,7 @@ BOOST_GLOBAL_FIXTURE(GlobalFixtureSSL); BOOST_GLOBAL_FIXTURE(GlobalFixtureSSL) #endif -void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult) { +void readerWorker(shared_ptr<TTransport> tt, uint32_t expectedResult) { uint8_t buf[4]; try { tt->read(buf, 1); @@ -102,7 +104,7 @@ void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult) { } } -void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt) { +void readerWorkerMustThrow(shared_ptr<TTransport> tt) { try { uint8_t buf[400]; tt->read(buf, 1); @@ -113,8 +115,8 @@ void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt) { } } -boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory; +shared_ptr<TSSLSocketFactory> createServerSocketFactory() { + shared_ptr<TSSLSocketFactory> pServerSocketFactory; pServerSocketFactory.reset(new TSSLSocketFactory()); pServerSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); @@ -124,8 +126,8 @@ boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { return pServerSocketFactory; } -boost::shared_ptr<TSSLSocketFactory> createClientSocketFactory() { - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory; +shared_ptr<TSSLSocketFactory> createClientSocketFactory() { + shared_ptr<TSSLSocketFactory> pClientSocketFactory; pClientSocketFactory.reset(new TSSLSocketFactory()); pClientSocketFactory->authenticate(true); @@ -136,15 +138,15 @@ boost::shared_ptr<TSSLSocketFactory> createClientSocketFactory() { } BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read_while_handshaking) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted)); + shared_ptr<TTransport> accepted = sock1.accept(); + boost::thread readThread(apache::thrift::stdcxx::bind(readerWorkerMustThrow, accepted)); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // readThread is practically guaranteed to be blocking now sock1.interruptChildren(); @@ -156,15 +158,15 @@ BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read_while_handshaking) { } BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted)); + shared_ptr<TTransport> accepted = sock1.accept(); + boost::thread readThread(apache::thrift::stdcxx::bind(readerWorkerMustThrow, accepted)); clientSock->write((const uint8_t*)"0", 1); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // readThread is practically guaranteed to be blocking now @@ -177,17 +179,17 @@ BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read) { } BOOST_AUTO_TEST_CASE(test_ssl_non_interruptable_child_read) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000); - boost::thread readThread(boost::bind(readerWorker, accepted, 0)); + shared_ptr<TTransport> accepted = sock1.accept(); + static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000); + boost::thread readThread(apache::thrift::stdcxx::bind(readerWorker, accepted, 0)); clientSock->write((const uint8_t*)"0", 1); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // readThread is practically guaranteed to be blocking here @@ -203,14 +205,14 @@ BOOST_AUTO_TEST_CASE(test_ssl_non_interruptable_child_read) { } BOOST_AUTO_TEST_CASE(test_ssl_cannot_change_after_listen) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.listen(); BOOST_CHECK_THROW(sock1.setInterruptableChildren(false), std::logic_error); sock1.close(); } -void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult) { +void peekerWorker(shared_ptr<TTransport> tt, bool expectedResult) { uint8_t buf[400]; try { tt->read(buf, 1); @@ -220,7 +222,7 @@ void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult) { } } -void peekerWorkerInterrupt(boost::shared_ptr<TTransport> tt) { +void peekerWorkerInterrupt(shared_ptr<TTransport> tt) { uint8_t buf[400]; try { tt->read(buf, 1); @@ -231,15 +233,15 @@ void peekerWorkerInterrupt(boost::shared_ptr<TTransport> tt) { } BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_peek) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::thread peekThread(boost::bind(peekerWorkerInterrupt, accepted)); + shared_ptr<TTransport> accepted = sock1.accept(); + boost::thread peekThread(apache::thrift::stdcxx::bind(peekerWorkerInterrupt, accepted)); clientSock->write((const uint8_t*)"0", 1); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // peekThread is practically guaranteed to be blocking now @@ -252,17 +254,17 @@ BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_peek) { } BOOST_AUTO_TEST_CASE(test_ssl_non_interruptable_child_peek) { - boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); + shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory(); TSSLServerSocket sock1("localhost", 0, pServerSocketFactory); sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior sock1.listen(); int port = sock1.getPort(); - boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); - boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); + shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory(); + shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port); clientSock->open(); - boost::shared_ptr<TTransport> accepted = sock1.accept(); - boost::static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000); - boost::thread peekThread(boost::bind(peekerWorker, accepted, false)); + shared_ptr<TTransport> accepted = sock1.accept(); + static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000); + boost::thread peekThread(apache::thrift::stdcxx::bind(peekerWorker, accepted, false)); clientSock->write((const uint8_t*)"0", 1); boost::this_thread::sleep(boost::posix_time::milliseconds(50)); // peekThread is practically guaranteed to be blocking now