summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2001-07-15 14:45:34 +0000
committerbala <balanatarajan@users.noreply.github.com>2001-07-15 14:45:34 +0000
commitfd367909e43e09651db218167b5c1a122c16c035 (patch)
tree3c69134e2c1d012fe75aae90922db2fa8d21e5b5
parent56df453d26f0041374d2b9046cfb0ebcc150c6ea (diff)
downloadATCD-fd367909e43e09651db218167b5c1a122c16c035.tar.gz
ChangeLogTag:Sun Jul 15 9:33:34 2001 Balachandran Natarajan <bala@cs.wustl.edu>
-rw-r--r--TAO/ChangeLogs/ChangeLog-02a23
-rw-r--r--TAO/orbsvcs/orbsvcs/Event/EC_Gateway_UDP.cpp7
-rw-r--r--TAO/tao/Sequence.cpp26
-rw-r--r--TAO/tao/Sequence.i24
4 files changed, 76 insertions, 4 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a
index 84e5a306f94..3282eda1f56 100644
--- a/TAO/ChangeLogs/ChangeLog-02a
+++ b/TAO/ChangeLogs/ChangeLog-02a
@@ -1,7 +1,28 @@
+Sun Jul 15 9:33:34 2001 Balachandran Natarajan <bala@cs.wustl.edu>
+
+ * tao/Sequence.cpp:
+ * tao/Sequence.i: A fix at the places where
+ ACE_Message_Block::duplicate () is called. The duplicate ()
+ call just allocated memory for a new Message block and then
+ duplicated the exisiting data block -- which just increments the
+ reference count of the data block. This could be bad for cases
+ where the incoming message is on a data block on stack. By
+ incrementing the reference count we get nothing for such
+ cases. The fix that has been put in does the following
+
+ - checks whether the data block is on stack, if so does a deep
+ copy before calling duplicate on the message block.
+ - if the data block is already on the heap just calls duplicate
+ () on the message block.
+
+ * orbsvcs/orbsvcs/Event/EC_Gateway_UDP.cpp: Added a comment where
+ duplicate () is used. But the code that uses duplicate () has
+ been commented out .
+
Sat Jul 14 20:18:36 2001 Balachandran Natarajan <bala@cs.wustl.edu>
* docs/tutorials/Quoter/Event_Service/Makefile: Updated
- dependencies.
+ dependencies.
Sat Jul 14 18:59:48 2001 Balachandran Natarajan <bala@cs.wustl.edu>
diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_Gateway_UDP.cpp b/TAO/orbsvcs/orbsvcs/Event/EC_Gateway_UDP.cpp
index f18ccc36d93..9c740466376 100644
--- a/TAO/orbsvcs/orbsvcs/Event/EC_Gateway_UDP.cpp
+++ b/TAO/orbsvcs/orbsvcs/Event/EC_Gateway_UDP.cpp
@@ -493,6 +493,13 @@ TAO_ECG_UDP_Request_Entry::TAO_ECG_UDP_Request_Entry (void)
{
}
+// @@ todo:This code is commented out. So no problem. But when this
+// code is enabled we need to make sure that
+// ACE_Message_Block::duplicate () should be called only if the data
+// block in it is NOT from stack. Else we need to copy the datablock
+// and then duplicate () it. See $TAO_ROOT/tao/Sequence.{cpp,i} on how
+// this is done.
+
TAO_ECG_UDP_Request_Entry::
TAO_ECG_UDP_Request_Entry (const TAO_ECG_UDP_Request_Entry& rhs)
: byte_order_ (rhs.byte_order_),
diff --git a/TAO/tao/Sequence.cpp b/TAO/tao/Sequence.cpp
index 7f6ba1d9432..2e3fa9689d2 100644
--- a/TAO/tao/Sequence.cpp
+++ b/TAO/tao/Sequence.cpp
@@ -654,8 +654,30 @@ TAO_Unbounded_Sequence (CORBA::ULong length,
length,
mb->rd_ptr (),
0)
- , mb_ (ACE_Message_Block::duplicate (mb))
-{
+ , mb_ (0)
+{
+ // Get the message block flags.
+ ACE_Message_Block::Message_Flags flg = mb->flags ();
+
+ // If the DONT_DELETE flag is disabled just a duplicate would
+ // help. If the DONT_DELETE flag is enabled a deep copy is needed as
+ // the contents would be on stack. Just incrementing the ref count
+ // on the stack based data block would only crash the program when
+ // the stack unwinds
+ if (ACE_BIT_DISABLED (flg,
+ ACE_Message_Block::DONT_DELETE))
+ {
+ this->mb_ = ACE_Message_Block::duplicate (mb);
+ }
+ else
+ {
+ // As we are in CORBA mode, all the data blocks would be aligned
+ // on an 8 byte boundary
+ ACE_Message_Block msgb (*mb,
+ ACE_CDR::MAX_ALIGNMENT);
+
+ this->mb_ = ACE_Message_Block::duplicate (&msgb);
+ }
}
#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */
diff --git a/TAO/tao/Sequence.i b/TAO/tao/Sequence.i
index bd1078e1deb..39d6f3f1a76 100644
--- a/TAO/tao/Sequence.i
+++ b/TAO/tao/Sequence.i
@@ -354,7 +354,29 @@ TAO_Unbounded_Sequence<CORBA::Octet>::replace (CORBA::ULong length,
const ACE_Message_Block* mb)
{
this->_deallocate_buffer ();
- this->mb_ = ACE_Message_Block::duplicate (mb);
+
+ // Get the message block flags.
+ ACE_Message_Block::Message_Flags flg = mb->flags ();
+
+ // If the DONT_DELETE flag is disabled just a duplicate would
+ // help. If the DONT_DELETE flag is enabled a deep copy is needed as
+ // the contents would be on stack. Just incrementing the ref count
+ // on the stack based data block would only crash the program when
+ // the stack unwinds
+ if (ACE_BIT_DISABLED (flg,
+ ACE_Message_Block::DONT_DELETE))
+ {
+ this->mb_ = ACE_Message_Block::duplicate (mb);
+ }
+ else
+ {
+ // As we are in CORBA mode, all the data blocks would be aligned
+ // on an 8 byte boundary
+ ACE_Message_Block msgb (*mb,
+ ACE_CDR::MAX_ALIGNMENT);
+
+ this->mb_ = ACE_Message_Block::duplicate (&msgb);
+ }
this->buffer_ = this->mb_->rd_ptr ();
this->maximum_ = length;
this->length_ = length;