diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/lib/common/sys/Acceptor.h | 2 | ||||
-rw-r--r-- | cpp/lib/common/sys/apr/APRAcceptor.cpp | 18 | ||||
-rw-r--r-- | cpp/tests/AcceptorTest.cpp | 11 | ||||
-rw-r--r-- | cpp/tests/Makefile.am | 1 | ||||
-rw-r--r-- | cpp/tests/MockConnectionInputHandler.h | 4 | ||||
-rwxr-xr-x | cpp/tests/run-unit-tests | 4 | ||||
-rw-r--r-- | cpp/tests/setup | 1 |
7 files changed, 25 insertions, 16 deletions
diff --git a/cpp/lib/common/sys/Acceptor.h b/cpp/lib/common/sys/Acceptor.h index f571dcbddd..cd4932d92e 100644 --- a/cpp/lib/common/sys/Acceptor.h +++ b/cpp/lib/common/sys/Acceptor.h @@ -35,7 +35,7 @@ class Acceptor : public qpid::SharedObject<Acceptor> public: static Acceptor::shared_ptr create(int16_t port, int backlog, int threads, bool trace = false); virtual ~Acceptor() = 0; - virtual int16_t getPort() const = 0; + virtual uint16_t getPort() const = 0; virtual void run(qpid::sys::ConnectionInputHandlerFactory* factory) = 0; virtual void shutdown() = 0; }; diff --git a/cpp/lib/common/sys/apr/APRAcceptor.cpp b/cpp/lib/common/sys/apr/APRAcceptor.cpp index 52384857ed..a346b9e8dc 100644 --- a/cpp/lib/common/sys/apr/APRAcceptor.cpp +++ b/cpp/lib/common/sys/apr/APRAcceptor.cpp @@ -32,7 +32,7 @@ class APRAcceptor : public Acceptor { public: APRAcceptor(int16_t port, int backlog, int threads, bool trace); - virtual int16_t getPort() const; + virtual uint16_t getPort() const; virtual void run(qpid::sys::ConnectionInputHandlerFactory* factory); virtual void shutdown(); @@ -70,7 +70,7 @@ APRAcceptor::APRAcceptor(int16_t port_, int backlog, int threads, bool trace_) : CHECK_APR_SUCCESS(apr_socket_listen(socket, backlog)); } -int16_t APRAcceptor::getPort() const { +uint16_t APRAcceptor::getPort() const { apr_sockaddr_t* address; CHECK_APR_SUCCESS(apr_socket_addr_get(&address, APR_LOCAL, socket)); return address->port; @@ -80,9 +80,11 @@ void APRAcceptor::run(ConnectionInputHandlerFactory* factory) { running = true; processor.start(); std::cout << "Listening on port " << getPort() << "..." << std::endl; - while(running){ - apr_socket_t* client; - apr_status_t status = apr_socket_accept(&client, socket, APRPool::get()); + while(running) { + apr_socket_t* client; + printf("== accept pre\n"); // FIXME aconway 2007-03-28: + apr_status_t status = apr_socket_accept(&client, socket, APRPool::get()); + printf("== accept post %d %d\n", status, running); // FIXME aconway 2007-03-28: if(status == APR_SUCCESS){ //make this socket non-blocking: CHECK_APR_SUCCESS(apr_socket_timeout_set(client, 0)); @@ -106,16 +108,16 @@ void APRAcceptor::run(ConnectionInputHandlerFactory* factory) { void APRAcceptor::shutdown() { Mutex::ScopedLock locker(shutdownLock); - if (running) { + if (running) shutdownImpl(); - } } void APRAcceptor::shutdownImpl() { - Mutex::ScopedLock locker(shutdownLock); running = false; processor.stop(); + printf("== shutdownImpl pre\n"); // FIXME aconway 2007-03-28: CHECK_APR_SUCCESS(apr_socket_close(socket)); + printf("== shutdownImpl post\n"); } diff --git a/cpp/tests/AcceptorTest.cpp b/cpp/tests/AcceptorTest.cpp index 34a51888d4..947ae2d11a 100644 --- a/cpp/tests/AcceptorTest.cpp +++ b/cpp/tests/AcceptorTest.cpp @@ -49,9 +49,10 @@ class AcceptorTest : public CppUnit::TestCase, private Runnable Acceptor::shared_ptr acceptor; public: - + using TestCase::run; // Avoid hiding TestCase::run. + void run() { - acceptor->run(factory); + acceptor->run(&factory); } void setUp() { @@ -65,7 +66,7 @@ class AcceptorTest : public CppUnit::TestCase, private Runnable void testAccept() { int port = acceptor->getPort(); - CPPUNIT_ASSERT(port > 0); + CPPUNIT_ASSERT(port != 0); Thread runThread(*this); // Connect to the acceptor Socket client = Socket::createTcp(); @@ -84,7 +85,9 @@ class AcceptorTest : public CppUnit::TestCase, private Runnable CPPUNIT_ASSERT_EQUAL(int(2), int(init.getMinor())); acceptor->shutdown(); - runThread.join(); + printf("== join\n"); // FIXME aconway 2007-03-28: + runThread.join(); + printf("== joined\n"); // FIXME aconway 2007-03-28: factory.handler->waitForClosed(); } }; diff --git a/cpp/tests/Makefile.am b/cpp/tests/Makefile.am index 6ae3598a98..e06901ed96 100644 --- a/cpp/tests/Makefile.am +++ b/cpp/tests/Makefile.am @@ -12,6 +12,7 @@ INCLUDES = \ # Unit tests broker_tests = \ AccumulatedAckTest \ + AcceptorTest \ BrokerChannelTest \ ConfigurationTest \ ExchangeTest \ diff --git a/cpp/tests/MockConnectionInputHandler.h b/cpp/tests/MockConnectionInputHandler.h index b039e244d9..55dbceaf44 100644 --- a/cpp/tests/MockConnectionInputHandler.h +++ b/cpp/tests/MockConnectionInputHandler.h @@ -30,9 +30,9 @@ struct MockConnectionInputHandler : public qpid::sys::ConnectionInputHandler { ~MockConnectionInputHandler() {} - void initiated(qpid::framing::ProtocolInitiation* pi) { + void initiated(const qpid::framing::ProtocolInitiation& pi) { qpid::sys::Monitor::ScopedLock l(monitor); - init = *pi; + init = pi; setState(GOT_INIT); } diff --git a/cpp/tests/run-unit-tests b/cpp/tests/run-unit-tests index e97309a59f..1f11f9acc7 100755 --- a/cpp/tests/run-unit-tests +++ b/cpp/tests/run-unit-tests @@ -8,11 +8,13 @@ test -z "$VALGRIND" -a -z "$MAKEFLAGS" && VALGRIND=`which valgrind` 2>/dev/null test -z "$srcdir" && srcdir=. +rm -f valgrind.out +vg_log=--log-file-exactly=valgrind.out source $srcdir/setup for u in $* $UNIT_TESTS ; do TESTLIBS="$TESTLIBS $pwd/.libs/$u.so" ; done test -z "$TESTLIBS" && TESTLIBS="$pwd/.libs/*Test.so" fail=0 -$vg DllPlugInTester -c -b $TESTLIBS 2> valgrind.out || fail=1 +$vg DllPlugInTester -c -b $TESTLIBS || fail=1 vg_check valgrind.out || fail=1 exit $fail diff --git a/cpp/tests/setup b/cpp/tests/setup index febf613847..aaa3afd9b8 100644 --- a/cpp/tests/setup +++ b/cpp/tests/setup @@ -27,6 +27,7 @@ vg_options=" $demangle $full_leak_check $gen_supp + $vg_log " # configure tests for the existence of valgrind. # If it's not available, then make $vg and vg_check no-ops. |