Subject: [Boost-bugs] [Boost C++ Libraries] #5719: pthread mutex in getnameinfo_emulation
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-07-19 15:55:10
#5719: pthread mutex in getnameinfo_emulation
---------------------------+------------------------------------------------
Reporter: olim@⦠| Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: Boost 1.48.0 | Component: asio
Version: Boost 1.47.0 | Severity: Problem
Keywords: |
---------------------------+------------------------------------------------
In getnameinfo_emulation() a static pthread_mutex_t is initialized with
PTHREAD_MUTEX_INITIALIZER, but pthread_mutex_init() is never called for
the mutex. Although this may work on unix/linux, on other systems that
emulate posix, pthread_mutex_init() must be called before the mutex is
used, otherwise the underlying mutex is never created.
Wouldn't it be better to use the wrapper class
boost::asio::detail::posix_mutex instead of using posix directly?
Actually, you can use boost::asio::detail::mutex instead and change the
conditional macro to #if !defined(BOOST_WINDOWS). In addition, why not
use a scoped lock (i.e. boost::asio::detail::mutex::scoped_lock) to
perform the actual locking and unlocking of the mutex? Then you would
only need one #if defined() instead of two.
I have also attached a patch of the changes I described above. (Warning,
I have not tried compiling with the changes, but you should get the idea)
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5719> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC