|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54783 - in trunk/boost/archive: detail impl
From: ramey_at_[hidden]
Date: 2009-07-07 17:56:18
Author: ramey
Date: 2009-07-07 17:56:18 EDT (Tue, 07 Jul 2009)
New Revision: 54783
URL: http://svn.boost.org/trac/boost/changeset/54783
Log:
Changes to address failure same object in two different DLLS is serialized via a pointer
Text files modified:
trunk/boost/archive/detail/basic_serializer.hpp | 6 +++++-
trunk/boost/archive/impl/archive_pointer_iserializer.ipp | 32 +++++++++++++++++++-------------
trunk/boost/archive/impl/archive_pointer_oserializer.ipp | 33 +++++++++++++++++----------------
3 files changed, 41 insertions(+), 30 deletions(-)
Modified: trunk/boost/archive/detail/basic_serializer.hpp
==============================================================================
--- trunk/boost/archive/detail/basic_serializer.hpp (original)
+++ trunk/boost/archive/detail/basic_serializer.hpp 2009-07-07 17:56:18 EDT (Tue, 07 Jul 2009)
@@ -46,7 +46,11 @@
inline bool
operator<(const basic_serializer & lhs, const basic_serializer & rhs) {
- return & lhs.get_eti() < & rhs.get_eti();
+ // can't compare address since there can be multiple eti records
+ // for the same type in different execution modules (that is, DLLS)
+ // leave this here as a reminder not to do this!
+ // return & lhs.get_eti() < & rhs.get_eti();
+ return lhs.get_eti() < rhs.get_eti();
}
class basic_serializer_arg : public basic_serializer {
Modified: trunk/boost/archive/impl/archive_pointer_iserializer.ipp
==============================================================================
--- trunk/boost/archive/impl/archive_pointer_iserializer.ipp (original)
+++ trunk/boost/archive/impl/archive_pointer_iserializer.ipp 2009-07-07 17:56:18 EDT (Tue, 07 Jul 2009)
@@ -40,11 +40,14 @@
) :
basic_pointer_iserializer(eti)
{
- std::pair<BOOST_DEDUCED_TYPENAME iserializer_map<Archive>::iterator, bool> result;
- result = serialization::singleton<
- iserializer_map<Archive>
- >::get_mutable_instance().insert(this);
- assert(result.second);
+ // only insert the first one. Assumes that DLLS are unloaded in
+ // the reverse sequence
+ //std::pair<BOOST_DEDUCED_TYPENAME iserializer_map<Archive>::iterator, bool> result;
+ iserializer_map<Archive> & map
+ = serialization::singleton<iserializer_map<Archive> >::get_mutable_instance();
+ iserializer_map<Archive>::iterator result = map.find(this);
+ if(result == map.end())
+ map.insert(this);
}
template<class Archive>
@@ -70,16 +73,19 @@
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
archive_pointer_iserializer<Archive>::~archive_pointer_iserializer(){
- if(! serialization::singleton<
+ // note: we need to check that the map still exists as we can't depend
+ // on static variables being constructed in a specific sequence
+ if(serialization::singleton<
iserializer_map<Archive>
>::is_destroyed()
- ){
- std::size_t count;
- count = serialization::singleton<
- iserializer_map<Archive>
- >::get_mutable_instance().erase(this);
- assert(count);
- }
+ )
+ return;
+
+ iserializer_map<Archive> & map
+ = serialization::singleton<iserializer_map<Archive> >::get_mutable_instance();
+ iserializer_map<Archive>::iterator result = map.find(this);
+ if(result == map.end())
+ map.erase(this);
}
} // namespace detail
Modified: trunk/boost/archive/impl/archive_pointer_oserializer.ipp
==============================================================================
--- trunk/boost/archive/impl/archive_pointer_oserializer.ipp (original)
+++ trunk/boost/archive/impl/archive_pointer_oserializer.ipp 2009-07-07 17:56:18 EDT (Tue, 07 Jul 2009)
@@ -35,14 +35,14 @@
) :
basic_pointer_oserializer(eti)
{
- std::pair<
- BOOST_DEDUCED_TYPENAME oserializer_map<Archive>::iterator,
- bool
- > result;
- result = serialization::singleton<
- oserializer_map<Archive>
- >::get_mutable_instance().insert(this);
- assert(result.second);
+ // only insert the first one. Assumes that DLLS are unloaded in
+ // the reverse sequence
+ //std::pair<BOOST_DEDUCED_TYPENAME oserializer_map<Archive>::iterator, bool> result;
+ oserializer_map<Archive> & map
+ = serialization::singleton<oserializer_map<Archive> >::get_mutable_instance();
+ oserializer_map<Archive>::iterator result = map.find(this);
+ if(result == map.end())
+ map.insert(this);
}
template<class Archive>
@@ -70,16 +70,17 @@
archive_pointer_oserializer<Archive>::~archive_pointer_oserializer(){
// note: we need to check that the map still exists as we can't depend
// on static variables being constructed in a specific sequence
- if(! serialization::singleton<
+ if(serialization::singleton<
oserializer_map<Archive>
>::is_destroyed()
- ){
- unsigned int count;
- count = serialization::singleton<
- oserializer_map<Archive>
- >::get_mutable_instance().erase(this);
- assert(count);
- }
+ )
+ return;
+
+ oserializer_map<Archive> & map
+ = serialization::singleton<oserializer_map<Archive> >::get_mutable_instance();
+ oserializer_map<Archive>::iterator result = map.find(this);
+ if(result == map.end())
+ map.erase(this);
}
} // namespace detail
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