Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions include/boost/interprocess/sync/windows/sync_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ class sync_handles

//key: id -> mapped: HANDLE. Hash map to allow efficient sync operations
typedef boost::container::flat_map<sync_id, void*> id_map_type;
//key: ordered address of the sync type -> iterator from id_map_type. Ordered map to allow closing handles when unmapping
typedef boost::container::flat_map<const void*, id_map_type::iterator> addr_map_type;
//key: ordered address of the sync type -> key from id_map_type. Ordered map to allow closing handles when unmapping
// Can't store iterators into id_map_type because they would get invalidated.
typedef boost::container::flat_map<const void*, sync_id> addr_map_type;
static const std::size_t LengthOfGlobal = sizeof("Global\\boost.ipc")-1;
static const std::size_t StrSize = LengthOfGlobal + (sizeof(sync_id)*2+1);
typedef char NameBuf[StrSize];
Expand Down Expand Up @@ -192,7 +193,7 @@ class sync_handles
void *&hnd_val = it->second;
if(!hnd_val){
BOOST_ASSERT(map_.find(mapping_address) == map_.end());
map_[mapping_address] = it;
map_[mapping_address] = id;
hnd_val = open_or_create_mutex(id);
if(popen_created) *popen_created = true;
++num_handles_;
Expand All @@ -213,7 +214,7 @@ class sync_handles
void *&hnd_val = it->second;
if(!hnd_val){
BOOST_ASSERT(map_.find(mapping_address) == map_.end());
map_[mapping_address] = it;
map_[mapping_address] = id;
hnd_val = open_or_create_semaphore(id, initial_count);
if(popen_created) *popen_created = true;
++num_handles_;
Expand Down Expand Up @@ -250,9 +251,11 @@ class sync_handles
ithig(map_.lower_bound(hig_id)),
it(itlow);
for (; it != ithig; ++it){
id_map_type::iterator uit = it->second;
sync_id ukey = it->second;
id_map_type::iterator uit = umap_.find(ukey);
BOOST_ASSERT(uit != umap_.end());
void * const hnd = uit->second;
umap_.erase(uit);
umap_.erase(ukey);
int ret = winapi::close_handle(hnd);
--num_handles_;
BOOST_ASSERT(ret != 0); (void)ret; //Sanity check that handle was ok
Expand Down