Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55518 - trunk/boost/interprocess
From: igaztanaga_at_[hidden]
Date: 2009-08-11 04:25:57


Author: igaztanaga
Date: 2009-08-11 04:25:56 EDT (Tue, 11 Aug 2009)
New Revision: 55518
URL: http://svn.boost.org/trac/boost/changeset/55518

Log:
lseek is undefined with shared memory descriptors, use fstat instead.
Text files modified:
   trunk/boost/interprocess/mapped_region.hpp | 13 ++++---------
   1 files changed, 4 insertions(+), 9 deletions(-)

Modified: trunk/boost/interprocess/mapped_region.hpp
==============================================================================
--- trunk/boost/interprocess/mapped_region.hpp (original)
+++ trunk/boost/interprocess/mapped_region.hpp 2009-08-11 04:25:56 EDT (Tue, 11 Aug 2009)
@@ -443,24 +443,19 @@
    }
    #endif //ifdef BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS
    if(size == 0){
- offset_t filesize = lseek
- (map_hnd.handle, offset, SEEK_END);
- if(filesize == -1 ){
+ struct ::stat buf;
+ if(0 != fstat(map_hnd.handle, &buf)){
          error_info err(system_error_code());
          throw interprocess_exception(err);
       }
+ std::size_t filesize = (std::size_t)buf.st_size;
       if(offset >= filesize){
          error_info err(size_error);
          throw interprocess_exception(err);
       }
 
       filesize -= offset;
- size = (size_t)filesize;
-
- if((offset_t)size != filesize){
- error_info err(size_error);
- throw interprocess_exception(err);
- }
+ size = filesize;
    }
 
    //Create new mapping


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk