summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-10-20 13:03:35 +0000
committermcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-10-20 13:03:35 +0000
commit23f86478b0c0362888eeda7e70204569e4e2ad68 (patch)
tree943f03f497e6df1b9ce82e460c9558fe59a9fe51
parentcb361d315f8831cd572a3c415c5b4e24ecdec23d (diff)
downloadATCD-23f86478b0c0362888eeda7e70204569e4e2ad68.tar.gz
Wed Oct 20 12:55:07 UTC 2010 Martin Corino <corino_m@remedy.nl>
* TAO_IDL/ast/ast_exception.cpp: * TAO_IDL/ast/ast_sequence.cpp: * TAO_IDL/ast/ast_structure.cpp: * TAO_IDL/ast/ast_type.cpp: * TAO_IDL/ast/ast_union.cpp: * TAO_IDL/ast/ast_valuetype.cpp: * TAO_IDL/be/be_visitor_typecode/struct_typecode.cpp: * TAO_IDL/be/be_visitor_typecode/union_typecode.cpp: * TAO_IDL/be/be_visitor_typecode/value_typecode.cpp: * TAO_IDL/include/ast_type.h: Fixed incorrect (unnecessary) generation of Recursive typecodes. * tao/AnyTypeCode/Recursive_Type_TypeCode.h: * tao/AnyTypeCode/Recursive_Type_TypeCode.inl: * tao/AnyTypeCode/Recursive_Type_TypeCode.cpp: * tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp: Fixed incorrect marshaling/demarshaling of Recursive typecodes (specifically nested recursions) as well as incorrect reference counting of recursive typecodes. These changes fix Bugzilla #2804 and 2844.
-rw-r--r--TAO/ChangeLog25
-rw-r--r--TAO/TAO_IDL/ast/ast_exception.cpp33
-rw-r--r--TAO/TAO_IDL/ast/ast_sequence.cpp28
-rw-r--r--TAO/TAO_IDL/ast/ast_structure.cpp35
-rw-r--r--TAO/TAO_IDL/ast/ast_type.cpp2
-rw-r--r--TAO/TAO_IDL/ast/ast_union.cpp37
-rw-r--r--TAO/TAO_IDL/ast/ast_valuetype.cpp75
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typecode/struct_typecode.cpp12
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp16
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typecode/value_typecode.cpp12
-rw-r--r--TAO/TAO_IDL/include/ast_type.h3
-rw-r--r--TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp29
-rw-r--r--TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h8
-rw-r--r--TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl8
-rw-r--r--TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp2
15 files changed, 217 insertions, 108 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index a7ed39754e7..fd1319c23c2 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,27 @@
+Wed Oct 20 13:02:07 UTC 2010 Martin Corino <corino_m@remedy.nl>
+
+ * TAO_IDL/ast/ast_exception.cpp:
+ * TAO_IDL/ast/ast_sequence.cpp:
+ * TAO_IDL/ast/ast_structure.cpp:
+ * TAO_IDL/ast/ast_type.cpp:
+ * TAO_IDL/ast/ast_union.cpp:
+ * TAO_IDL/ast/ast_valuetype.cpp:
+ * TAO_IDL/be/be_visitor_typecode/struct_typecode.cpp:
+ * TAO_IDL/be/be_visitor_typecode/union_typecode.cpp:
+ * TAO_IDL/be/be_visitor_typecode/value_typecode.cpp:
+ * TAO_IDL/include/ast_type.h:
+ Fixed incorrect (unnecessary) generation of Recursive typecodes.
+
+ * tao/AnyTypeCode/Recursive_Type_TypeCode.h:
+ * tao/AnyTypeCode/Recursive_Type_TypeCode.inl:
+ * tao/AnyTypeCode/Recursive_Type_TypeCode.cpp:
+ * tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp:
+ Fixed incorrect marshaling/demarshaling of Recursive typecodes
+ (specifically nested recursions) as well as incorrect reference
+ counting of recursive typecodes.
+
+ These changes fix Bugzilla #2804 and 2844.
+
Wed Oct 20 12:48:50 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl>
* bin/tao_orb_tests.lst:
@@ -33,6 +57,7 @@ Fri Oct 15 13:49:28 UTC 2010 Marcel Smit <msmit@remedy.nl>
* TAO_IDL/be/be_codegen.cpp:
Only include ORB_core.h when the reactor method is created.
+>>>>>>> .r92277
Fri Oct 15 07:37:52 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl>
* tao/LRU_Connection_Purging_Strategy.cpp:
diff --git a/TAO/TAO_IDL/ast/ast_exception.cpp b/TAO/TAO_IDL/ast/ast_exception.cpp
index 685b66273e7..f3598c77ed1 100644
--- a/TAO/TAO_IDL/ast/ast_exception.cpp
+++ b/TAO/TAO_IDL/ast/ast_exception.cpp
@@ -112,11 +112,30 @@ AST_Exception::~AST_Exception (void)
bool
AST_Exception::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
{
+ bool self_test = (list.size () == 0);
+
+ // We should calculate this only once. If it has already been
+ // done, just return it.
+ if (self_test && this->in_recursion_ != -1)
+ {
+ return (this->in_recursion_ == 1);
+ }
+
+ if (list.size () > 1)
+ {
+ if (match_names (this, list))
+ {
+ // this happens when we are not recursed ourselves but instead
+ // are part of another recursive type
+ return false;
+ }
+ }
+
+ list.enqueue_tail(this);
+
// Proceed if the number of members in our scope is greater than 0.
if (this->nmembers () > 0)
{
- list.enqueue_tail (this);
-
// Continue until each element is visited.
for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ())
{
@@ -148,16 +167,18 @@ AST_Exception::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
if (type->in_recursion (list))
{
- this->in_recursion_ = 1;
+ if (self_test)
+ this->in_recursion_ = 1;
idl_global->recursive_type_seen_ = true;
- return this->in_recursion_;
+ return true;
}
}
}
// Not in recursion.
- this->in_recursion_ = 0;
- return this->in_recursion_;
+ if (self_test)
+ this->in_recursion_ = 0;
+ return 0; //this->in_recursion_;
}
// Dump this AST_Exception node to the ostream o.
diff --git a/TAO/TAO_IDL/ast/ast_sequence.cpp b/TAO/TAO_IDL/ast/ast_sequence.cpp
index b908a542c39..f1f667e48d1 100644
--- a/TAO/TAO_IDL/ast/ast_sequence.cpp
+++ b/TAO/TAO_IDL/ast/ast_sequence.cpp
@@ -159,12 +159,10 @@ AST_Sequence::~AST_Sequence (void)
bool
AST_Sequence::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
{
- // We should calculate this only once. If it has already been
- // done, just return it.
- if (this->in_recursion_ != -1)
- {
- return this->in_recursion_;
- }
+ if (list.size () == 0) // only structs, unions and valuetypes can be recursive
+ return false;
+
+ list.enqueue_tail(this);
AST_Type *type = AST_Type::narrow_from_decl (this->base_type ());
AST_Decl::NodeType nt = type->node_type ();
@@ -193,25 +191,23 @@ AST_Sequence::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
return false;
}
- if (this->match_names (type, list))
+ bool recursion_found = false;
+ AST_Type** recursable_type = 0;
+ list.get (recursable_type, 0);
+ if (!ACE_OS::strcmp (type->full_name (),
+ (*recursable_type)->full_name ()))
{
// They match.
- this->in_recursion_ = 1;
+ recursion_found = true;
idl_global->recursive_type_seen_ = true;
}
else
{
// Check the element type.
- list.enqueue_tail (type);
- this->in_recursion_ = type->in_recursion (list);
-
- if (this->in_recursion_ == 1)
- {
- idl_global->recursive_type_seen_ = true;
- }
+ recursion_found = type->in_recursion (list);
}
- return this->in_recursion_;
+ return recursion_found;
}
// Redefinition of inherited virtual operations.
diff --git a/TAO/TAO_IDL/ast/ast_structure.cpp b/TAO/TAO_IDL/ast/ast_structure.cpp
index 2ebd955d41d..f62ed5c32a3 100644
--- a/TAO/TAO_IDL/ast/ast_structure.cpp
+++ b/TAO/TAO_IDL/ast/ast_structure.cpp
@@ -125,19 +125,32 @@ AST_Structure::~AST_Structure (void)
bool
AST_Structure::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
{
+ bool self_test = (list.size () == 0);
+
// We should calculate this only once. If it has already been
// done, just return it.
- if (this->in_recursion_ != -1)
+ if (self_test && this->in_recursion_ != -1)
{
- return this->in_recursion_;
+ return (this->in_recursion_ == 1);
}
+ if (list.size () > 1)
+ {
+ if (match_names (this, list))
+ {
+ // We've found ourselves outside of a sequence.
+ // This happens when we are not recursed ourselves but instead
+ // are part of another recursed type which is part of us.
+ // f.i. union containing sequence of struct containing the union as member.
+ return false;
+ }
+ }
+
+ list.enqueue_tail(this);
+
// Proceed if the number of members in our scope is greater than 0.
if (this->nmembers () > 0)
{
- ACE_Unbounded_Queue<AST_Type *> scope_list = list;
- scope_list.enqueue_tail (this);
-
// Initialize an iterator to iterate over our scope.
// Continue until each element is visited.
for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
@@ -170,18 +183,20 @@ AST_Structure::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
0);
}
- if (type->in_recursion (scope_list))
+ if (type->in_recursion (list))
{
- this->in_recursion_ = 1;
+ if (self_test)
+ this->in_recursion_ = 1;
idl_global->recursive_type_seen_ = true;
- return this->in_recursion_;
+ return true;
}
}
}
// Not in recursion.
- this->in_recursion_ = 0;
- return this->in_recursion_;
+ if (self_test)
+ this->in_recursion_ = 0;
+ return false;
}
int
diff --git a/TAO/TAO_IDL/ast/ast_type.cpp b/TAO/TAO_IDL/ast/ast_type.cpp
index 6699aa78107..04d90152816 100644
--- a/TAO/TAO_IDL/ast/ast_type.cpp
+++ b/TAO/TAO_IDL/ast/ast_type.cpp
@@ -138,7 +138,7 @@ AST_Type::compute_size_type (void)
}
bool
-AST_Type::in_recursion (ACE_Unbounded_Queue<AST_Type *> &)
+AST_Type::in_recursion (ACE_Unbounded_Queue<AST_Type *> & /*list*/)
{
// By default we are not involved in recursion.
return 0;
diff --git a/TAO/TAO_IDL/ast/ast_union.cpp b/TAO/TAO_IDL/ast/ast_union.cpp
index 43b0de85503..48eaee7214e 100644
--- a/TAO/TAO_IDL/ast/ast_union.cpp
+++ b/TAO/TAO_IDL/ast/ast_union.cpp
@@ -235,12 +235,31 @@ AST_Union::default_index (void)
bool
AST_Union::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
{
+ bool self_test = (list.size () == 0);
+
+ // We should calculate this only once. If it has already been
+ // done, just return it.
+ if (self_test && this->in_recursion_ != -1)
+ {
+ return (this->in_recursion_ == 1);
+ }
+
+ if (list.size () > 1)
+ {
+ if (match_names (this, list))
+ {
+ // We've found ourselves outside of a sequence.
+ // This happens when we are not recursed ourselves but instead
+ // are part of another recursive type
+ return false;
+ }
+ }
+
+ list.enqueue_tail(this);
+
// Proceed if the number of members in our scope is greater than 0.
if (this->nmembers () > 0)
{
- ACE_Unbounded_Queue<AST_Type *> scope_list = list;
- scope_list.enqueue_tail (this);
-
// Initialize an iterator to iterate thru our scope.
// Continue until each element is visited.
for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
@@ -274,18 +293,20 @@ AST_Union::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
0);
}
- if (type->in_recursion (scope_list))
+ if (type->in_recursion (list))
{
- this->in_recursion_ = 1;
+ if (self_test)
+ this->in_recursion_ = 1;
idl_global->recursive_type_seen_ = true;
- return this->in_recursion_;
+ return true;
}
}
}
// Not in recursion.
- this->in_recursion_ = 0;
- return this->in_recursion_;
+ if (self_test)
+ this->in_recursion_ = 0;
+ return 0;
}
// Look up the default branch in union.
diff --git a/TAO/TAO_IDL/ast/ast_valuetype.cpp b/TAO/TAO_IDL/ast/ast_valuetype.cpp
index cecbf76def0..246eac472c8 100644
--- a/TAO/TAO_IDL/ast/ast_valuetype.cpp
+++ b/TAO/TAO_IDL/ast/ast_valuetype.cpp
@@ -82,14 +82,50 @@ AST_ValueType::~AST_ValueType (void)
bool
AST_ValueType::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
{
+ bool self_test = (list.size () == 0);
+
// We should calculate this only once. If it has already been
// done, just return it.
- if (this->in_recursion_ != -1)
+ if (self_test && this->in_recursion_ != -1)
{
- return this->in_recursion_;
+ return (this->in_recursion_ == 1);
+ }
+
+ if (list.size ())
+ {
+ if (match_names (this, list))
+ {
+ // A valuetype may contain itself as a member (nesting == 1)
+ // which is not a problem., but we could also match ourselves when
+ // we are not recursed ourselves but instead are part of another
+ // recursive type.
+ if (list.size () == 1)
+ {
+ idl_global->recursive_type_seen_ = true;
+ return true;
+ }
+ else
+ {
+ // get the head element which is the type being tested
+ AST_Type** recursable_type = 0;
+ list.get (recursable_type, 0);
+ // Check if we are the possibly recursive type being tested
+ if (!ACE_OS::strcmp (this->full_name (),
+ (*recursable_type)->full_name ()))
+ {
+ // match, so we're recursive
+ idl_global->recursive_type_seen_ = true;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
}
+ }
- list.enqueue_tail (this);
+ list.enqueue_tail(this);
for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
!si.is_done ();
@@ -114,19 +150,6 @@ AST_ValueType::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
AST_Type *type = field->field_type ();
- // A valuetype may contain itself as a member. This will not
- // cause a problem when checking if the valuetype itself is
- // recursive, but if another valuetype contains a recursive
- // one, the string compare below is not sufficient, and we
- // will go into an infinite recursion of calls to in_recursion ;-).
- // The check below will catch that use case.
- if (this == type)
- {
- this->in_recursion_ = 1;
- idl_global->recursive_type_seen_ = true;
- return this->in_recursion_;
- }
-
if (type == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
@@ -135,15 +158,6 @@ AST_ValueType::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
0);
}
- // IDL doesn't have such a feature as name reuse so
- // just compare fully qualified names.
- if (this->match_names (this, list))
- {
- this->in_recursion_ = 1;
- idl_global->recursive_type_seen_ = true;
- return this->in_recursion_;
- }
-
if (type->node_type () == AST_Decl::NT_typedef)
{
AST_Typedef *td = AST_Typedef::narrow_from_decl (type);
@@ -153,15 +167,18 @@ AST_ValueType::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
// Now hand over to our field type.
if (type->in_recursion (list))
{
- this->in_recursion_ = 1;
+ if (self_test)
+ this->in_recursion_ = 1;
idl_global->recursive_type_seen_ = true;
- return this->in_recursion_;
+ return true;
}
} // end of for loop
- this->in_recursion_ = 0;
- return this->in_recursion_;
+ // Not in recursion.
+ if (self_test)
+ this->in_recursion_ = 0;
+ return false;
}
void
diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/struct_typecode.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/struct_typecode.cpp
index b8689ce4871..b0451d59c3a 100644
--- a/TAO/TAO_IDL/be/be_visitor_typecode/struct_typecode.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_typecode/struct_typecode.cpp
@@ -33,11 +33,10 @@ TAO::be_visitor_struct_typecode::visit_structure (be_structure * node)
this->queue_lookup (this->tc_queue_, node);
ACE_Unbounded_Queue<AST_Type *> recursion_queue;
-
- if (qnode
- && node->in_recursion (recursion_queue))
+ this->is_recursive_ = node->in_recursion (recursion_queue);
+ if (qnode && this->is_recursive_)
{
- this->is_recursive_ = true;
+ // we're repeated and we're recursive so just leave
return 0;
}
else if (this->queue_insert (this->tc_queue_, node, 0) == 0)
@@ -189,6 +188,9 @@ TAO::be_visitor_struct_typecode::gen_member_typecodes (AST_Structure * node)
return -1;
}
+/* MCO@20101020 - this is unnecessary since the check for recursiveness
+ * of *this* typecode has already been done before calling this method
+
be_structure *bs = be_structure::narrow_from_decl (node);
if (bs)
{
@@ -196,12 +198,14 @@ TAO::be_visitor_struct_typecode::gen_member_typecodes (AST_Structure * node)
this->queue_lookup (this->tc_queue_, bs);
ACE_Unbounded_Queue<AST_Type *> recursion_queue;
+ recursion_queue.enqueue_tail(node);
if (qnode
&& member_type->in_recursion (recursion_queue))
{
this->is_recursive_ = true;
}
}
+*/
}
return 0;
diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp
index 09119469d31..f30d341f948 100644
--- a/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp
@@ -34,12 +34,10 @@ TAO::be_visitor_union_typecode::visit_union (be_union * node)
this->queue_lookup (this->tc_queue_, node);
ACE_Unbounded_Queue<AST_Type *> recursion_queue;
-
- if (qnode
- && node->in_recursion (recursion_queue))
+ this->is_recursive_ = node->in_recursion (recursion_queue);
+ if (qnode && this->is_recursive_)
{
- this->is_recursive_ = true;
-
+ // we're repeated and we're recursive so just leave
return 0;
}
else if (this->queue_insert (this->tc_queue_, node, 0) == 0)
@@ -148,15 +146,21 @@ TAO::be_visitor_union_typecode::gen_case_typecodes (be_union * node)
return -1;
}
+/* MCO@20101020 - this is unnecessary since the check for recursiveness
+ * of *this* typecode has already been done before calling this method
+
be_visitor_typecode_defn::QNode const * const qnode =
this->queue_lookup (this->tc_queue_, node);
ACE_Unbounded_Queue<AST_Type *> recursion_queue;
+ recursion_queue.enqueue_tail (node);
if (qnode
- && member_type->in_recursion (recursion_queue))
+ &&
+ member_type->in_recursion (recursion_queue))
{
this->is_recursive_ = true;
}
+*/
}
return 0;
diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/value_typecode.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/value_typecode.cpp
index a8e6cebdbe2..3c3d923514d 100644
--- a/TAO/TAO_IDL/be/be_visitor_typecode/value_typecode.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_typecode/value_typecode.cpp
@@ -33,11 +33,10 @@ TAO::be_visitor_value_typecode::visit_valuetype (be_valuetype * node)
this->queue_lookup (this->tc_queue_, node);
ACE_Unbounded_Queue<AST_Type *> recursion_queue;
- if (qnode
- && node->in_recursion (recursion_queue))
+ this->is_recursive_ = node->in_recursion (recursion_queue);
+ if (qnode && this->is_recursive_)
{
- this->is_recursive_ = true;
-
+ // we're repeated and we're recursive so just leave
return 0;
}
else if (this->queue_insert (this->tc_queue_, node, 0) == 0)
@@ -211,15 +210,20 @@ TAO::be_visitor_value_typecode::gen_member_typecodes (be_valuetype * node)
return -1;
}
+/* MCO@20101020 - this is unnecessary since the check for recursiveness
+ * of *this* typecode has already been done before calling this method
+
be_visitor_typecode_defn::QNode const * const qnode =
this->queue_lookup (this->tc_queue_, node);
ACE_Unbounded_Queue<AST_Type *> recursion_queue;
+ recursion_queue.enqueue_tail (node);
if (qnode
&& member_type->in_recursion (recursion_queue))
{
this->is_recursive_ = true;
}
+*/
}
return 0;
diff --git a/TAO/TAO_IDL/include/ast_type.h b/TAO/TAO_IDL/include/ast_type.h
index 1e77d023486..e4071cf9e49 100644
--- a/TAO/TAO_IDL/include/ast_type.h
+++ b/TAO/TAO_IDL/include/ast_type.h
@@ -96,7 +96,8 @@ public:
virtual bool in_recursion (ACE_Unbounded_Queue<AST_Type *> &list);
// Determine if we are involved in some kind of limited recursion.
// Most types cannot be involved except structs and unions.
- // If the parameter is 0, we are trying to determine this for ourselves.
+ // The head element of the list the possibly recursed type we are checking for.
+ // If the list is empty, we are trying to determine this for ourselves.
virtual void size_type (SIZE_TYPE);
// Set the size type.
diff --git a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp
index d7df0270792..01e56ce2e40 100644
--- a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp
+++ b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp
@@ -22,24 +22,21 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase,
false);
// Top-level TypeCode case.
- if (!(this->in_recursion_))
+ if (this->recursion_start_offset_ == 0)
{
- this->in_recursion_ = true;
-
// Starting offset should point to the CORBA::TCKind value.
-
// Note that this doesn't need to take into account alignment
// padding since CORBA::TCKind (encoded as a CORBA::ULong) is
// already aligned on the appropriate boundary, and since the
// CORBA::TCKind was the last thing marshaled into the CDR
// stream before getting here.
- offset = sizeof (CORBA::ULong);
+ this->recursion_start_offset_ = offset - sizeof (CORBA::ULong);
// Reset recursion flag to false in an exception-safe manner once
// marshaling is done.
//
// Only reset the recursion flag at the top-level.
- Reset flag (this->in_recursion_);
+ Reset flag (this->recursion_start_offset_);
return this->TypeCodeBase::tao_marshal (cdr, offset);
}
@@ -49,7 +46,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase,
// ACE_ASSERT (offset > 4
// && offset < static_cast<CORBA::ULong> (ACE_INT32_MAX));
- return (cdr << -static_cast<CORBA::Long> (offset));
+ return (cdr << -static_cast<CORBA::Long> (offset - this->recursion_start_offset_));
}
template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType>
@@ -65,15 +62,17 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase,
false);
// Top-level TypeCode case.
- if (!(this->in_recursion_))
+ if (this->recursion_start_offset_ == 0)
{
- this->in_recursion_ = true;
+ // no need for real start offset here
+ // just set to non-zero to flag recursion
+ this->recursion_start_offset_ = 1;
// Reset recursion flag to false in an exception-safe manner once
// equality determination is done.
//
// Only reset the recursion flag at the top-level.
- Reset flag (this->in_recursion_);
+ Reset flag (this->recursion_start_offset_);
return this->TypeCodeBase::equal_i (tc);
}
@@ -95,15 +94,17 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase,
false);
// Top-level TypeCode case.
- if (!(this->in_recursion_))
+ if (this->recursion_start_offset_ == 0)
{
- this->in_recursion_ = true;
+ // no need for real start offset here
+ // just set to non-zero to flag recursion
+ this->recursion_start_offset_ = 1;
// Reset recursion flag to false in an exception-safe manner once
// equivalence determination is done.
//
// Only reset the recursion flag at the top-level.
- Reset flag (this->in_recursion_);
+ Reset flag (this->recursion_start_offset_);
return this->TypeCodeBase::equivalent_i (tc);
}
@@ -125,7 +126,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase,
false);
// Top-level TypeCode case.
- if (!(this->in_recursion_))
+ if (this->recursion_start_offset_ == 0)
return this->::CORBA::TypeCode::tao_marshal_kind (cdr);
// Recursive/indirected TypeCode case.
diff --git a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h
index f9ebdfab5ff..f09954a6344 100644
--- a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h
+++ b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h
@@ -146,10 +146,10 @@ namespace TAO
class Reset
{
public:
- Reset (bool & flag) : flag_ (flag) { }
- ~Reset (void) { this->flag_ = false; }
+ Reset (CORBA::ULong & flag) : flag_ (flag) { }
+ ~Reset (void) { this->flag_ = 0; }
private:
- bool & flag_;
+ CORBA::ULong & flag_;
};
private:
@@ -163,7 +163,7 @@ namespace TAO
* This flag is used to prevent @c TypeCode equality and
* equivalence operations from recursing indefinitely.
*/
- mutable bool in_recursion_;
+ mutable CORBA::ULong recursion_start_offset_;
/// Track whether data has been initialized.
bool data_initialized_;
diff --git a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl
index 8c285e02ce8..fa836bb9319 100644
--- a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl
+++ b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl
@@ -16,7 +16,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase,
CORBA::ULong nfields)
: TypeCodeBase (kind, id, name, fields, nfields)
, lock_ ()
- , in_recursion_ (false)
+ , recursion_start_offset_ (0)
, data_initialized_(true)
{
// ACE_ASSERT (kind != CORBA::tk_except);
@@ -40,7 +40,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase,
ncases,
default_index)
, lock_ ()
- , in_recursion_ (false)
+ , recursion_start_offset_ (0)
, data_initialized_(true)
{
}
@@ -65,7 +65,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase,
fields,
nfields)
, lock_ ()
- , in_recursion_ (false)
+ , recursion_start_offset_ (0)
, data_initialized_(true)
{
}
@@ -79,7 +79,7 @@ TAO::TypeCode::Recursive_Type<TypeCodeBase,
char const * id)
: TypeCodeBase (kind, id)
, lock_ ()
- , in_recursion_ (false)
+ , recursion_start_offset_ (0)
, data_initialized_(false)
{
// ACE_ASSERT (kind == CORBA::tk_struct
diff --git a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp
index 69f4546b40d..af5b611128c 100644
--- a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp
+++ b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp
@@ -1361,7 +1361,7 @@ namespace
TAO::TypeCodeFactory::TC_Info_List recursive_tc;
if (find_recursive_tc (id.in (), recursive_tc, infos))
{
- tc = recursive_tc[0].type;
+ tc = CORBA::TypeCode::_duplicate(recursive_tc[0].type);
}
else switch (kind)
{