|
Boost : |
From: Michael Klein (michael.klein_at_[hidden])
Date: 2007-03-29 10:17:29
Hi,
iterating over a directory on AIX results in an endless loop because of
funny return codes from readdir_r():
Specifically, readdir_r() sets errno to EBADF upon end-of-directory.
Currently, dir_itr_increment() detects an error condition and returns,
but without ever calling dir_itr_close(), and the DIR handle never gets
closed.
Workaround:
--- ../boost/libs/filesystem/src/operations.cpp.orig
+++ ../boost/libs/filesystem/src/operations.cpp
@@ -1250,10 +1250,9 @@
BOOST_ASSERT( buffer != 0 );
dirent * entry( static_cast<dirent *>(buffer) );
dirent * result;
- int return_code;
- if ( (return_code = readdir_r_simulator( static_cast<DIR*>(handle),
- entry, &result )) != 0 ) return error_code( errno, errno_ecat );
+ int return_code( readdir_r_simulator( static_cast<DIR*>(handle), entry, &result ) );
if ( result == 0 ) return dir_itr_close( handle, buffer );
+ if ( return_code != 0 ) return error_code( errno, errno_ecat );
target = entry->d_name;
# ifdef BOOST_FILESYSTEM_STATUS_CACHE
if ( entry->d_type == DT_UNKNOWN ) // filesystem does not supply d_type value
Kind regards,
-- Michael #exclude <windows.h>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk