diff options
author | fields_t <fields_t@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-12-15 05:03:41 +0000 |
---|---|---|
committer | fields_t <fields_t@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-12-15 05:03:41 +0000 |
commit | 6fdcc224a39537c7644a4c430f9ce54ca3aeb4ba (patch) | |
tree | d3b81469307e9067ca34559cb75f675afaeaca56 | |
parent | 70f434c89ce245250ca68999ae02cafea57fc2d2 (diff) | |
download | ATCD-6fdcc224a39537c7644a4c430f9ce54ca3aeb4ba.tar.gz |
ChangeLogTag: Mon Dec 15 04:55:10 UTC 2008 Trevor Fields <fields_t@ociweb.com>
-rw-r--r-- | TAO/ChangeLog | 16 | ||||
-rw-r--r-- | TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h | 8 | ||||
-rw-r--r-- | TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl | 61 | ||||
-rw-r--r-- | TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp | 68 |
4 files changed, 117 insertions, 36 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 99d66d632d5..59600041284 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,19 @@ +Mon Dec 15 04:55:10 UTC 2008 Trevor Fields <fields_t@ociweb.com> + + * tao/AnyTypeCode/Recursive_Type_TypeCode.h: + * tao/AnyTypeCode/Recursive_Type_TypeCode.inl: + * tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp: + Reverted change in + Mon Dec 01 19:47:02 UTC 2008 Trevor Fields <fields_t@ociweb.com> + because it introduced a memory leak. + Changed the recursive type code to not over write previously + assigned members. This can occur when a recusive typecode + has already been extracted and then is extracted again. + The extraction routine detects that recursive type code did + not over write the pre existing members and increments the + reference count on the the typecode to account for the reference + in the local member of the extraction method. + Wed Dec 10 21:49:00 UTC 2008 Ciju John <johnc at ociweb dot com> * tests/Objref_Sequence_Test/run_test.pl: diff --git a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h index 3f0b24474be..75bcdd79a30 100644 --- a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h +++ b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h @@ -114,12 +114,12 @@ namespace TAO public: /// Set @c struct @c TypeCode parameters. - void struct_parameters (char const * name, + bool struct_parameters (char const * name, MemberArrayType const & fields, CORBA::ULong nfields); /// Set @c union @c TypeCode parameters. - void union_parameters ( + bool union_parameters ( char const * name, TypeCodeType const & discriminant_type, MemberArrayType const & cases, @@ -127,7 +127,7 @@ namespace TAO CORBA::Long default_index); /// Set @c valuetype or @c eventtype @c TypeCode parameters. - void valuetype_parameters (char const * name, + bool valuetype_parameters (char const * name, CORBA::ValueModifier modifier, TypeCodeType const & concrete_base, MemberArrayType const & fields, @@ -164,6 +164,8 @@ namespace TAO */ mutable bool in_recursion_; + /// Track whether data has been initialized. + bool data_initialized_; }; } // End namespace TypeCode diff --git a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl index c7f9917972c..8c285e02ce8 100644 --- a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl +++ b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl @@ -17,6 +17,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase, : TypeCodeBase (kind, id, name, fields, nfields) , lock_ () , in_recursion_ (false) + , data_initialized_(true) { // ACE_ASSERT (kind != CORBA::tk_except); } @@ -40,6 +41,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase, default_index) , lock_ () , in_recursion_ (false) + , data_initialized_(true) { } @@ -64,6 +66,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase, nfields) , lock_ () , in_recursion_ (false) + , data_initialized_(true) { } @@ -77,6 +80,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase, : TypeCodeBase (kind, id) , lock_ () , in_recursion_ (false) + , data_initialized_(false) { // ACE_ASSERT (kind == CORBA::tk_struct // || kind == CORBA::tk_union @@ -85,7 +89,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase, } template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> -ACE_INLINE void +ACE_INLINE bool TAO::TypeCode::Recursive_Type<TypeCodeBase, TypeCodeType, MemberArrayType>::struct_parameters ( @@ -93,13 +97,22 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase, MemberArrayType const & fields, CORBA::ULong nfields) { - this->base_attributes_.name (name); - this->fields_ = fields; - this->nfields_ = nfields; + // Do not replace pre-existing fields! + if ( !this->data_initialized_ ) + { + this->base_attributes_.name (name); + this->fields_ = fields; + this->nfields_ = nfields; + this->data_initialized_ = true; + + return true; + } + + return false; } template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> -ACE_INLINE void +ACE_INLINE bool TAO::TypeCode::Recursive_Type<TypeCodeBase, TypeCodeType, MemberArrayType>::union_parameters ( @@ -109,15 +122,23 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase, CORBA::ULong ncases, CORBA::Long default_index) { - this->base_attributes_.name (name); - this->discriminant_type_ = discriminant_type; - this->cases_ = cases; - this->ncases_ = ncases; - this->default_index_ = default_index; + if ( !this->data_initialized_ ) + { + this->base_attributes_.name (name); + this->discriminant_type_ = discriminant_type; + this->cases_ = cases; + this->ncases_ = ncases; + this->default_index_ = default_index; + this->data_initialized_ = true; + + return true; + } + + return false; } template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> -ACE_INLINE void +ACE_INLINE bool TAO::TypeCode::Recursive_Type<TypeCodeBase, TypeCodeType, MemberArrayType>::valuetype_parameters ( @@ -127,11 +148,19 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase, MemberArrayType const & fields, CORBA::ULong nfields) { - this->base_attributes_.name (name); - this->type_modifier_ = modifier; - this->concrete_base_ = concrete_base; - this->fields_ = fields; - this->nfields_ = nfields; + if ( !this->data_initialized_ ) + { + this->base_attributes_.name (name); + this->type_modifier_ = modifier; + this->concrete_base_ = concrete_base; + this->fields_ = fields; + this->nfields_ = nfields; + this->data_initialized_ = true; + + return true; + } + + return false; } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp index 06a7be2b7f7..0f1e267a37d 100644 --- a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp +++ b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp @@ -453,6 +453,7 @@ TAO::TypeCodeFactory::tc_struct_factory (CORBA::TCKind kind, size_t const len = recursive_tc.size (); + bool assigned_params = false; for (size_t i = 0; i < len; ++i) { TAO::TypeCodeFactory::TC_Info & info = recursive_tc[i]; @@ -463,10 +464,20 @@ TAO::TypeCodeFactory::tc_struct_factory (CORBA::TCKind kind, if (!rtc) return false; // Should never occur. - rtc->struct_parameters (name.in (), fields, nfields); + assigned_params |= rtc->struct_parameters (name.in (), fields, nfields); } - tc = CORBA::TypeCode::_duplicate(recursive_tc[0].type); + // If no parameters were assigned then the reference in the + // fields variable will be released when the variable is destroyed. + // Increment the reference count. + if ( !assigned_params) + { + tc = CORBA::TypeCode::_duplicate(recursive_tc[0].type); + } + else + { + tc = recursive_tc[0].type; + } } else { @@ -632,7 +643,7 @@ TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, case CORBA::tk_boolean: { CORBA::Boolean label; - if (!(cdr >> CORBA::Any::to_boolean (label))) + if (!(cdr >> CORBA::Any::to_boolean (label))) return false; typedef TypeCode::Case_T<CORBA::Boolean, @@ -665,10 +676,10 @@ TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, CORBA::ULongLong label; if (!(cdr >> label)) return false; - + typedef TypeCode::Case_T<CORBA::ULongLong, CORBA::String_var, - CORBA::TypeCode_var> case_type; + CORBA::TypeCode_var> case_type; ACE_NEW_RETURN (the_case, case_type (label), @@ -712,6 +723,7 @@ TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, size_t const len = recursive_tc.size (); + bool assigned_params = false; for (size_t i = 0; i < len; ++i) { TAO::TypeCodeFactory::TC_Info & info = recursive_tc[i]; @@ -722,14 +734,25 @@ TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, if (!rtc) return false; // Should never occur. - rtc->union_parameters (name.in (), - discriminant_type, - cases, // Will be copied. - ncases, - default_index); + assigned_params |= rtc->union_parameters (name.in (), + discriminant_type, + cases, // Will be copied. + ncases, + default_index); + } - tc = recursive_tc[0].type; + // If no parameters were assigned then the reference in the + // cases variable will be released when the variable is destroyed. + // Increment the reference count. + if ( !assigned_params) + { + tc = CORBA::TypeCode::_duplicate(recursive_tc[0].type); + } + else + { + tc = recursive_tc[0].type; + } } else { @@ -1050,6 +1073,7 @@ TAO::TypeCodeFactory::tc_value_factory (CORBA::TCKind kind, recursive_typecode_type; size_t const len = recursive_tc.size (); + bool assigned_params = false; for (size_t i = 0; i < len; ++i) { @@ -1061,13 +1085,23 @@ TAO::TypeCodeFactory::tc_value_factory (CORBA::TCKind kind, if (!rtc) return false; // Should never occur. - rtc->valuetype_parameters (name.in (), - type_modifier, - concrete_base, - fields, // Will be copied. - nfields); + assigned_params |= rtc->valuetype_parameters (name.in (), + type_modifier, + concrete_base, + fields, // Will be copied. + nfields); + } + // If no parameters were assigned then the reference in the + // fields variable will be released when the variable is destroyed. + // Increment the reference count. + if ( !assigned_params) + { + tc = CORBA::TypeCode::_duplicate(recursive_tc[0].type); + } + else + { + tc = recursive_tc[0].type; } - tc = recursive_tc[0].type; } else { |