mirror of
https://github.com/boostorg/system.git
synced 2025-07-29 20:17:13 +02:00
Fix thread safety issue in std interop
This commit is contained in:
@ -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
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
|
Reference in New Issue
Block a user