From 929a7453034ef55434281908b3050b438c543da0 Mon Sep 17 00:00:00 2001 From: Jim King Date: Wed, 6 May 2015 14:25:28 -0400 Subject: [PATCH] THRIFT-3130 finish removal of THRIFT_OVERLOAD_IF as testing proved it unnecessary --- lib/cpp/CMakeLists.txt | 2 +- lib/cpp/Makefile.am | 4 +- .../src/thrift/{Thrift.cpp => TOutput.cpp} | 0 lib/cpp/src/thrift/TOutput.h | 59 ++++++++++ lib/cpp/src/thrift/Thrift.h | 53 +-------- .../src/thrift/server/TNonblockingServer.h | 36 ++---- lib/cpp/src/thrift/server/TServer.h | 43 +++----- lib/cpp/test/TServerIntegrationTest.cpp | 103 +++++++++++++++--- 8 files changed, 175 insertions(+), 125 deletions(-) rename lib/cpp/src/thrift/{Thrift.cpp => TOutput.cpp} (100%) create mode 100644 lib/cpp/src/thrift/TOutput.h diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index 46a48f768c2..84509a333c9 100755 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -32,8 +32,8 @@ set(SYSLIBS "") # Create the thrift C++ library set( thriftcpp_SOURCES - src/thrift/Thrift.cpp src/thrift/TApplicationException.cpp + src/thrift/TOutput.cpp src/thrift/VirtualProfiling.cpp src/thrift/async/TAsyncChannel.cpp src/thrift/concurrency/ThreadManager.cpp diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index 0de8dc7aef8..561217975f2 100755 --- a/lib/cpp/Makefile.am +++ b/lib/cpp/Makefile.am @@ -62,8 +62,8 @@ AM_LDFLAGS = $(BOOST_LDFLAGS) $(OPENSSL_LDFLAGS) # Define the source files for the module -libthrift_la_SOURCES = src/thrift/Thrift.cpp \ - src/thrift/TApplicationException.cpp \ +libthrift_la_SOURCES = src/thrift/TApplicationException.cpp \ + src/thrift/TOutput.cpp \ src/thrift/VirtualProfiling.cpp \ src/thrift/async/TAsyncChannel.cpp \ src/thrift/concurrency/ThreadManager.cpp \ diff --git a/lib/cpp/src/thrift/Thrift.cpp b/lib/cpp/src/thrift/TOutput.cpp similarity index 100% rename from lib/cpp/src/thrift/Thrift.cpp rename to lib/cpp/src/thrift/TOutput.cpp diff --git a/lib/cpp/src/thrift/TOutput.h b/lib/cpp/src/thrift/TOutput.h new file mode 100644 index 00000000000..9053b802067 --- /dev/null +++ b/lib/cpp/src/thrift/TOutput.h @@ -0,0 +1,59 @@ +/* + * 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 + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _THRIFT_OUTPUT_H_ +#define _THRIFT_OUTPUT_H_ 1 + +namespace apache { +namespace thrift { + +class TOutput { +public: + TOutput() : f_(&errorTimeWrapper) {} + + inline void setOutputFunction(void (*function)(const char*)) { f_ = function; } + + inline void operator()(const char* message) { f_(message); } + + // It is important to have a const char* overload here instead of + // just the string version, otherwise errno could be corrupted + // if there is some problem allocating memory when constructing + // the string. + void perror(const char* message, int errno_copy); + inline void perror(const std::string& message, int errno_copy) { + perror(message.c_str(), errno_copy); + } + + void printf(const char* message, ...); + + static void errorTimeWrapper(const char* msg); + + /** Just like strerror_r but returns a C++ string object. */ + static std::string strerror_s(int errno_copy); + +private: + void (*f_)(const char*); +}; + +extern TOutput GlobalOutput; + +} +} // namespace apache::thrift + +#endif //_THRIFT_OUTPUT_H_ diff --git a/lib/cpp/src/thrift/Thrift.h b/lib/cpp/src/thrift/Thrift.h index 9ddf946c4a0..b56373bd7f6 100644 --- a/lib/cpp/src/thrift/Thrift.h +++ b/lib/cpp/src/thrift/Thrift.h @@ -46,26 +46,7 @@ #include #include - -/** - * Helper macros to allow function overloading even when using - * boost::shared_ptr. - * - * shared_ptr makes overloading really annoying, since shared_ptr defines - * constructor methods to allow one shared_ptr type to be constructed from any - * other shared_ptr type. (Even if it would be a compile error to actually try - * to instantiate the constructor.) These macros add an extra argument to the - * function to cause it to only be instantiated if a pointer of type T is - * convertible to a pointer of type U. - * - * THRIFT_OVERLOAD_IF should be used in function declarations. - * THRIFT_OVERLOAD_IF_DEFN should be used in the function definition, if it is - * defined separately from where it is declared. - */ -#define THRIFT_OVERLOAD_IF_DEFN(T, Y) \ - typename ::boost::enable_if::type, void*>::type - -#define THRIFT_OVERLOAD_IF(T, Y) THRIFT_OVERLOAD_IF_DEFN(T, Y) = NULL +#include #define THRIFT_UNUSED_VARIABLE(x) ((void)(x)) @@ -81,7 +62,7 @@ class TEnumIterator int operator++() { return ++ii_; } bool operator!=(const TEnumIterator& end) { - (void)end; // avoid "unused" warning with NDEBUG + THRIFT_UNUSED_VARIABLE(end); // avoid "unused" warning with NDEBUG assert(end.n_ == -1); return (ii_ != n_); } @@ -95,36 +76,6 @@ class TEnumIterator const char** names_; }; -class TOutput { -public: - TOutput() : f_(&errorTimeWrapper) {} - - inline void setOutputFunction(void (*function)(const char*)) { f_ = function; } - - inline void operator()(const char* message) { f_(message); } - - // It is important to have a const char* overload here instead of - // just the string version, otherwise errno could be corrupted - // if there is some problem allocating memory when constructing - // the string. - void perror(const char* message, int errno_copy); - inline void perror(const std::string& message, int errno_copy) { - perror(message.c_str(), errno_copy); - } - - void printf(const char* message, ...); - - static void errorTimeWrapper(const char* msg); - - /** Just like strerror_r but returns a C++ string object. */ - static std::string strerror_s(int errno_copy); - -private: - void (*f_)(const char*); -}; - -extern TOutput GlobalOutput; - class TException : public std::exception { public: TException() : message_() {} diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h index 0a0d167a99b..7922a68cbf7 100644 --- a/lib/cpp/src/thrift/server/TNonblockingServer.h +++ b/lib/cpp/src/thrift/server/TNonblockingServer.h @@ -305,29 +305,23 @@ class TNonblockingServer : public TServer { } public: - template - TNonblockingServer(const boost::shared_ptr& processorFactory, - int port, - THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) + TNonblockingServer(const boost::shared_ptr& processorFactory, + int port) : TServer(processorFactory) { init(port); } - template - TNonblockingServer(const boost::shared_ptr& processor, - int port, - THRIFT_OVERLOAD_IF(Processor, TProcessor)) + TNonblockingServer(const boost::shared_ptr& processor, + int port) : TServer(processor) { init(port); } - template - TNonblockingServer(const boost::shared_ptr& processorFactory, + TNonblockingServer(const boost::shared_ptr& processorFactory, const boost::shared_ptr& protocolFactory, int port, const boost::shared_ptr& threadManager - = boost::shared_ptr(), - THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) + = boost::shared_ptr()) : TServer(processorFactory) { init(port); @@ -337,13 +331,11 @@ class TNonblockingServer : public TServer { setThreadManager(threadManager); } - template - TNonblockingServer(const boost::shared_ptr& processor, + TNonblockingServer(const boost::shared_ptr& processor, const boost::shared_ptr& protocolFactory, int port, const boost::shared_ptr& threadManager - = boost::shared_ptr(), - THRIFT_OVERLOAD_IF(Processor, TProcessor)) + = boost::shared_ptr()) : TServer(processor) { init(port); @@ -353,16 +345,14 @@ class TNonblockingServer : public TServer { setThreadManager(threadManager); } - template - TNonblockingServer(const boost::shared_ptr& processorFactory, + TNonblockingServer(const boost::shared_ptr& processorFactory, const boost::shared_ptr& inputTransportFactory, const boost::shared_ptr& outputTransportFactory, const boost::shared_ptr& inputProtocolFactory, const boost::shared_ptr& outputProtocolFactory, int port, const boost::shared_ptr& threadManager - = boost::shared_ptr(), - THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) + = boost::shared_ptr()) : TServer(processorFactory) { init(port); @@ -374,16 +364,14 @@ class TNonblockingServer : public TServer { setThreadManager(threadManager); } - template - TNonblockingServer(const boost::shared_ptr& processor, + TNonblockingServer(const boost::shared_ptr& processor, const boost::shared_ptr& inputTransportFactory, const boost::shared_ptr& outputTransportFactory, const boost::shared_ptr& inputProtocolFactory, const boost::shared_ptr& outputProtocolFactory, int port, const boost::shared_ptr& threadManager - = boost::shared_ptr(), - THRIFT_OVERLOAD_IF(Processor, TProcessor)) + = boost::shared_ptr()) : TServer(processor) { init(port); diff --git a/lib/cpp/src/thrift/server/TServer.h b/lib/cpp/src/thrift/server/TServer.h index c0b222f610c..47e0d40b79f 100644 --- a/lib/cpp/src/thrift/server/TServer.h +++ b/lib/cpp/src/thrift/server/TServer.h @@ -124,9 +124,7 @@ class TServer : public concurrency::Runnable { boost::shared_ptr getEventHandler() { return eventHandler_; } protected: - template - TServer(const boost::shared_ptr& processorFactory, - THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) + TServer(const boost::shared_ptr& processorFactory) : processorFactory_(processorFactory) { setInputTransportFactory(boost::shared_ptr(new TTransportFactory())); setOutputTransportFactory(boost::shared_ptr(new TTransportFactory())); @@ -134,8 +132,7 @@ class TServer : public concurrency::Runnable { setOutputProtocolFactory(boost::shared_ptr(new TBinaryProtocolFactory())); } - template - TServer(const boost::shared_ptr& processor, THRIFT_OVERLOAD_IF(Processor, TProcessor)) + TServer(const boost::shared_ptr& processor) : processorFactory_(new TSingletonProcessorFactory(processor)) { setInputTransportFactory(boost::shared_ptr(new TTransportFactory())); setOutputTransportFactory(boost::shared_ptr(new TTransportFactory())); @@ -143,10 +140,8 @@ class TServer : public concurrency::Runnable { setOutputProtocolFactory(boost::shared_ptr(new TBinaryProtocolFactory())); } - template - TServer(const boost::shared_ptr& processorFactory, - const boost::shared_ptr& serverTransport, - THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) + TServer(const boost::shared_ptr& processorFactory, + const boost::shared_ptr& serverTransport) : processorFactory_(processorFactory), serverTransport_(serverTransport) { setInputTransportFactory(boost::shared_ptr(new TTransportFactory())); setOutputTransportFactory(boost::shared_ptr(new TTransportFactory())); @@ -154,10 +149,8 @@ class TServer : public concurrency::Runnable { setOutputProtocolFactory(boost::shared_ptr(new TBinaryProtocolFactory())); } - template - TServer(const boost::shared_ptr& processor, - const boost::shared_ptr& serverTransport, - THRIFT_OVERLOAD_IF(Processor, TProcessor)) + TServer(const boost::shared_ptr& processor, + const boost::shared_ptr& serverTransport) : processorFactory_(new TSingletonProcessorFactory(processor)), serverTransport_(serverTransport) { setInputTransportFactory(boost::shared_ptr(new TTransportFactory())); @@ -166,12 +159,10 @@ class TServer : public concurrency::Runnable { setOutputProtocolFactory(boost::shared_ptr(new TBinaryProtocolFactory())); } - template - TServer(const boost::shared_ptr& processorFactory, + TServer(const boost::shared_ptr& processorFactory, const boost::shared_ptr& serverTransport, const boost::shared_ptr& transportFactory, - const boost::shared_ptr& protocolFactory, - THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) + const boost::shared_ptr& protocolFactory) : processorFactory_(processorFactory), serverTransport_(serverTransport), inputTransportFactory_(transportFactory), @@ -179,12 +170,10 @@ class TServer : public concurrency::Runnable { inputProtocolFactory_(protocolFactory), outputProtocolFactory_(protocolFactory) {} - template - TServer(const boost::shared_ptr& processor, + TServer(const boost::shared_ptr& processor, const boost::shared_ptr& serverTransport, const boost::shared_ptr& transportFactory, - const boost::shared_ptr& protocolFactory, - THRIFT_OVERLOAD_IF(Processor, TProcessor)) + const boost::shared_ptr& protocolFactory) : processorFactory_(new TSingletonProcessorFactory(processor)), serverTransport_(serverTransport), inputTransportFactory_(transportFactory), @@ -192,14 +181,12 @@ class TServer : public concurrency::Runnable { inputProtocolFactory_(protocolFactory), outputProtocolFactory_(protocolFactory) {} - template - TServer(const boost::shared_ptr& processorFactory, + TServer(const boost::shared_ptr& processorFactory, const boost::shared_ptr& serverTransport, const boost::shared_ptr& inputTransportFactory, const boost::shared_ptr& outputTransportFactory, const boost::shared_ptr& inputProtocolFactory, - const boost::shared_ptr& outputProtocolFactory, - THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) + const boost::shared_ptr& outputProtocolFactory) : processorFactory_(processorFactory), serverTransport_(serverTransport), inputTransportFactory_(inputTransportFactory), @@ -207,14 +194,12 @@ class TServer : public concurrency::Runnable { inputProtocolFactory_(inputProtocolFactory), outputProtocolFactory_(outputProtocolFactory) {} - template - TServer(const boost::shared_ptr& processor, + TServer(const boost::shared_ptr& processor, const boost::shared_ptr& serverTransport, const boost::shared_ptr& inputTransportFactory, const boost::shared_ptr& outputTransportFactory, const boost::shared_ptr& inputProtocolFactory, - const boost::shared_ptr& outputProtocolFactory, - THRIFT_OVERLOAD_IF(Processor, TProcessor)) + const boost::shared_ptr& outputProtocolFactory) : processorFactory_(new TSingletonProcessorFactory(processor)), serverTransport_(serverTransport), inputTransportFactory_(inputTransportFactory), diff --git a/lib/cpp/test/TServerIntegrationTest.cpp b/lib/cpp/test/TServerIntegrationTest.cpp index 73bcdbabf97..9c5c7708549 100644 --- a/lib/cpp/test/TServerIntegrationTest.cpp +++ b/lib/cpp/test/TServerIntegrationTest.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +57,12 @@ using apache::thrift::server::TThreadPoolServer; using apache::thrift::server::TThreadedServer; using apache::thrift::test::ParentServiceClient; using apache::thrift::test::ParentServiceIf; +using apache::thrift::test::ParentServiceIfFactory; +using apache::thrift::test::ParentServiceIfSingletonFactory; using apache::thrift::test::ParentServiceProcessor; +using apache::thrift::test::ParentServiceProcessorFactory; +using apache::thrift::TProcessor; +using apache::thrift::TProcessorFactory; using boost::posix_time::milliseconds; /** @@ -143,10 +149,9 @@ template class TServerIntegrationTestFixture : public TestPortFixture { public: - TServerIntegrationTestFixture() : + TServerIntegrationTestFixture(const boost::shared_ptr& _processorFactory) : pServer(new TServerType( - boost::shared_ptr(new ParentServiceProcessor( - boost::shared_ptr(new ParentHandler))), + _processorFactory, boost::shared_ptr(new TServerSocket("localhost", m_serverPort)), boost::shared_ptr(new TTransportFactory), boost::shared_ptr(new TBinaryProtocolFactory))), @@ -155,6 +160,17 @@ class TServerIntegrationTestFixture : public TestPortFixture pServer->setServerEventHandler(pEventHandler); } + TServerIntegrationTestFixture(const boost::shared_ptr& _processor) : + pServer(new TServerType( + _processor, + boost::shared_ptr(new TServerSocket("localhost", 0)), + boost::shared_ptr(new TTransportFactory), + boost::shared_ptr(new TBinaryProtocolFactory))), + pEventHandler(boost::shared_ptr(new TServerReadyEventHandler)) + { + pServer->setServerEventHandler(pEventHandler); + } + void startServer() { pServerThread.reset(new boost::thread(boost::bind(&TServerType::serve, pServer.get()))); @@ -191,6 +207,11 @@ class TServerIntegrationTestFixture : public TestPortFixture stopServer(); } + int getServerPort() { + TServerSocket *pSock = dynamic_cast(pServer->getServerTransport().get()); + return pSock->getPort(); + } + void delayClose(boost::shared_ptr toClose, boost::posix_time::time_duration after) { boost::this_thread::sleep(after); toClose->close(); @@ -202,7 +223,7 @@ class TServerIntegrationTestFixture : public TestPortFixture std::vector > holdThreads; for (int64_t i = 0; i < numToMake; ++i) { - boost::shared_ptr pClientSock(new TSocket("localhost", m_serverPort), autoSocketCloser); + boost::shared_ptr pClientSock(new TSocket("localhost", getServerPort()), autoSocketCloser); holdSockets.push_back(pClientSock); boost::shared_ptr pClientProtocol(new TBinaryProtocol(pClientSock)); ParentServiceClient client(pClientProtocol); @@ -229,25 +250,71 @@ class TServerIntegrationTestFixture : public TestPortFixture boost::shared_ptr pServerThread; }; -BOOST_FIXTURE_TEST_SUITE( Baseline, TestPortFixture ) +template +class TServerIntegrationProcessorFactoryTestFixture : public TServerIntegrationTestFixture +{ +public: + TServerIntegrationProcessorFactoryTestFixture() : + TServerIntegrationTestFixture( + boost::make_shared( + boost::make_shared( + boost::make_shared()))) { } +}; + +template +class TServerIntegrationProcessorTestFixture : public TServerIntegrationTestFixture +{ +public: + TServerIntegrationProcessorTestFixture() : + TServerIntegrationTestFixture( + boost::make_shared( + boost::make_shared())) { } +}; + +BOOST_AUTO_TEST_SUITE(constructors) + +BOOST_FIXTURE_TEST_CASE(test_simple_factory, TServerIntegrationProcessorFactoryTestFixture) +{ + baseline(3, 1); +} -BOOST_FIXTURE_TEST_CASE(test_simple, TServerIntegrationTestFixture) +BOOST_FIXTURE_TEST_CASE(test_simple, TServerIntegrationProcessorTestFixture) { baseline(3, 1); } -BOOST_FIXTURE_TEST_CASE(test_threaded, TServerIntegrationTestFixture) +BOOST_FIXTURE_TEST_CASE(test_threaded_factory, TServerIntegrationProcessorFactoryTestFixture) { baseline(10, 10); } -BOOST_FIXTURE_TEST_CASE(test_threaded_bound, TServerIntegrationTestFixture) +BOOST_FIXTURE_TEST_CASE(test_threaded, TServerIntegrationProcessorTestFixture) +{ + baseline(10, 10); +} + +BOOST_FIXTURE_TEST_CASE(test_threaded_bound, TServerIntegrationProcessorTestFixture) { pServer->setConcurrentClientLimit(4); baseline(10, 4); } -BOOST_FIXTURE_TEST_CASE(test_threadpool, TServerIntegrationTestFixture) +BOOST_FIXTURE_TEST_CASE(test_threadpool_factory, TServerIntegrationProcessorFactoryTestFixture) +{ + pServer->getThreadManager()->threadFactory( + boost::shared_ptr( + new apache::thrift::concurrency::PlatformThreadFactory)); + pServer->getThreadManager()->start(); + + // thread factory has 4 threads as a default + // thread factory however is a bad way to limit concurrent clients + // as accept() will be called to grab a 5th client socket, in this case + // and then the thread factory will block adding the thread to manage + // that client. + baseline(10, 5); +} + +BOOST_FIXTURE_TEST_CASE(test_threadpool, TServerIntegrationProcessorTestFixture) { pServer->getThreadManager()->threadFactory( boost::shared_ptr( @@ -262,7 +329,7 @@ BOOST_FIXTURE_TEST_CASE(test_threadpool, TServerIntegrationTestFixture) +BOOST_FIXTURE_TEST_CASE(test_threadpool_bound, TServerIntegrationProcessorTestFixture) { pServer->getThreadManager()->threadFactory( boost::shared_ptr( @@ -276,7 +343,7 @@ BOOST_FIXTURE_TEST_CASE(test_threadpool_bound, TServerIntegrationTestFixture ) +BOOST_FIXTURE_TEST_SUITE ( TServerIntegrationTest, TServerIntegrationProcessorTestFixture ) BOOST_AUTO_TEST_CASE(test_stop_with_interruptable_clients_connected) { @@ -284,10 +351,10 @@ BOOST_AUTO_TEST_CASE(test_stop_with_interruptable_clients_connected) startServer(); - boost::shared_ptr pClientSock1(new TSocket("localhost", m_serverPort), autoSocketCloser); + boost::shared_ptr pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock1->open(); - boost::shared_ptr pClientSock2(new TSocket("localhost", m_serverPort), autoSocketCloser); + boost::shared_ptr pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock2->open(); // Ensure they have been accepted @@ -313,10 +380,10 @@ BOOST_AUTO_TEST_CASE(test_stop_with_uninterruptable_clients_connected) startServer(); - boost::shared_ptr pClientSock1(new TSocket("localhost", m_serverPort), autoSocketCloser); + boost::shared_ptr pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock1->open(); - boost::shared_ptr pClientSock2(new TSocket("localhost", m_serverPort), autoSocketCloser); + boost::shared_ptr pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock2->open(); // Ensure they have been accepted @@ -340,19 +407,19 @@ BOOST_AUTO_TEST_CASE(test_concurrent_client_limit) BOOST_CHECK_EQUAL(0, pServer->getConcurrentClientCount()); BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientLimit()); - boost::shared_ptr pClientSock1(new TSocket("localhost", m_serverPort), autoSocketCloser); + boost::shared_ptr pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock1->open(); blockUntilAccepted(1); BOOST_CHECK_EQUAL(1, pServer->getConcurrentClientCount()); - boost::shared_ptr pClientSock2(new TSocket("localhost", m_serverPort), autoSocketCloser); + boost::shared_ptr pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock2->open(); blockUntilAccepted(2); BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCount()); // a third client cannot connect until one of the other two closes boost::thread t2(boost::bind(&TServerIntegrationTestFixture::delayClose, this, pClientSock2, milliseconds(250))); - boost::shared_ptr pClientSock3(new TSocket("localhost", m_serverPort), autoSocketCloser); + boost::shared_ptr pClientSock3(new TSocket("localhost", getServerPort()), autoSocketCloser); pClientSock2->open(); blockUntilAccepted(2); BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCount());