mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
Fixes #103 ("Use interprocess headers without exception handling")
This commit is contained in:
@@ -2308,13 +2308,13 @@ we should call to unlock it:
|
||||
|
||||
[c++]
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Mutex operations
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
//What should we call? "unlock()" or "unlock_sharable()"
|
||||
//Is the mutex locked?
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
We can use [*lock transfer] to simplify all this management:
|
||||
|
||||
@@ -6814,6 +6814,7 @@ thank them:
|
||||
* Fixed bugs:
|
||||
* [@https://github.com/boostorg/interprocess/pulls/65 GitHub #65 (['"Robustness of the interprocess mutex"])].
|
||||
* [@https://github.com/boostorg/interprocess/pulls/67 GitHub #67 (['"Changed to use posix robust mutex"])].
|
||||
* [@https://github.com/boostorg/interprocess/pulls/103 GitHub #103 (['"Use interprocess headers without exception handling"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/142 GitHub #142 (['"File lock documentation about advisory locking is inaccurate on Windows"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/149 GitHub #149 (['"interprocess_condition_any::timed_wait update"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/145 GitHub #145 (['"1.76 now requires unicode paths on windows"])].
|
||||
|
||||
@@ -37,7 +37,7 @@ int main ()
|
||||
,"MySharedMemory" //name
|
||||
,read_write //read-write mode
|
||||
);
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Set size
|
||||
shm.truncate(sizeof(trace_queue));
|
||||
|
||||
@@ -72,10 +72,10 @@ int main ()
|
||||
data->message_in = true;
|
||||
}
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ int main ()
|
||||
,read_write //read-write mode
|
||||
);
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Map the whole shared memory in this process
|
||||
mapped_region region
|
||||
(shm //What to map
|
||||
@@ -60,10 +60,10 @@ int main ()
|
||||
}
|
||||
while(!end_loop);
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace boost::interprocess;
|
||||
|
||||
int main ()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Remove shared memory on construction and destruction
|
||||
struct shm_remove
|
||||
{
|
||||
@@ -71,10 +71,10 @@ int main ()
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
//]
|
||||
|
||||
@@ -17,7 +17,7 @@ using namespace boost::interprocess;
|
||||
|
||||
int main ()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Erase previous message queue
|
||||
message_queue::remove("message_queue");
|
||||
|
||||
@@ -34,10 +34,10 @@ int main ()
|
||||
mq.send(&i, sizeof(i), 0);
|
||||
}
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ using namespace boost::interprocess;
|
||||
|
||||
int main ()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Open a message queue.
|
||||
message_queue mq
|
||||
(open_only //only open
|
||||
@@ -35,11 +35,11 @@ int main ()
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
message_queue::remove("message_queue");
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
message_queue::remove("message_queue");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Create an anonymous shared memory segment with size 1000
|
||||
mapped_region region(anonymous_shared_memory(1000));
|
||||
|
||||
@@ -26,10 +26,10 @@ int main ()
|
||||
|
||||
//The segment is unmapped when "region" goes out of scope
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
//]
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
// See http://www.boost.org/libs/interprocess for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/interprocess/detail/config_begin.hpp>
|
||||
//[doc_managed_aligned_allocation
|
||||
#include <boost/interprocess/managed_shared_memory.hpp>
|
||||
#include <cassert>
|
||||
@@ -88,31 +87,4 @@ int main()
|
||||
return 0;
|
||||
}
|
||||
//]
|
||||
/*
|
||||
|
||||
#include <vector>
|
||||
#include <boost/interprocess/managed_windows_shared_memory.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
typedef boost::interprocess::
|
||||
managed_windows_shared_memory shared_segment;
|
||||
|
||||
std::vector<void *> ptrs;
|
||||
shared_segment m_segment(create_only, "shmem", 4096*16);
|
||||
try{
|
||||
while(1){
|
||||
//Now I have several allocate_aligned operations:
|
||||
ptrs.push_back(m_segment.allocate_aligned(128, 128));
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
m_segment.deallocate(ptrs.back());
|
||||
ptrs.pop_back();
|
||||
ptrs.push_back(m_segment.allocate_aligned(128, 128));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
#include <boost/interprocess/detail/config_end.hpp>
|
||||
|
||||
@@ -31,14 +31,14 @@ int main ()
|
||||
managed_heap_memory::handle_t list_handle = heap_memory.get_handle_from_address(mylist);
|
||||
|
||||
//Fill list until there is no more memory in the buffer
|
||||
try{
|
||||
BOOST_TRY{
|
||||
while(1) {
|
||||
mylist->insert(mylist->begin(), 0);
|
||||
}
|
||||
}
|
||||
catch(const bad_alloc &){
|
||||
BOOST_CATCH(const bad_alloc &){
|
||||
//memory is full
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
//Let's obtain the size of the list
|
||||
MyList::size_type old_size = mylist->size();
|
||||
//<-
|
||||
@@ -55,14 +55,14 @@ int main ()
|
||||
(heap_memory.get_address_from_handle(list_handle));
|
||||
|
||||
//Fill list until there is no more memory in the buffer
|
||||
try{
|
||||
BOOST_TRY{
|
||||
while(1) {
|
||||
mylist->insert(mylist->begin(), 0);
|
||||
}
|
||||
}
|
||||
catch(const bad_alloc &){
|
||||
BOOST_CATCH(const bad_alloc &){
|
||||
//memory is full
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
//Let's obtain the new size of the list
|
||||
MyList::size_type new_size = mylist->size();
|
||||
|
||||
@@ -43,7 +43,7 @@ int main ()
|
||||
const std::size_t FileSize = 1000;
|
||||
file_mapping::remove(FileName);
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
MyList::size_type old_size = 0;
|
||||
managed_mapped_file::handle_t list_handle;
|
||||
{
|
||||
@@ -55,14 +55,14 @@ int main ()
|
||||
list_handle = mfile_memory.get_handle_from_address(mylist);
|
||||
|
||||
//Fill list until there is no more room in the file
|
||||
try{
|
||||
BOOST_TRY{
|
||||
while(1) {
|
||||
mylist->insert(mylist->begin(), 0);
|
||||
}
|
||||
}
|
||||
catch(const bad_alloc &){
|
||||
BOOST_CATCH(const bad_alloc &){
|
||||
//mapped file is full
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
//Let's obtain the size of the list
|
||||
old_size = mylist->size();
|
||||
}
|
||||
@@ -80,14 +80,14 @@ int main ()
|
||||
(mfile_memory.get_address_from_handle(list_handle));
|
||||
|
||||
//Fill list until there is no more room in the file
|
||||
try{
|
||||
BOOST_TRY{
|
||||
while(1) {
|
||||
mylist->insert(mylist->begin(), 0);
|
||||
}
|
||||
}
|
||||
catch(const bad_alloc &){
|
||||
BOOST_CATCH(const bad_alloc &){
|
||||
//mapped file is full
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
//Let's obtain the new size of the list
|
||||
MyList::size_type new_size = mylist->size();
|
||||
@@ -98,10 +98,10 @@ int main ()
|
||||
mfile_memory.destroy_ptr(mylist);
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
file_mapping::remove(FileName);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
file_mapping::remove(FileName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
struct file_remove
|
||||
{
|
||||
//<-
|
||||
@@ -87,10 +87,10 @@ int main ()
|
||||
file << std::endl;
|
||||
}
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
//]
|
||||
|
||||
@@ -92,7 +92,7 @@ int main ()
|
||||
//we destroy the object automatically
|
||||
my_deleter<my_class> d(shmem.get_segment_manager());
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
scoped_ptr<my_class, my_deleter<my_class> > s_ptr(my_object, d);
|
||||
//Let's emulate a exception capable operation
|
||||
//In the second try, throw an exception
|
||||
@@ -104,7 +104,7 @@ int main ()
|
||||
//to avoid destruction
|
||||
s_ptr.release();
|
||||
}
|
||||
catch(const my_exception &){}
|
||||
BOOST_CATCH(const my_exception &){} BOOST_CATCH_END
|
||||
//Here, scoped_ptr is destroyed
|
||||
//so it we haven't thrown an exception
|
||||
//the object should be there, otherwise, destroyed
|
||||
|
||||
@@ -23,14 +23,14 @@ using namespace boost::interprocess;
|
||||
|
||||
void remove_old_shared_memory(const xsi_key &key)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
xsi_shared_memory xsi(open_only, key);
|
||||
xsi_shared_memory::remove(xsi.get_shmid());
|
||||
}
|
||||
catch(interprocess_exception &e){
|
||||
BOOST_CATCH(interprocess_exception &e){
|
||||
if(e.get_error_code() != not_found_error)
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
@@ -220,8 +220,7 @@ class cache_impl
|
||||
BOOST_CATCH(...){
|
||||
this->cached_deallocation(chain);
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
void cached_deallocation(void *ptr)
|
||||
|
||||
@@ -121,7 +121,7 @@ class intermodule_singleton_common
|
||||
}
|
||||
}
|
||||
if(previous_module_singleton_initialized == Uninitialized){
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Now initialize the global map, this function must solve concurrency
|
||||
//issues between threads of several modules
|
||||
initialize_global_map_handle();
|
||||
@@ -143,11 +143,11 @@ class intermodule_singleton_common
|
||||
//before this one. Now marked as initialized
|
||||
atomic_write32(&this_module_singleton_initialized, Initialized);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
//Mark singleton failed to initialize
|
||||
atomic_write32(&this_module_singleton_initialized, Broken);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
//If previous state was initializing, this means that another winner thread is
|
||||
//trying to initialize the singleton. Just wait until completes its work.
|
||||
@@ -232,7 +232,7 @@ class intermodule_singleton_common
|
||||
}
|
||||
else{ //(tmp == Uninitialized)
|
||||
//If not initialized try it again?
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Remove old global map from the system
|
||||
intermodule_singleton_helpers::thread_safe_global_map_dependant<ThreadSafeGlobalMap>::remove_old_gmem();
|
||||
//in-place construction of the global map class
|
||||
@@ -255,10 +255,10 @@ class intermodule_singleton_common
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
//
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,17 +406,17 @@ class intermodule_singleton_impl
|
||||
<ThreadSafeGlobalMap>::find(m_map, typeid(C).name());
|
||||
if(!rcount){
|
||||
C *p = new C;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
ref_count_ptr val(p, 0u);
|
||||
rcount = intermodule_singleton_helpers::thread_safe_global_map_dependant
|
||||
<ThreadSafeGlobalMap>::insert(m_map, typeid(C).name(), val);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
intermodule_singleton_helpers::thread_safe_global_map_dependant
|
||||
<ThreadSafeGlobalMap>::erase(m_map, typeid(C).name());
|
||||
delete p;
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
//if(Phoenix){
|
||||
std::atexit(&atexit_work);
|
||||
|
||||
@@ -91,19 +91,19 @@ class basic_managed_global_memory
|
||||
|
||||
public: //functions
|
||||
|
||||
basic_managed_global_memory (open_or_create_t open_or_create,
|
||||
basic_managed_global_memory (open_or_create_t,
|
||||
const char *name, size_type size,
|
||||
const void *addr = 0, const permissions& perm = permissions())
|
||||
: base_t()
|
||||
, base2_t(open_or_create, name, size, read_write, addr,
|
||||
, base2_t(open_or_create_t(), name, size, read_write, addr,
|
||||
create_open_func_t(get_this_pointer(),
|
||||
DoOpenOrCreate), perm)
|
||||
{}
|
||||
|
||||
basic_managed_global_memory (open_only_t open_only, const char* name,
|
||||
basic_managed_global_memory (open_only_t , const char* name,
|
||||
const void *addr = 0)
|
||||
: base_t()
|
||||
, base2_t(open_only, name, read_write, addr,
|
||||
, base2_t(open_only_t(), name, read_write, addr,
|
||||
create_open_func_t(get_this_pointer(),
|
||||
DoOpen))
|
||||
{}
|
||||
|
||||
@@ -115,7 +115,7 @@ class basic_managed_memory_impl
|
||||
{
|
||||
typedef typename ManagedMemory::device_type device_type;
|
||||
//Increase file size
|
||||
try{
|
||||
BOOST_TRY{
|
||||
offset_t old_size;
|
||||
{
|
||||
device_type f(open_or_create, filename, read_write);
|
||||
@@ -127,9 +127,9 @@ class basic_managed_memory_impl
|
||||
//Grow always works
|
||||
managed_memory.self_t::grow(extra_bytes);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -138,15 +138,15 @@ class basic_managed_memory_impl
|
||||
{
|
||||
typedef typename ManagedMemory::device_type device_type;
|
||||
size_type new_size;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
ManagedMemory managed_memory(open_only, filename);
|
||||
managed_memory.get_size();
|
||||
managed_memory.self_t::shrink_to_fit();
|
||||
new_size = managed_memory.get_size();
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
//Decrease file size
|
||||
{
|
||||
@@ -182,8 +182,7 @@ class basic_managed_memory_impl
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
} BOOST_CATCH_END
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -337,41 +337,45 @@ class managed_open_or_create_impl
|
||||
bool completed = false;
|
||||
spin_wait swait;
|
||||
while(!completed){
|
||||
try{
|
||||
BOOST_TRY{
|
||||
create_device<FileBased>(dev, id, size, perm, file_like_t());
|
||||
created = true;
|
||||
completed = true;
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(ex.get_error_code() != already_exists_error){
|
||||
throw;
|
||||
BOOST_RETHROW
|
||||
}
|
||||
else{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
DeviceAbstraction tmp(open_only, id, read_write);
|
||||
dev.swap(tmp);
|
||||
created = false;
|
||||
completed = true;
|
||||
}
|
||||
catch(interprocess_exception &e){
|
||||
BOOST_CATCH(interprocess_exception &e){
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(e.get_error_code() != not_found_error){
|
||||
throw;
|
||||
BOOST_RETHROW
|
||||
}
|
||||
#endif //BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
#endif //#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
swait.yield();
|
||||
}
|
||||
}
|
||||
|
||||
if(created){
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//If this throws, we are lost
|
||||
truncate_device<FileBased>(dev, size, file_like_t());
|
||||
|
||||
@@ -382,16 +386,16 @@ class managed_open_or_create_impl
|
||||
boost::uint32_t previous = atomic_cas32(patomic_word, InitializingSegment, UninitializedSegment);
|
||||
|
||||
if(previous == UninitializedSegment){
|
||||
try{
|
||||
BOOST_TRY{
|
||||
construct_func( static_cast<char*>(region.get_address()) + ManagedOpenOrCreateUserOffset
|
||||
, size - ManagedOpenOrCreateUserOffset, true);
|
||||
//All ok, just move resources to the external mapped region
|
||||
m_mapped_region.swap(region);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
atomic_write32(patomic_word, CorruptedSegment);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
atomic_write32(patomic_word, InitializedSegment);
|
||||
}
|
||||
else if(previous == InitializingSegment || previous == InitializedSegment){
|
||||
@@ -401,14 +405,16 @@ class managed_open_or_create_impl
|
||||
throw interprocess_exception(error_info(corrupted_error));
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
try{
|
||||
BOOST_CATCH(...){
|
||||
BOOST_TRY{
|
||||
truncate_device<FileBased>(dev, 1u, file_like_t());
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
}
|
||||
throw;
|
||||
BOOST_CATCH_END
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
else{
|
||||
if(FileBased){
|
||||
|
||||
@@ -152,7 +152,7 @@ struct thread_safe_global_map_dependant<managed_global_memory>
|
||||
static void apply_gmem_erase_logic(const char *filepath, const char *filename)
|
||||
{
|
||||
int fd = GMemMarkToBeRemoved;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
std::string str;
|
||||
//If the filename is current process lock file, then avoid it
|
||||
if(check_if_filename_complies_with_pid
|
||||
@@ -167,21 +167,21 @@ struct thread_safe_global_map_dependant<managed_global_memory>
|
||||
//If done, then the process is dead so take global shared memory name
|
||||
//(the name is based on the lock file name) and try to apply erasure logic
|
||||
str.insert(0, get_map_base_name());
|
||||
try{
|
||||
BOOST_TRY{
|
||||
managed_global_memory shm(open_only, str.c_str());
|
||||
gmem_erase_func func(str.c_str(), filepath, shm);
|
||||
shm.try_atomic_func(func);
|
||||
}
|
||||
catch(interprocess_exception &e){
|
||||
BOOST_CATCH(interprocess_exception &e){
|
||||
//If shared memory is not found erase the lock file
|
||||
if(e.get_error_code() == not_found_error){
|
||||
delete_file(filepath);
|
||||
}
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
if(fd >= 0){
|
||||
close_lock_file(fd);
|
||||
}
|
||||
|
||||
@@ -219,8 +219,7 @@ inline void array_construct(void *mem, std::size_t num, in_place_interface &tabl
|
||||
std::size_t destroyed = 0;
|
||||
table.destroy_n(mem, constructed, destroyed);
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
template<class CharT>
|
||||
|
||||
@@ -1318,7 +1318,7 @@ inline bool unlink_file(const CharT *filename)
|
||||
//- Close the handle. If there are no file users, it will be deleted.
|
||||
// Otherwise it will be used by already connected handles but the
|
||||
// file name can't be used to open this file again
|
||||
try{
|
||||
BOOST_TRY{
|
||||
NtSetInformationFile_t pNtSetInformationFile =
|
||||
reinterpret_cast<NtSetInformationFile_t>(dll_func::get(dll_func::NtSetInformationFile));
|
||||
|
||||
@@ -1412,9 +1412,9 @@ inline bool unlink_file(const CharT *filename)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -245,4 +245,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
|
||||
|
||||
@@ -39,14 +39,14 @@ class BOOST_SYMBOL_VISIBLE interprocess_exception : public std::exception
|
||||
interprocess_exception(const char *err) BOOST_NOEXCEPT
|
||||
: m_err(other_error)
|
||||
{
|
||||
try { m_str = err; }
|
||||
catch (...) {}
|
||||
BOOST_TRY { m_str = err; }
|
||||
BOOST_CATCH(...) {} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
interprocess_exception(const error_info &err_info, const char *str = 0)
|
||||
: m_err(err_info)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
if(m_err.get_native_error() != 0){
|
||||
fill_system_message(m_err.get_native_error(), m_str);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class BOOST_SYMBOL_VISIBLE interprocess_exception : public std::exception
|
||||
m_str = "boost::interprocess_exception::library_error";
|
||||
}
|
||||
}
|
||||
catch(...){}
|
||||
BOOST_CATCH(...){} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
~interprocess_exception() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {}
|
||||
|
||||
@@ -276,15 +276,15 @@ class iunordered_set_index
|
||||
new_n = index_type::suggested_upper_bucket_count(new_n);
|
||||
bucket_ptr new_p;
|
||||
//This can throw
|
||||
try{
|
||||
BOOST_TRY{
|
||||
if(old_p != bucket_ptr(&this->init_bucket))
|
||||
new_p = expand_or_create_buckets(old_p, old_n, this->alloc, new_n);
|
||||
else
|
||||
new_p = create_buckets(this->alloc, new_n);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
//Rehashing does not throw, since neither the hash nor the
|
||||
//comparison function can throw
|
||||
this->rehash(bucket_traits(new_p, new_n));
|
||||
@@ -312,12 +312,12 @@ class iunordered_set_index
|
||||
if(sug_count >= cur_count)
|
||||
return;
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
shrink_buckets(old_p, cur_count, this->alloc, sug_count);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
//Rehashing does not throw, since neither the hash nor the
|
||||
//comparison function can throw
|
||||
@@ -340,10 +340,10 @@ class iunordered_set_index
|
||||
iterator it = index_type::insert_commit(val, commit_data);
|
||||
size_type cur_size = this->size();
|
||||
if(cur_size > this->bucket_count()){
|
||||
try{
|
||||
BOOST_TRY{
|
||||
this->reserve(cur_size);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
//Strong guarantee: if something goes wrong
|
||||
//we should remove the insertion.
|
||||
//
|
||||
@@ -352,8 +352,8 @@ class iunordered_set_index
|
||||
//throw only because of the memory allocation:
|
||||
//the iterator has not been invalidated.
|
||||
index_type::erase(it);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
@@ -683,8 +683,7 @@ class msg_queue_initialization_func_t
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -893,8 +892,7 @@ inline bool message_queue_t<VoidPointer>::do_send(
|
||||
--p_hdr->m_blocked_senders;
|
||||
#endif
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX)
|
||||
@@ -1024,8 +1022,7 @@ inline bool
|
||||
--p_hdr->m_blocked_receivers;
|
||||
#endif
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
#ifdef BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX
|
||||
|
||||
@@ -890,9 +890,9 @@ class segment_manager
|
||||
size_type &length, ipcdetail::false_ is_intrusive, bool use_lock)
|
||||
{
|
||||
(void)is_intrusive;
|
||||
typedef IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > index_type;
|
||||
typedef typename index_type::key_type key_type;
|
||||
typedef typename index_type::iterator index_it;
|
||||
typedef IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > char_aware_index_type;
|
||||
typedef typename char_aware_index_type::key_type key_type;
|
||||
typedef typename char_aware_index_type::iterator index_it;
|
||||
|
||||
//-------------------------------
|
||||
scoped_lock<rmutex> guard(priv_get_lock(use_lock));
|
||||
@@ -1000,9 +1000,9 @@ class segment_manager
|
||||
ipcdetail::false_ is_intrusive_index)
|
||||
{
|
||||
(void)is_intrusive_index;
|
||||
typedef IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > index_type;
|
||||
typedef typename index_type::iterator index_it;
|
||||
typedef typename index_type::key_type key_type;
|
||||
typedef IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > char_aware_index_type;
|
||||
typedef typename char_aware_index_type::iterator index_it;
|
||||
typedef typename char_aware_index_type::key_type key_type;
|
||||
|
||||
//-------------------------------
|
||||
scoped_lock<rmutex> guard(m_header);
|
||||
@@ -1026,8 +1026,8 @@ class segment_manager
|
||||
IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > &index,
|
||||
ipcdetail::in_place_interface &table)
|
||||
{
|
||||
typedef IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > index_type;
|
||||
typedef typename index_type::iterator index_it;
|
||||
typedef IndexType<ipcdetail::index_config<CharT, MemoryAlgorithm> > char_aware_index_type;
|
||||
typedef typename char_aware_index_type::iterator index_it;
|
||||
|
||||
//Get allocation parameters
|
||||
block_header_t *ctrl_data = reinterpret_cast<block_header_t*>
|
||||
|
||||
@@ -269,30 +269,30 @@ inline bool shared_memory_object::priv_open_or_create
|
||||
|
||||
inline bool shared_memory_object::remove(const wchar_t *filename)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Make sure a temporary path is created for shared memory
|
||||
std::wstring shmfile;
|
||||
ipcdetail::shared_filepath(filename, shmfile);
|
||||
return ipcdetail::delete_file(shmfile.c_str());
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
inline bool shared_memory_object::remove(const char *filename)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Make sure a temporary path is created for shared memory
|
||||
std::string shmfile;
|
||||
ipcdetail::shared_filepath(filename, shmfile);
|
||||
return ipcdetail::delete_file(shmfile.c_str());
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
inline void shared_memory_object::truncate(offset_t length)
|
||||
@@ -432,7 +432,7 @@ inline bool shared_memory_object::priv_open_or_create
|
||||
|
||||
inline bool shared_memory_object::remove(const char *filename)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
std::string filepath;
|
||||
#if defined(BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY)
|
||||
const bool add_leading_slash = false;
|
||||
@@ -449,9 +449,9 @@ inline bool shared_memory_object::remove(const char *filename)
|
||||
}
|
||||
return 0 == shm_unlink(filepath.c_str());
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
inline void shared_memory_object::truncate(offset_t length)
|
||||
|
||||
@@ -395,16 +395,16 @@ template<class T, class ManagedMemory>
|
||||
inline typename managed_shared_ptr<T, ManagedMemory>::type
|
||||
make_managed_shared_ptr(T *constructed_object, ManagedMemory &managed_memory, const std::nothrow_t &)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
return typename managed_shared_ptr<T, ManagedMemory>::type
|
||||
( constructed_object
|
||||
, managed_memory.template get_allocator<void>()
|
||||
, managed_memory.template get_deleter<T>()
|
||||
);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return typename managed_shared_ptr<T, ManagedMemory>::type();
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ inline void semaphore_close(sem_t *handle)
|
||||
|
||||
inline bool semaphore_unlink(const char *semname)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
std::string sem_str;
|
||||
#ifndef BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SEMAPHORES
|
||||
add_leading_slash(semname, sem_str);
|
||||
@@ -131,9 +131,9 @@ inline bool semaphore_unlink(const char *semname)
|
||||
#endif
|
||||
return 0 == sem_unlink(sem_str.c_str());
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
#endif //BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
|
||||
|
||||
@@ -253,8 +253,8 @@ class scoped_lock
|
||||
//!Notes: The destructor behavior ensures that the mutex lock is not leaked.*/
|
||||
~scoped_lock()
|
||||
{
|
||||
try{ if(m_locked && mp_mutex) mp_mutex->unlock(); }
|
||||
catch(...){}
|
||||
BOOST_TRY{ if(m_locked && mp_mutex) mp_mutex->unlock(); }
|
||||
BOOST_CATCH(...){} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
//!Effects: If owns() before the call, then unlock() is called on mutex().
|
||||
|
||||
@@ -182,10 +182,10 @@ class sharable_lock
|
||||
//!Notes: The destructor behavior ensures that the mutex lock is not leaked.
|
||||
~sharable_lock()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
if(m_locked && mp_mutex) mp_mutex->unlock_sharable();
|
||||
}
|
||||
catch(...){}
|
||||
BOOST_CATCH(...){} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
//!Effects: If owns() before the call, then unlock_sharable() is called on mutex().
|
||||
|
||||
@@ -184,10 +184,10 @@ class upgradable_lock
|
||||
//!Notes: The destructor behavior ensures that the mutex lock is not leaked.
|
||||
~upgradable_lock()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
if(m_locked && mp_mutex) mp_mutex->unlock_upgradable();
|
||||
}
|
||||
catch(...){}
|
||||
BOOST_CATCH(...){} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
//!Effects: If owns(), then unlock_upgradable() is called on mutex().
|
||||
|
||||
@@ -204,28 +204,28 @@ inline void windows_named_sync::open_or_create
|
||||
|
||||
inline bool windows_named_sync::remove(const char *name)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Make sure a temporary path is created for shared memory
|
||||
std::string semfile;
|
||||
ipcdetail::shared_filepath(name, semfile);
|
||||
return winapi::unlink_file(semfile.c_str());
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
inline bool windows_named_sync::remove(const wchar_t *name)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Make sure a temporary path is created for shared memory
|
||||
std::wstring semfile;
|
||||
ipcdetail::shared_filepath(name, semfile);
|
||||
return winapi::unlink_file(semfile.c_str());
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
return false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
} //namespace ipcdetail {
|
||||
|
||||
@@ -37,57 +37,59 @@ int main ()
|
||||
const int memsize = 16384;
|
||||
const char *const shMemName = test::get_process_id_name();
|
||||
|
||||
try{
|
||||
shared_memory_object::remove(shMemName);
|
||||
|
||||
//Named allocate capable shared mem allocator
|
||||
managed_shared_memory segment(create_only, shMemName, memsize);
|
||||
|
||||
//STL compatible allocator object, uses allocate(), deallocate() functions
|
||||
typedef allocator<InstanceCounter,
|
||||
managed_shared_memory::segment_manager>
|
||||
inst_allocator_t;
|
||||
const inst_allocator_t myallocator (segment.get_segment_manager());
|
||||
|
||||
typedef vector<InstanceCounter, inst_allocator_t> MyVect;
|
||||
|
||||
//We'll provoke an exception, let's see if exception handling works
|
||||
try{
|
||||
//Fill vector until there is no more memory
|
||||
MyVect myvec(myallocator);
|
||||
int i;
|
||||
for(i = 0; true; ++i){
|
||||
myvec.push_back(InstanceCounter());
|
||||
}
|
||||
}
|
||||
catch(boost::interprocess::bad_alloc &){
|
||||
if(InstanceCounter::counter != 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//We'll provoke an exception, let's see if exception handling works
|
||||
try{
|
||||
//Fill vector at the beginning until there is no more memory
|
||||
MyVect myvec(myallocator);
|
||||
int i;
|
||||
InstanceCounter ic;
|
||||
for(i = 0; true; ++i){
|
||||
myvec.insert(myvec.begin(), i, ic);
|
||||
}
|
||||
}
|
||||
catch(boost::interprocess::bad_alloc &){
|
||||
if(InstanceCounter::counter != 0)
|
||||
return 1;
|
||||
}
|
||||
catch(std::length_error &){
|
||||
if(InstanceCounter::counter != 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_TRY{
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
|
||||
//Named allocate capable shared mem allocator
|
||||
managed_shared_memory segment(create_only, shMemName, memsize);
|
||||
|
||||
//STL compatible allocator object, uses allocate(), deallocate() functions
|
||||
typedef allocator<InstanceCounter,
|
||||
managed_shared_memory::segment_manager>
|
||||
inst_allocator_t;
|
||||
const inst_allocator_t myallocator (segment.get_segment_manager());
|
||||
|
||||
typedef vector<InstanceCounter, inst_allocator_t> MyVect;
|
||||
|
||||
//We'll provoke an exception, let's see if exception handling works
|
||||
BOOST_TRY{
|
||||
//Fill vector until there is no more memory
|
||||
MyVect myvec(myallocator);
|
||||
int i;
|
||||
for(i = 0; true; ++i){
|
||||
myvec.push_back(InstanceCounter());
|
||||
}
|
||||
}
|
||||
BOOST_CATCH(boost::interprocess::bad_alloc &){
|
||||
if(InstanceCounter::counter != 0)
|
||||
return 1;
|
||||
} BOOST_CATCH_END
|
||||
|
||||
//We'll provoke an exception, let's see if exception handling works
|
||||
BOOST_TRY{
|
||||
//Fill vector at the beginning until there is no more memory
|
||||
MyVect myvec(myallocator);
|
||||
int i;
|
||||
InstanceCounter ic;
|
||||
for(i = 0; true; ++i){
|
||||
myvec.insert(myvec.begin(), i, ic);
|
||||
}
|
||||
}
|
||||
BOOST_CATCH(boost::interprocess::bad_alloc &){
|
||||
if(InstanceCounter::counter != 0)
|
||||
return 1;
|
||||
}
|
||||
BOOST_CATCH(std::length_error &){
|
||||
if(InstanceCounter::counter != 0)
|
||||
return 1;
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
shared_memory_object::remove(shMemName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ using namespace boost::interprocess;
|
||||
|
||||
int main ()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
const std::size_t MemSize = 99999*2;
|
||||
{
|
||||
//Now check anonymous mapping
|
||||
@@ -43,9 +43,9 @@ int main ()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(std::exception &exc){
|
||||
BOOST_CATCH(std::exception &exc){
|
||||
std::cout << "Unhandled exception: " << exc.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ int main ()
|
||||
test::get_process_id_name(process_name);
|
||||
const char *const shMemName = process_name.c_str();
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
shared_memory_object::remove(shMemName);
|
||||
|
||||
//Create shared memory
|
||||
@@ -85,10 +85,10 @@ int main ()
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(shMemName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ bool do_test()
|
||||
const char *const shMemName = test::get_process_id_name();
|
||||
const int max = 100;
|
||||
|
||||
/*try*/{
|
||||
/*BOOST_TRY*/{
|
||||
shared_memory_object::remove(shMemName);
|
||||
|
||||
//Create shared memory
|
||||
@@ -139,7 +139,7 @@ bool do_test()
|
||||
|
||||
MyStdDeque *stddeque = new MyStdDeque;
|
||||
|
||||
/*try*/{
|
||||
/*BOOST_TRY*/{
|
||||
//Compare several shared memory deque operations with std::deque
|
||||
for(int i = 0; i < max*50; ++i){
|
||||
IntType move_me(i);
|
||||
@@ -270,17 +270,17 @@ bool do_test()
|
||||
if(!segment.all_memory_deallocated())
|
||||
return false;
|
||||
}/*
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
return false;
|
||||
}*/
|
||||
} BOOST_CATCH_END*/
|
||||
|
||||
std::cout << std::endl << "Test OK!" << std::endl;
|
||||
}/*
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
}*/
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END*/
|
||||
shared_memory_object::remove(shMemName);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,21 +49,21 @@ void test_enable_shared_this(ManagedMemory &managed_mem)
|
||||
|
||||
X v2(*p);
|
||||
|
||||
try
|
||||
BOOST_TRY
|
||||
{
|
||||
//This should throw bad_weak_ptr
|
||||
v_shared_ptr r = v2.shared_from_this();
|
||||
BOOST_ERROR("v2.shared_from_this() failed to throw");
|
||||
}
|
||||
catch(boost::interprocess::bad_weak_ptr const &)
|
||||
BOOST_CATCH(boost::interprocess::bad_weak_ptr const &)
|
||||
{
|
||||
//This is the expected path
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
BOOST_ERROR("v2.shared_from_this() threw an unexpected exception");
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
try
|
||||
BOOST_TRY
|
||||
{
|
||||
//This should not throw bad_weak_ptr
|
||||
*p = X();
|
||||
@@ -71,14 +71,14 @@ void test_enable_shared_this(ManagedMemory &managed_mem)
|
||||
BOOST_TEST(p == r);
|
||||
BOOST_TEST(!(p < r) && !(r < p));
|
||||
}
|
||||
catch(boost::interprocess::bad_weak_ptr const &)
|
||||
BOOST_CATCH(boost::interprocess::bad_weak_ptr const &)
|
||||
{
|
||||
BOOST_ERROR("p->shared_from_this() threw bad_weak_ptr after *p = X()");
|
||||
}
|
||||
catch(...)
|
||||
BOOST_CATCH(...)
|
||||
{
|
||||
BOOST_ERROR("p->shared_from_this() threw an unexpected exception after *p = X()");
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ bool test_insert_with_expand_bwd()
|
||||
for(int iteration = 0; iteration < Iterations; ++iteration)
|
||||
{
|
||||
value_type *memory = new value_type[MemorySize];
|
||||
try {
|
||||
BOOST_TRY {
|
||||
std::vector<non_volatile_value_type> initial_data;
|
||||
initial_data.resize(InitialSize[iteration]);
|
||||
for(int i = 0; i < InitialSize[iteration]; ++i){
|
||||
@@ -165,10 +165,10 @@ bool test_insert_with_expand_bwd()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
delete [](const_cast<non_volatile_value_type*>(memory));
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
delete [](const_cast<non_volatile_value_type*>(memory));
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ bool test_assign_with_expand_bwd()
|
||||
for(int iteration = 0; iteration <Iterations; ++iteration)
|
||||
{
|
||||
value_type *memory = new value_type[MemorySize];
|
||||
try {
|
||||
BOOST_TRY {
|
||||
//Create initial data
|
||||
std::vector<non_volatile_value_type> initial_data;
|
||||
initial_data.resize(InitialSize[iteration]);
|
||||
@@ -226,10 +226,10 @@ bool test_assign_with_expand_bwd()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
delete [](const_cast<typename boost::interprocess::ipcdetail::remove_volatile<value_type>::type*>(memory));
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
delete [](const_cast<typename boost::interprocess::ipcdetail::remove_volatile<value_type>::type*>(memory));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ file_mapping get_file_mapping()
|
||||
|
||||
int main ()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
const std::size_t FileSize = 99999*2;
|
||||
{
|
||||
//Create file with given size
|
||||
@@ -164,11 +164,11 @@ int main ()
|
||||
file_mapping ret(get_file_mapping());
|
||||
}
|
||||
}
|
||||
catch(std::exception &exc){
|
||||
BOOST_CATCH(std::exception &exc){
|
||||
file_mapping::remove(get_filename().c_str());
|
||||
std::cout << "Unhandled exception: " << exc.what() << std::endl;
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
file_mapping::remove(get_filename().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -53,19 +53,19 @@ int intermodule_singleton_test()
|
||||
bool exception_thrown = false;
|
||||
bool exception_2_thrown = false;
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
IntermoduleType<MyThrowingClass, true, false>::get();
|
||||
}
|
||||
catch(int &){
|
||||
BOOST_CATCH(int &){
|
||||
exception_thrown = true;
|
||||
//Second try
|
||||
try{
|
||||
BOOST_TRY{
|
||||
IntermoduleType<MyThrowingClass, true, false>::get();
|
||||
}
|
||||
catch(interprocess_exception &){
|
||||
BOOST_CATCH(interprocess_exception &){
|
||||
exception_2_thrown = true;
|
||||
}
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
} BOOST_CATCH_END
|
||||
|
||||
if(!exception_thrown || !exception_2_thrown){
|
||||
return 1;
|
||||
@@ -78,12 +78,12 @@ int intermodule_singleton_test()
|
||||
|
||||
//Second try
|
||||
exception_2_thrown = false;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
IntermoduleType<MyThrowingClass, true, false>::get();
|
||||
}
|
||||
catch(interprocess_exception &){
|
||||
BOOST_CATCH(interprocess_exception &){
|
||||
exception_2_thrown = true;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
if(!exception_2_thrown){
|
||||
return 1;
|
||||
}
|
||||
@@ -211,16 +211,16 @@ class LogDeadReferenceUser
|
||||
std::cout << "~LogDeadReferenceUser(), LogSingleton: " << typeid(LogSingleton).name() << "\n" << std::endl;
|
||||
//Make sure the exception is thrown as we are
|
||||
//trying to use a dead non-phoenix singleton
|
||||
try{
|
||||
BOOST_TRY{
|
||||
LogSingleton::get().log_it();
|
||||
std::string s("LogDeadReferenceUser failed for LogSingleton ");
|
||||
s += typeid(LogSingleton).name();
|
||||
std::cout << "~LogDeadReferenceUser(), error: " << s << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
catch(interprocess_exception &){
|
||||
BOOST_CATCH(interprocess_exception &){
|
||||
//Correct behaviour
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ int list_test (bool copied_allocators_equal = true)
|
||||
const int max = 100;
|
||||
typedef push_data_function<DoublyLinked> push_data_t;
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Named new capable shared mem allocator
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
@@ -264,10 +264,10 @@ int list_test (bool copied_allocators_equal = true)
|
||||
if(!segment.all_memory_deallocated())
|
||||
return 1;
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(shMemName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ using namespace boost::interprocess;
|
||||
|
||||
void remove_shared_memory(const xsi_key &key)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
xsi_shared_memory xsi(open_only, key);
|
||||
xsi_shared_memory::remove(xsi.get_shmid());
|
||||
}
|
||||
catch(interprocess_exception &e){
|
||||
BOOST_CATCH(interprocess_exception &e){
|
||||
if(e.get_error_code() != not_found_error)
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
class xsi_shared_memory_remover
|
||||
|
||||
@@ -52,7 +52,7 @@ int map_test ()
|
||||
const char *const shMemName = test::get_process_id_name();
|
||||
const int max = 100;
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
ManagedSharedMemory segment(create_only, shMemName, memsize);
|
||||
@@ -482,10 +482,10 @@ int map_test ()
|
||||
if(!segment.all_memory_deallocated())
|
||||
return 1;
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(shMemName);
|
||||
return 0;
|
||||
}
|
||||
@@ -505,7 +505,7 @@ int map_test_copyable ()
|
||||
const char *const shMemName = test::get_process_id_name();
|
||||
const int max = 100;
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
ManagedSharedMemory segment(create_only, shMemName, memsize);
|
||||
@@ -576,10 +576,10 @@ int map_test_copyable ()
|
||||
if(!segment.all_memory_deallocated())
|
||||
return 1;
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(shMemName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -153,14 +153,14 @@ bool test_serialize_db()
|
||||
return false;
|
||||
|
||||
//Fill map1 until is full
|
||||
try{
|
||||
BOOST_TRY{
|
||||
std::size_t i = 0;
|
||||
while(1){
|
||||
(*map1)[i] = i;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
catch(boost::interprocess::bad_alloc &){}
|
||||
BOOST_CATCH(boost::interprocess::bad_alloc &){} BOOST_CATCH_END
|
||||
|
||||
//Data control data sending through the message queue
|
||||
std::size_t sent = 0;
|
||||
@@ -320,7 +320,7 @@ bool test_multi_sender_receiver()
|
||||
{
|
||||
bool ret = true;
|
||||
//std::cout << "Testing multi-sender / multi-receiver " << std::endl;
|
||||
try {
|
||||
BOOST_TRY {
|
||||
boost::interprocess::message_queue::remove(test::get_process_id_name());
|
||||
boost::interprocess::message_queue mq
|
||||
(boost::interprocess::open_or_create, test::get_process_id_name(), MULTI_QUEUE_SIZE, 1);
|
||||
@@ -343,10 +343,10 @@ bool test_multi_sender_receiver()
|
||||
//std::cout << "Joined thread " << i << std::endl;
|
||||
}
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
BOOST_CATCH(std::exception &e) {
|
||||
std::cout << "error " << e.what() << std::endl;
|
||||
ret = false;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
boost::interprocess::message_queue::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
@@ -402,7 +402,7 @@ class msg_queue_named_test_wrapper_w
|
||||
int main ()
|
||||
{
|
||||
int ret = 0;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
message_queue::remove(test::get_process_id_name());
|
||||
test::test_named_creation<msg_queue_named_test_wrapper>();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
@@ -425,10 +425,10 @@ int main ()
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
BOOST_CATCH(std::exception &ex) {
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
message_queue::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
|
||||
@@ -74,16 +74,17 @@ int test_owner_dead_mutex_impl(EOwnerDeadLockType lock_type)
|
||||
ipcdetail::OS_thread_t tm1;
|
||||
ipcdetail::thread_launch(tm1, thread_adapter<M>(&lock_and_exit, 0, mtx));
|
||||
ipcdetail::thread_join(tm1);
|
||||
try {
|
||||
BOOST_TRY {
|
||||
test_owner_dead_mutex_do_lock(mtx, lock_type);
|
||||
}
|
||||
catch (lock_exception& e) {
|
||||
BOOST_CATCH(lock_exception& e) {
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (e.get_error_code() == not_recoverable){
|
||||
//Now try once again to lock it, to make sure it's not recoverable
|
||||
try {
|
||||
BOOST_TRY {
|
||||
test_owner_dead_mutex_do_lock(mtx, lock_type);
|
||||
}
|
||||
catch (lock_exception& e) {
|
||||
BOOST_CATCH(lock_exception& e) {
|
||||
if (e.get_error_code() == not_recoverable)
|
||||
return 0;
|
||||
else{
|
||||
@@ -91,10 +92,10 @@ int test_owner_dead_mutex_impl(EOwnerDeadLockType lock_type)
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
BOOST_CATCH(...) {
|
||||
std::cerr << "lock_exception not thrown! (2)";
|
||||
return 4;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
std::cerr << "Exception not thrown (2)!";
|
||||
return 5;
|
||||
}
|
||||
@@ -102,11 +103,12 @@ int test_owner_dead_mutex_impl(EOwnerDeadLockType lock_type)
|
||||
std::cerr << "e.get_error_code() != not_recoverable!";
|
||||
return 1;
|
||||
}
|
||||
#endif //BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...) {
|
||||
BOOST_CATCH(...) {
|
||||
std::cerr << "lock_exception not thrown!";
|
||||
return 2;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
std::cerr << "Exception not thrown!";
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ template<typename M>
|
||||
void lock_and_catch_errors(void *arg, M &sm)
|
||||
{
|
||||
data<M> *pdata = static_cast<data<M>*>(arg);
|
||||
try
|
||||
BOOST_TRY
|
||||
{
|
||||
boost::interprocess::scoped_lock<M> l(sm);
|
||||
if(pdata->m_secs){
|
||||
@@ -206,10 +206,10 @@ void lock_and_catch_errors(void *arg, M &sm)
|
||||
++shared_val;
|
||||
pdata->m_value = shared_val;
|
||||
}
|
||||
catch(interprocess_exception const & e)
|
||||
BOOST_CATCH(interprocess_exception const & e)
|
||||
{
|
||||
pdata->m_error = e.get_error_code();
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
template<typename M>
|
||||
|
||||
@@ -436,7 +436,7 @@ bool test_named_allocation()
|
||||
|
||||
const int memsize = 163840;
|
||||
const char *const shMemName = test::get_process_id_name();
|
||||
try
|
||||
BOOST_TRY
|
||||
{
|
||||
//A shared memory with rbtree best fit algorithm
|
||||
typedef basic_managed_shared_memory
|
||||
@@ -454,14 +454,14 @@ bool test_named_allocation()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(shMemName);
|
||||
|
||||
//Now test it with wchar_t
|
||||
try
|
||||
BOOST_TRY
|
||||
{
|
||||
//A shared memory with simple sequential fit algorithm
|
||||
typedef basic_managed_shared_memory
|
||||
@@ -479,10 +479,10 @@ bool test_named_allocation()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(shMemName);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -234,7 +234,7 @@ template<class NamedCondition, class NamedMutex>
|
||||
int test_named_condition()
|
||||
{
|
||||
int ret = 0;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Remove previous mutexes and conditions
|
||||
NamedMutex::remove(test::add_to_process_id_name("test_mutex0"));
|
||||
NamedCondition::remove(test::add_to_process_id_name("test_cond0"));
|
||||
@@ -255,10 +255,10 @@ int test_named_condition()
|
||||
test::do_test_condition<test::named_condition_test_wrapper<NamedCondition>
|
||||
,test::named_mutex_test_wrapper<NamedMutex> >();
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
NamedMutex::remove(test::add_to_process_id_name("test_mutex0"));
|
||||
NamedCondition::remove(test::add_to_process_id_name("test_cond0"));
|
||||
NamedCondition::remove(test::add_to_process_id_name("test_cond1"));
|
||||
|
||||
@@ -24,16 +24,16 @@ namespace boost { namespace interprocess { namespace test {
|
||||
template <class NamedResource>
|
||||
inline void create_then_open_then_open_or_create()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Create it and open it twice
|
||||
NamedResource nresource1(create_only);
|
||||
NamedResource nresource2(open_only);
|
||||
NamedResource nresource3(open_or_create);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
//This shouldn't throw so show the error
|
||||
BOOST_INTERPROCESS_CHECK( false );
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
template <class NamedResource>
|
||||
@@ -41,25 +41,25 @@ inline void open_or_create_then_create()
|
||||
{
|
||||
//Create it with open_or_create and try to create it twice
|
||||
NamedResource nresource1(open_or_create);
|
||||
try{
|
||||
BOOST_TRY{
|
||||
NamedResource nresource2(create_only);
|
||||
}
|
||||
catch(interprocess_exception &err){
|
||||
BOOST_CATCH(interprocess_exception &err){
|
||||
BOOST_INTERPROCESS_CHECK(err.get_error_code() == already_exists_error);
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
template <class NamedResource>
|
||||
inline void dont_create_and_open()
|
||||
{
|
||||
//Try to open it without creating
|
||||
try{
|
||||
BOOST_TRY{
|
||||
NamedResource nresource1(open_only);
|
||||
}
|
||||
catch(interprocess_exception &err){
|
||||
BOOST_CATCH(interprocess_exception &err){
|
||||
BOOST_INTERPROCESS_CHECK(err.get_error_code() == not_found_error);
|
||||
return;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
//The mutex should not exist
|
||||
BOOST_INTERPROCESS_CHECK(false);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ template<class NamedMutex>
|
||||
int test_named_mutex()
|
||||
{
|
||||
int ret = 0;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
NamedMutex::remove(test::get_process_id_name());
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<NamedMutex> >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
@@ -34,10 +34,10 @@ int test_named_mutex()
|
||||
test::test_all_lock< test::named_sync_wrapper<NamedMutex> >();
|
||||
test::test_all_mutex<test::named_sync_wrapper<NamedMutex> >();
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
NamedMutex::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ template<class NamedRecursiveMutex>
|
||||
int test_named_recursive_mutex()
|
||||
{
|
||||
int ret = 0;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
NamedRecursiveMutex::remove(test::get_process_id_name());
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<NamedRecursiveMutex> >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
@@ -37,10 +37,10 @@ int test_named_recursive_mutex()
|
||||
test::test_all_mutex<test::named_sync_wrapper<NamedRecursiveMutex> >();
|
||||
test::test_all_recursive_lock<test::named_sync_wrapper<NamedRecursiveMutex> >();
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
NamedRecursiveMutex::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ template<class NamedSemaphore>
|
||||
int test_named_semaphore()
|
||||
{
|
||||
int ret = 0;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<lock_test_wrapper<NamedSemaphore> > >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper_w<lock_test_wrapper<NamedSemaphore> > >();
|
||||
@@ -134,10 +134,10 @@ int test_named_semaphore()
|
||||
test::test_all_recursive_lock<test::named_sync_wrapper<recursive_test_wrapper<NamedSemaphore> > >();
|
||||
test_named_semaphore_specific<NamedSemaphore>();
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
NamedSemaphore::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace boost::interprocess;
|
||||
int main ()
|
||||
{
|
||||
int ret = 0;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
named_sharable_mutex::remove(test::get_process_id_name());
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<named_sharable_mutex> >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
@@ -30,10 +30,10 @@ int main ()
|
||||
test::test_all_mutex<test::named_sync_wrapper<named_sharable_mutex> >();
|
||||
test::test_all_sharable_mutex<test::named_sync_wrapper<named_sharable_mutex> >();
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
named_sharable_mutex::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace boost::interprocess;
|
||||
int main ()
|
||||
{
|
||||
int ret = 0;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
named_upgradable_mutex::remove(test::get_process_id_name());
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<named_upgradable_mutex> >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
@@ -30,10 +30,10 @@ int main ()
|
||||
test::test_all_mutex<test::named_sync_wrapper<named_upgradable_mutex> >();
|
||||
test::test_all_sharable_mutex<test::named_sync_wrapper<named_upgradable_mutex> >();
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
named_upgradable_mutex::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace test{
|
||||
template<class RobustMutex>
|
||||
int robust_mutex_test(int argc, char *argv[])
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
if(argc == 1){ //Parent process
|
||||
//First usual mutex tests
|
||||
{
|
||||
@@ -101,12 +101,12 @@ int robust_mutex_test(int argc, char *argv[])
|
||||
instance[1].unlock();
|
||||
//Since it's NOT consistent, locking is NOT possible again
|
||||
bool exception_thrown = false;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
instance[1].lock();
|
||||
}
|
||||
catch(interprocess_exception &){
|
||||
BOOST_CATCH(interprocess_exception &){
|
||||
exception_thrown = true;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
if(!exception_thrown){
|
||||
return 1;
|
||||
}
|
||||
@@ -125,12 +125,12 @@ int robust_mutex_test(int argc, char *argv[])
|
||||
instance[2].unlock();
|
||||
//Since it's NOT consistent, locking is NOT possible again
|
||||
bool exception_thrown = false;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
instance[2].lock();
|
||||
}
|
||||
catch(interprocess_exception &){
|
||||
BOOST_CATCH(interprocess_exception &){
|
||||
exception_thrown = true;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
if(!exception_thrown){
|
||||
return 1;
|
||||
}
|
||||
@@ -192,10 +192,10 @@ int robust_mutex_test(int argc, char *argv[])
|
||||
*go_ahead2 = true;
|
||||
}
|
||||
}
|
||||
}catch(...){
|
||||
}BOOST_CATCH(...){
|
||||
std::cout << "Exception thrown error!" << std::endl;
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ bool test_segment_manager()
|
||||
return false;
|
||||
if(seg_mgr->get_free_memory() != free_mem_before)
|
||||
return false;
|
||||
try{ seg_mgr->allocate(ShmSizeSize*2); }catch(interprocess_exception&){}
|
||||
BOOST_TRY{ seg_mgr->allocate(ShmSizeSize*2); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
|
||||
if(seg_mgr->get_free_memory() != free_mem_before)
|
||||
return false;
|
||||
if(seg_mgr->allocate(ShmSizeSize*2, std::nothrow))
|
||||
@@ -121,7 +121,7 @@ bool test_segment_manager()
|
||||
return false;
|
||||
if(seg_mgr->get_free_memory() != free_mem_before)
|
||||
return false;
|
||||
try{ seg_mgr->allocate_aligned(ShmSizeSize*2, Alignment); }catch(interprocess_exception&){}
|
||||
BOOST_TRY{ seg_mgr->allocate_aligned(ShmSizeSize*2, Alignment); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
|
||||
if(seg_mgr->get_free_memory() != free_mem_before)
|
||||
return false;
|
||||
if(seg_mgr->allocate_aligned(ShmSizeSize*2, Alignment, std::nothrow))
|
||||
@@ -210,9 +210,9 @@ bool test_segment_manager()
|
||||
if(seg_mgr->get_instance_name(int_array))
|
||||
return false;
|
||||
seg_mgr->destroy_ptr(int_array);
|
||||
try{ seg_mgr->template construct<int>(anonymous_instance)[ShmSizeSize](); }catch(interprocess_exception&){}
|
||||
BOOST_TRY{ seg_mgr->template construct<int>(anonymous_instance)[ShmSizeSize](); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
|
||||
if(seg_mgr->template construct<int>(anonymous_instance, std::nothrow)[ShmSizeSize]())
|
||||
try{ seg_mgr->template construct_it<int>(anonymous_instance)[ShmSizeSize](&int_array_values[0]); }catch(interprocess_exception&){}
|
||||
BOOST_TRY{ seg_mgr->template construct_it<int>(anonymous_instance)[ShmSizeSize](&int_array_values[0]); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
|
||||
if(seg_mgr->template construct_it<int>(anonymous_instance, std::nothrow)[ShmSizeSize](&int_array_values[0]))
|
||||
return false;
|
||||
if(seg_mgr->get_free_memory() != free_mem_before)
|
||||
@@ -295,9 +295,9 @@ bool test_segment_manager()
|
||||
seg_mgr->destroy_ptr(uint_object);
|
||||
seg_mgr->template destroy<int>(object2_name);
|
||||
}
|
||||
try{ seg_mgr->template construct<unsigned int>(object1_name)[ShmSizeSize](); }catch(interprocess_exception&){}
|
||||
BOOST_TRY{ seg_mgr->template construct<unsigned int>(object1_name)[ShmSizeSize](); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
|
||||
if(seg_mgr->template construct<int>(object2_name, std::nothrow)[ShmSizeSize]())
|
||||
try{ seg_mgr->template construct_it<unsigned int>(object1_name)[ShmSizeSize](&int_array_values[0]); }catch(interprocess_exception&){}
|
||||
BOOST_TRY{ seg_mgr->template construct_it<unsigned int>(object1_name)[ShmSizeSize](&int_array_values[0]); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
|
||||
if(seg_mgr->template construct_it<int>(object2_name, std::nothrow)[ShmSizeSize](&int_array_values[0]))
|
||||
return false;
|
||||
seg_mgr->shrink_to_fit_indexes();
|
||||
@@ -385,9 +385,9 @@ bool test_segment_manager()
|
||||
seg_mgr->destroy_ptr(uint_object);
|
||||
seg_mgr->template destroy<int>(unique_instance);
|
||||
}
|
||||
try{ seg_mgr->template construct<unsigned int>(unique_instance)[ShmSizeSize](); }catch(interprocess_exception&){}
|
||||
BOOST_TRY{ seg_mgr->template construct<unsigned int>(unique_instance)[ShmSizeSize](); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
|
||||
if(seg_mgr->template construct<int>(unique_instance, std::nothrow)[ShmSizeSize]())
|
||||
try{ seg_mgr->template construct_it<unsigned int>(unique_instance)[ShmSizeSize](&int_array_values[0]); }catch(interprocess_exception&){}
|
||||
BOOST_TRY{ seg_mgr->template construct_it<unsigned int>(unique_instance)[ShmSizeSize](&int_array_values[0]); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
|
||||
if(seg_mgr->template construct_it<int>(unique_instance, std::nothrow)[ShmSizeSize](&int_array_values[0]))
|
||||
return false;
|
||||
seg_mgr->shrink_to_fit_indexes();
|
||||
|
||||
@@ -35,7 +35,7 @@ int set_test ()
|
||||
const char *const shMemName = test::get_process_id_name();
|
||||
const int max = 100;
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
ManagedSharedMemory segment(create_only, shMemName, memsize);
|
||||
@@ -490,10 +490,10 @@ int set_test ()
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(shMemName);
|
||||
return 0;
|
||||
}
|
||||
@@ -510,7 +510,7 @@ int set_test_copyable ()
|
||||
const char *const shMemName = test::get_process_id_name();
|
||||
const int max = 100;
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
ManagedSharedMemory segment(create_only, shMemName, memsize);
|
||||
@@ -577,10 +577,10 @@ int set_test_copyable ()
|
||||
if(!segment.all_memory_deallocated())
|
||||
return 1;
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
shared_memory_object::remove(shMemName);
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(shMemName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ int main ()
|
||||
std::string process_id = test::get_process_id_name();
|
||||
std::string process_id2(process_id);
|
||||
process_id2 += "_2";
|
||||
try{
|
||||
BOOST_TRY{
|
||||
const std::size_t FileSize = 99999*4;
|
||||
{
|
||||
//Remove shared memory
|
||||
@@ -200,19 +200,19 @@ int main ()
|
||||
mapped_region region (mapping, read_only);
|
||||
shared_memory_object mapping2(create_only, process_id2.c_str(), read_write);
|
||||
mapping2.truncate(FileSize);
|
||||
try{
|
||||
BOOST_TRY{
|
||||
mapped_region region2 (mapping2, read_only, 0, FileSize, region.get_address());
|
||||
}
|
||||
catch(interprocess_exception &e){
|
||||
BOOST_CATCH(interprocess_exception &e){
|
||||
shared_memory_object::remove(process_id2.c_str());
|
||||
if(e.get_error_code() != busy_error){
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
catch(std::exception &){
|
||||
BOOST_CATCH(std::exception &){
|
||||
shared_memory_object::remove(process_id2.c_str());
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(process_id2.c_str());
|
||||
}
|
||||
{
|
||||
@@ -246,12 +246,12 @@ int main ()
|
||||
shared_memory_object ret(get_shared_memory_mapping());
|
||||
}
|
||||
}
|
||||
catch(std::exception &exc){
|
||||
BOOST_CATCH(std::exception &exc){
|
||||
shared_memory_object::remove(process_id.c_str());
|
||||
shared_memory_object::remove(process_id2.c_str());
|
||||
std::cout << "Unhandled exception: " << exc.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(process_id.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class shared_memory_creation_test_wrapper_w
|
||||
|
||||
int main ()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
shared_memory_object::remove(ShmName);
|
||||
test::test_named_creation<shared_memory_creation_test_wrapper>();
|
||||
#ifdef BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES
|
||||
@@ -102,11 +102,11 @@ int main ()
|
||||
move_assign = boost::move(move_ctor);
|
||||
}
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
shared_memory_object::remove(ShmName);
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(ShmName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -230,14 +230,14 @@ int string_shared_ptr_vector_insertion_test()
|
||||
}
|
||||
bool success = false;
|
||||
//Now this should throw
|
||||
try{
|
||||
BOOST_TRY{
|
||||
string_shared_ptr_t dummy(*beg);
|
||||
//We should never reach here
|
||||
return 1;
|
||||
}
|
||||
catch(const boost::interprocess::bad_weak_ptr &){
|
||||
BOOST_CATCH(const boost::interprocess::bad_weak_ptr &){
|
||||
success = true;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
if(!success){
|
||||
return 1;
|
||||
}
|
||||
@@ -466,12 +466,12 @@ int basic_shared_ptr_test()
|
||||
BOOST_TEST(wp1.expired());
|
||||
BOOST_TEST(wp1.use_count() == 0);
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
x_shared_ptr sp1(wp1);
|
||||
BOOST_ERROR("shared_ptr<X, A, D> sp1(wp1) failed to throw");
|
||||
}
|
||||
catch(boost::interprocess::bad_weak_ptr const &)
|
||||
{}
|
||||
BOOST_CATCH(boost::interprocess::bad_weak_ptr const &)
|
||||
{} BOOST_CATCH_END
|
||||
|
||||
test_is_zero(wp1.lock());
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ int main()
|
||||
{
|
||||
//Remove any other old shared memory from the system
|
||||
bip::shared_memory_object::remove(bip::test::get_process_id_name());
|
||||
try {
|
||||
BOOST_TRY {
|
||||
bip::managed_shared_memory shm(bip::create_only, bip::test::get_process_id_name(), 65536);
|
||||
|
||||
//Elements to be inserted in unordered containers
|
||||
@@ -86,11 +86,11 @@ int main()
|
||||
return 1;
|
||||
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
//Remove shared memory from the system
|
||||
bip::shared_memory_object::remove(bip::test::get_process_id_name());
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
//Remove shared memory from the system
|
||||
bip::shared_memory_object::remove(bip::test::get_process_id_name());
|
||||
return 0;
|
||||
|
||||
@@ -204,12 +204,12 @@ int main ()
|
||||
delete stdlist;
|
||||
|
||||
//Fill heap buffer until is full
|
||||
try{
|
||||
BOOST_TRY{
|
||||
while(1){
|
||||
heaplist->insert(heaplist->end(), 0);
|
||||
}
|
||||
}
|
||||
catch(boost::interprocess::bad_alloc &){}
|
||||
BOOST_CATCH(boost::interprocess::bad_alloc &){} BOOST_CATCH_END
|
||||
|
||||
MyHeapList::size_type heap_list_size = heaplist->size();
|
||||
|
||||
@@ -237,12 +237,12 @@ int main ()
|
||||
}
|
||||
|
||||
//Fill user buffer until is full
|
||||
try{
|
||||
BOOST_TRY{
|
||||
while(1){
|
||||
userlist->insert(userlist->end(), 0);
|
||||
}
|
||||
}
|
||||
catch(boost::interprocess::bad_alloc &){}
|
||||
BOOST_CATCH(boost::interprocess::bad_alloc &){} BOOST_CATCH_END
|
||||
|
||||
MyUserList::size_type user_list_size = userlist->size();
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ int vector_test()
|
||||
//Compare several shared memory vector operations with std::vector
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
try{
|
||||
BOOST_TRY{
|
||||
ManagedSharedMemory segment(create_only, shMemName, Memsize);
|
||||
|
||||
segment.reserve_named_objects(100);
|
||||
@@ -234,11 +234,11 @@ int vector_test()
|
||||
if(!segment.all_memory_deallocated())
|
||||
return 1;
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
shared_memory_object::remove(shMemName);
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
shared_memory_object::remove(shMemName);
|
||||
std::cout << std::endl << "Test OK!" << std::endl;
|
||||
|
||||
@@ -125,7 +125,7 @@ class shared_memory_creation_test_wrapper_w
|
||||
int main ()
|
||||
{
|
||||
int ret = 0;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
shared_memory_object::remove(ShmName);
|
||||
test::test_named_creation<shared_memory_creation_test_wrapper>();
|
||||
#ifdef BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES
|
||||
@@ -146,10 +146,10 @@ int main ()
|
||||
move_assign = boost::move(move_ctor);
|
||||
}
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
shared_memory_object::remove(ShmName);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace boost::interprocess;
|
||||
|
||||
int main ()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
const char *names[2] = { test::get_process_id_name(), 0 };
|
||||
for(unsigned int i_name = 0; i_name < sizeof(names)/sizeof(names[0]); ++i_name)
|
||||
{
|
||||
@@ -116,11 +116,11 @@ int main ()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(std::exception &exc){
|
||||
BOOST_CATCH(std::exception &exc){
|
||||
//shared_memory_object::remove(test::get_process_id_name());
|
||||
std::cout << "Unhandled exception: " << exc.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -84,16 +84,16 @@ class shared_memory_creation_test_wrapper_w
|
||||
|
||||
int main ()
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
test::test_named_creation<shared_memory_creation_test_wrapper>();
|
||||
#ifdef BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES
|
||||
test::test_named_creation<shared_memory_creation_test_wrapper_w>();
|
||||
#endif
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -26,14 +26,14 @@ using namespace boost::interprocess;
|
||||
|
||||
void remove_shared_memory(const xsi_key &key)
|
||||
{
|
||||
try{
|
||||
BOOST_TRY{
|
||||
xsi_shared_memory xsi(open_only, key);
|
||||
xsi_shared_memory::remove(xsi.get_shmid());
|
||||
}
|
||||
catch(interprocess_exception &e){
|
||||
BOOST_CATCH(interprocess_exception &e){
|
||||
if(e.get_error_code() != not_found_error)
|
||||
throw;
|
||||
}
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
|
||||
class xsi_shared_memory_remover
|
||||
@@ -61,23 +61,23 @@ int main ()
|
||||
remove_shared_memory(key);
|
||||
|
||||
unsigned int i;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
for(i = 0; i < sizeof(names)/sizeof(names[0]); ++i)
|
||||
{
|
||||
const std::size_t FileSize = 99999*2;
|
||||
//Create a file mapping
|
||||
xsi_shared_memory mapping (create_only, names[i] ? key : xsi_key(), FileSize);
|
||||
xsi_shared_memory_remover rem(mapping);
|
||||
try{
|
||||
BOOST_TRY{
|
||||
{
|
||||
//Partial mapping should fail fox XSI shared memory
|
||||
bool thrown = false;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
mapped_region region2(mapping, read_write, FileSize/2, FileSize - FileSize/2, 0);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
thrown = true;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
if(thrown == false){
|
||||
return 1;
|
||||
}
|
||||
@@ -105,16 +105,16 @@ int main ()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(std::exception &exc){
|
||||
BOOST_CATCH(std::exception &exc){
|
||||
std::cout << "Unhandled exception: " << exc.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
}
|
||||
catch(std::exception &exc){
|
||||
BOOST_CATCH(std::exception &exc){
|
||||
std::cout << "Unhandled exception: " << exc.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user