|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54376 - in trunk: boost/asio/detail libs/asio/test
From: chris_at_[hidden]
Date: 2009-06-26 09:35:06
Author: chris_kohlhoff
Date: 2009-06-26 09:35:04 EDT (Fri, 26 Jun 2009)
New Revision: 54376
URL: http://svn.boost.org/trac/boost/changeset/54376
Log:
Fix bug in hash resize. Ref #3095.
Text files modified:
trunk/boost/asio/detail/hash_map.hpp | 6 +++++-
trunk/libs/asio/test/deadline_timer.cpp | 25 +++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletions(-)
Modified: trunk/boost/asio/detail/hash_map.hpp
==============================================================================
--- trunk/boost/asio/detail/hash_map.hpp (original)
+++ trunk/boost/asio/detail/hash_map.hpp 2009-06-26 09:35:04 EDT (Fri, 26 Jun 2009)
@@ -231,9 +231,13 @@
{
buckets_[bucket].first = buckets_[bucket].last = iter++;
}
+ else if (++buckets_[bucket].last == iter)
+ {
+ ++iter;
+ }
else
{
- values_.splice(++buckets_[bucket].last, values_, iter++);
+ values_.splice(buckets_[bucket].last, values_, iter++);
--buckets_[bucket].last;
}
}
Modified: trunk/libs/asio/test/deadline_timer.cpp
==============================================================================
--- trunk/libs/asio/test/deadline_timer.cpp (original)
+++ trunk/libs/asio/test/deadline_timer.cpp 2009-06-26 09:35:04 EDT (Fri, 26 Jun 2009)
@@ -179,9 +179,34 @@
BOOST_CHECK(expected_end < end || expected_end == end);
}
+void timer_handler(const boost::system::error_code&)
+{
+}
+
+void deadline_timer_cancel_test()
+{
+ static boost::asio::io_service io_service;
+ struct timer
+ {
+ boost::asio::deadline_timer t;
+ timer() : t(io_service) { t.expires_at(boost::posix_time::pos_infin); }
+ } timers[50];
+
+ timers[2].t.async_wait(timer_handler);
+ timers[41].t.async_wait(timer_handler);
+ for (int i = 10; i < 20; ++i)
+ timers[i].t.async_wait(timer_handler);
+
+ BOOST_CHECK(timers[2].t.cancel() == 1);
+ BOOST_CHECK(timers[41].t.cancel() == 1);
+ for (int i = 10; i < 20; ++i)
+ BOOST_CHECK(timers[i].t.cancel() == 1);
+}
+
test_suite* init_unit_test_suite(int, char*[])
{
test_suite* test = BOOST_TEST_SUITE("deadline_timer");
test->add(BOOST_TEST_CASE(&deadline_timer_test));
+ test->add(BOOST_TEST_CASE(&deadline_timer_cancel_test));
return test;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk