stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r389646 - /incubator/stdcxx/trunk/src/memattr.cpp
Date Wed, 29 Mar 2006 01:11:41 GMT
Author: sebor
Date: Tue Mar 28 17:11:39 2006
New Revision: 389646

URL: http://svn.apache.org/viewcvs?rev=389646&view=rev
Log:
2006-03-28  Martin Sebor  <sebor@roguewave.com>

	* memattr.cpp (__rw_memattr): Checked errno for EFAULT and ENOMEM
	after caling madvise() on Linux to prevent false negatives when
	errno is set to EBADF for mapped address ranges not backed by a
	file.

Modified:
    incubator/stdcxx/trunk/src/memattr.cpp

Modified: incubator/stdcxx/trunk/src/memattr.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/src/memattr.cpp?rev=389646&r1=389645&r2=389646&view=diff
==============================================================================
--- incubator/stdcxx/trunk/src/memattr.cpp (original)
+++ incubator/stdcxx/trunk/src/memattr.cpp Tue Mar 28 17:11:39 2006
@@ -153,7 +153,17 @@
             const int err = errno;
             errno = errno_save;
 
-            if (err)
+            bool bad_address;
+
+#    ifdef _RWSTD_OS_LINUX
+            // Linux fails with EBADF when "the map exists,
+            // but the area maps something that isn't a file"
+            bad_address = EFAULT == err || ENOMEM == err;
+#    else   // not Linux
+            bad_address = err != 0;
+#    endif   // Linux
+
+            if (bad_address)
                 return next == page ? -1 : DIST (next, addr);
         }
 



Mime
View raw message