From 080f80579152f664abb8ec02b5b06efaf485586d Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 4 Apr 2015 16:46:47 +0300 Subject: [PATCH] BronsonAVLTreeMap: fixed update() bug --- cds/container/impl/bronson_avltree_map_rcu.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cds/container/impl/bronson_avltree_map_rcu.h b/cds/container/impl/bronson_avltree_map_rcu.h index bbc93ffa..8524ddfc 100644 --- a/cds/container/impl/bronson_avltree_map_rcu.h +++ b/cds/container/impl/bronson_avltree_map_rcu.h @@ -1312,6 +1312,7 @@ namespace cds { namespace container { int try_update_node( int nFlags, Func funcUpdate, node_type * pNode, version_type nVersion, rcu_disposer& disp ) { mapped_type pOld; + bool bInserted; assert( pNode != nullptr ); { node_scoped_lock l( m_Monitor, *pNode ); @@ -1330,6 +1331,7 @@ namespace cds { namespace container { } pOld = pNode->value( memory_model::memory_order_relaxed ); + bInserted = pOld == nullptr; mapped_type pVal = funcUpdate( pNode ); if ( pVal == pOld ) pOld = nullptr; @@ -1344,6 +1346,11 @@ namespace cds { namespace container { m_stat.onDisposeValue(); } + if ( bInserted ) { + m_stat.onInsertSuccess(); + return update_flags::result_inserted; + } + m_stat.onUpdateSuccess(); return update_flags::result_updated; } -- 2.34.1