From: mtk Date: Tue, 13 Jul 2010 12:49:01 +0000 (+0000) Subject: fix QueueingSocketSink to update the IOEvent when the handle is modified. tihgtened... X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=08b1c492f3a7264006d5eb020fb19b265f0805cb;p=senf.git fix QueueingSocketSink to update the IOEvent when the handle is modified. tihgtened unit test git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1645 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/QueueingSocketSink.cc b/senf/PPI/QueueingSocketSink.cc index 4267bb8..c21eeb8 100644 --- a/senf/PPI/QueueingSocketSink.cc +++ b/senf/PPI/QueueingSocketSink.cc @@ -92,7 +92,7 @@ prefix_ senf::Packet senf::ppi::FIFOQueueingAlgorithm::v_dequeue() prefix_ bool senf::ppi::FIFOQueueingAlgorithm::v_enqueue(Packet const & packet) { - if (queue_.size() == max_size_) + if (queue_.size() >= max_size_) queue_.pop(); queue_.push( packet); return true; diff --git a/senf/PPI/QueueingSocketSink.ct b/senf/PPI/QueueingSocketSink.ct index 3ae8cbf..93a412e 100644 --- a/senf/PPI/QueueingSocketSink.ct +++ b/senf/PPI/QueueingSocketSink.ct @@ -85,7 +85,7 @@ prefix_ void senf::ppi::module::PassiveQueueingSocketSink::write() } if (! writer_( handle_, p)) { if (qAlgo_->enqueue( p) && !event_.enabled()) { - event_.enabled( true); + event_.enabled( true); } } } diff --git a/senf/PPI/QueueingSocketSink.cti b/senf/PPI/QueueingSocketSink.cti index f1ae028..481ff99 100644 --- a/senf/PPI/QueueingSocketSink.cti +++ b/senf/PPI/QueueingSocketSink.cti @@ -59,6 +59,7 @@ template prefix_ void senf::ppi::module::PassiveQueueingSocketSink::handle(Handle handle) { handle_ = handle; + event_.set( handle_, IOEvent::Write); qAlgo_->clear(); checkThrottle(); } diff --git a/senf/PPI/QueueingSocketSink.test.cc b/senf/PPI/QueueingSocketSink.test.cc index 38cfcff..972d1ee 100644 --- a/senf/PPI/QueueingSocketSink.test.cc +++ b/senf/PPI/QueueingSocketSink.test.cc @@ -75,15 +75,25 @@ namespace { return false; return ConnectedDgramWriter::operator()( handle, packet); } + + TestingConnectedDgramWriter(){ + throttled = false; + } }; } SENF_AUTO_UNIT_TEST(passiveQueueingSocketSink) { + senf::ConnectedUDPv4ClientSocketHandle os(senf::noinit); + senf::ConnectedUDPv4ClientSocketHandle outputSocket ( senf::INet4SocketAddress( localhost4str(0))); module::PassiveQueueingSocketSink udpSink ( - outputSocket, ppi::FIFOQueueingAlgorithm::create()); + os, ppi::FIFOQueueingAlgorithm::create()); + + // test re-assignment of socket + udpSink.handle( outputSocket); + udpSink.writer().throttled = false; debug::ActiveSource source; ppi::connect(source, udpSink); @@ -106,6 +116,12 @@ SENF_AUTO_UNIT_TEST(passiveQueueingSocketSink) source.submit(p); BOOST_CHECK_EQUAL( udpSink.qAlgorithm().size(), 1); + for( int n = 0; n < 100; n++){ + source.submit(p); + } + // queue default size is 64 + BOOST_CHECK_EQUAL( udpSink.qAlgorithm().size(), 64); + udpSink.writer().throttled = false; runPPI( senf::ClockService::milliseconds(200));