Boost logo

Boost Users :

Subject: [Boost-users] file_mapping and network failure problem
From: Marko Pietarinen (marko.pietarinen_at_[hidden])
Date: 2010-02-11 03:22:30


Hi,

I use boost::interprocess::file_mapping to map certain data files (data
files are on server). Then I use boost::interprocess::mapped_region with
that file-map to access the data. The following is pseudo code:

// file-map is initialized first
   file_mapping fileMap(filename);
   mapped_region mappedRegion(fileMap);

// later some where else data is read from file
  float * ptr = reinterpret_cast<float *>(mappedRegion.get_address());
  float value = ptr[index];

This works normally fine. But sometimes you map data file when network is ok
After that you need to look some data (in portion that is not on memory
allready) when the network is not in use, then program just crashes. This is
pretty logical to me. But the question is, can I some how detect the problem
and prevent the crash. I tried to catch exception but no help there.

And is this the rigth way to use mapped files?

    Marko


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net