Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1578: bug in readdir_r_simulator() in a multi-threaded environment
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-02-14 21:10:47
#1578: bug in readdir_r_simulator() in a multi-threaded environment
-----------------------------+----------------------------------------------
Reporter: raulh39_at_[hidden] | Owner: bemandawes
Type: Bugs | Status: assigned
Milestone: Boost 1.35.0 | Component: filesystem
Version: Boost 1.34.1 | Severity: Problem
Resolution: | Keywords:
-----------------------------+----------------------------------------------
Comment (by raulh39):
Ok.
I've been studying the problem, and I have come to the conclusion that
it's a bug in Solaris.
The function readdir_r (despite what is indicated here:
http://tinyurl.com/35aek7) with
int r = readdir_r(dirp,entry,result);
returns r==-1, do NOT set *result to NULL, and leaves errno with its
previous value when it reaches an end-of-directory.
This way it "cheats" dir_itr_increment (lines 1269 and 1270 of
operations.cpp in boost 1.34.1) to believe that an error has ocurred
(because of the -1), but returns errno, whose value is 0, which means OK!
So basic_directory_iterator<Path>::increment() understands (lines 940 to
944 of operations.hpp) that everything is OK, and because *result has not
been set to NULL, m_imp->m_handle is not NULL, so (line 950) it is not
understand as an end-of-directory.
I have change readdir_r_simulator (lines 1247-1248) from this:
{{{
if ( ::sysconf( _SC_THREAD_SAFE_FUNCTIONS ) >= 0 )
{ return ::readdir_r( dirp, entry, result ); }
}}}
to this:
{{{
if ( ::sysconf( _SC_THREAD_SAFE_FUNCTIONS ) >= 0 )
{
int r = ::readdir_r( dirp, entry, result );
#ifdef __sun__
if(r==-1 && errno==0)
{
r=0;
*result=0;
}
#endif
return r;
}
}}}
and now it works as expected.
Please consider whether this changes might be made in any branch of Boost.
Thank you.
--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1578#comment:4>
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:49:57 UTC