Fix thread safety issue in std interop

This commit is contained in:
Peter Dimov
2019-04-25 01:01:48 +03:00
parent e08e4253d0
commit 1d845408dd
2 changed files with 9 additions and 0 deletions

View File

@ -22,6 +22,11 @@
# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR
#endif
#if defined(BOOST_NO_CXX11_HDR_MUTEX)
// Required for thread-safe map manipulation
# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR
#endif
// BOOST_SYSTEM_NOEXCEPT
// Retained for backward compatibility

View File

@ -10,6 +10,7 @@
#include <system_error>
#include <map>
#include <memory>
#include <mutex>
//
@ -92,6 +93,9 @@ inline std::error_category const & to_std_category( boost::system::error_categor
typedef std::map< boost::system::error_category const *, std::unique_ptr<std_category>, cat_ptr_less > map_type;
static map_type map_;
static std::mutex map_mx_;
std::lock_guard<std::mutex> guard( map_mx_ );
map_type::iterator i = map_.find( &cat );