From 4701cf9c56d5553f21bafcf9c9f659a52d91a781 Mon Sep 17 00:00:00 2001 From: khizmax Date: Fri, 13 Mar 2015 00:23:44 +0300 Subject: [PATCH] Bugfixing --- cds/container/impl/bronson_avltree_map_rcu.h | 15 ++++++++++----- cds/sync/pool_monitor.h | 7 +++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cds/container/impl/bronson_avltree_map_rcu.h b/cds/container/impl/bronson_avltree_map_rcu.h index 0387befc..d44c64ea 100644 --- a/cds/container/impl/bronson_avltree_map_rcu.h +++ b/cds/container/impl/bronson_avltree_map_rcu.h @@ -977,6 +977,8 @@ namespace cds { namespace container { else if ( pChild == child( m_pRoot, right_child, memory_model::memory_order_acquire )) { result = try_update( key, cmp, nFlags, funcUpdate, m_pRoot, pChild, nChildVersion, disp ); } + else + result = update_flags::retry; } else { // the tree is empty @@ -985,7 +987,7 @@ namespace cds { namespace container { { node_scoped_lock l( m_Monitor, *m_pRoot ); if ( child( m_pRoot, right_child, memory_model::memory_order_acquire ) != nullptr ) { - result = result == update_flags::retry; + result = update_flags::retry; continue; } @@ -1028,6 +1030,8 @@ namespace cds { namespace container { else if ( pChild == child( m_pRoot, right_child, memory_model::memory_order_acquire )) { result = try_remove( key, cmp, func, m_pRoot, pChild, nChildVersion, disp ); } + else + result = update_flags::retry; } else return false; @@ -1466,8 +1470,6 @@ namespace cds { namespace container { // pParent and pNode should be locked. // Returns a damaged node, or nullptr if no more rebalancing is necessary assert( parent( pNode, memory_model::memory_order_relaxed ) == pParent ); - assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode - || child( pParent, right_child, memory_model::memory_order_relaxed ) == pNode ); node_type * pLeft = child( pNode, left_child, memory_model::memory_order_relaxed ); node_type * pRight = child( pNode, right_child, memory_model::memory_order_relaxed ); @@ -1481,6 +1483,9 @@ namespace cds { namespace container { } } + assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode + || child( pParent, right_child, memory_model::memory_order_relaxed ) == pNode ); + int h = pNode->height( memory_model::memory_order_relaxed ); int hL = pLeft ? pLeft->height( memory_model::memory_order_relaxed ) : 0; int hR = pRight ? pRight->height( memory_model::memory_order_relaxed ) : 0; @@ -1504,7 +1509,7 @@ namespace cds { namespace container { node_type * rebalance_to_right_locked( node_type * pParent, node_type * pNode, node_type * pLeft, int hR ) { assert( parent( pNode, memory_model::memory_order_relaxed ) == pParent ); - assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode + assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode || child( pParent, right_child, memory_model::memory_order_relaxed ) == pNode ); // pParent and pNode is locked yet @@ -1559,7 +1564,7 @@ namespace cds { namespace container { node_type * rebalance_to_left_locked( node_type * pParent, node_type * pNode, node_type * pRight, int hL ) { assert( parent( pNode, memory_model::memory_order_relaxed ) == pParent ); - assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode + assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode || child( pParent, right_child, memory_model::memory_order_relaxed ) == pNode ); // pParent and pNode is locked yet diff --git a/cds/sync/pool_monitor.h b/cds/sync/pool_monitor.h index 9b6b1926..f38edc90 100644 --- a/cds/sync/pool_monitor.h +++ b/cds/sync/pool_monitor.h @@ -108,6 +108,9 @@ namespace cds { namespace sync { typename pool_monitor_traits::empty_stat >::type internal_stat; + /// Pool's default capacity + static CDS_CONSTEXPR size_t const c_nDefaultCapacity = 256; + private: //@cond static CDS_CONSTEXPR refspin_type const c_nSpinBit = 1; @@ -138,12 +141,12 @@ namespace cds { namespace sync { /// Initializes the pool of 256 preallocated mutexes pool_monitor() - : m_Pool( 256 ) + : m_Pool( c_nDefaultCapacity ) {} /// Initializes the pool of \p nPoolCapacity preallocated mutexes pool_monitor( size_t nPoolCapacity ) - : m_Pool( nPoolCapacity ? nPoolCapacity : 256 ) + : m_Pool( nPoolCapacity ? nPoolCapacity : c_nDefaultCapacity ) {} /// Makes exclusive access to node \p p -- 2.34.1