#1211: Interprocess tests hang when run in parallel

#1080 boost::interprocess win32 global file mapping issue 

[SVN r38950]
This commit is contained in:
Ion Gaztañaga
2007-08-25 19:07:32 +00:00
parent 09c4b609d8
commit 3a18bed072
10 changed files with 106 additions and 67 deletions

View File

@@ -16,7 +16,7 @@
#include <memory>
#include <cstdio>
#include <string>
#include "get_compiler_name.hpp"
#include "get_process_id_name.hpp"
using namespace boost::interprocess;
@@ -26,14 +26,14 @@ int main ()
const std::size_t FileSize = 99999*2;
{
//Create file with given size
std::ofstream file(test::get_compiler_name(), std::ios::binary | std::ios::trunc);
std::ofstream file(test::get_process_id_name(), std::ios::binary | std::ios::trunc);
file.seekp(static_cast<std::streamoff>(FileSize-1));
file.write("", 1);
}
{
//Create a file mapping
file_mapping mapping(test::get_compiler_name(), read_write);
file_mapping mapping(test::get_process_id_name(), read_write);
//Create two mapped regions, one half of the file each
mapped_region region (mapping
,read_write
@@ -66,7 +66,7 @@ int main ()
//See if the pattern is correct in the file
{
//Open the file
std::ifstream file(test::get_compiler_name(), std::ios::binary);
std::ifstream file(test::get_process_id_name(), std::ios::binary);
//Create a memory buffer
std::auto_ptr<unsigned char> memory (new unsigned char [FileSize/2 +1]);
@@ -103,7 +103,7 @@ int main ()
//Now check the pattern mapping a single read only mapped_region
{
//Create a file mapping
file_mapping mapping(test::get_compiler_name(), read_only);
file_mapping mapping(test::get_process_id_name(), read_only);
//Create a single regions, mapping all the file
mapped_region region (mapping
@@ -122,11 +122,11 @@ int main ()
}
}
catch(std::exception &exc){
std::remove(test::get_compiler_name());
std::remove(test::get_process_id_name());
std::cout << "Unhandled exception: " << exc.what() << std::endl;
throw;
}
std::remove(test::get_compiler_name());
std::remove(test::get_process_id_name());
return 0;
}