From 12ea449365d25f2be70fc2559126f0ac06d5ff74 Mon Sep 17 00:00:00 2001 From: bala Date: Tue, 16 Apr 2002 03:24:20 +0000 Subject: ChangeLogTag: Mon Apr 15 22:19:31 2002 Balachandran Natarajan --- TAO/ChangeLogs/ChangeLog-02a | 15 +++++++++++++++ TAO/tao/Incoming_Message_Queue.cpp | 26 ++++++++++++++++++++++++++ TAO/tao/Incoming_Message_Queue.h | 5 +++++ TAO/tao/Incoming_Message_Queue.inl | 18 ++++++++++++++++-- 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index bdd7d368f7c..c1f7aa6787f 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,18 @@ +Mon Apr 15 22:19:31 2002 Balachandran Natarajan + + * tao/Incoming_Message_Queue.h: + * tao/Incoming_Message_Queue.cpp: + * tao/Incoming_Message_Queue.inl: Added a check in + TAO_Queued_Data::duplicate () to see if the incoming data block + was off the stack or heap. If the data_block is off the stack, + we carefully clone the datablock and then created a new + TAO_Queued_Data pointer. This problem showed up along one of the + code paths handling fragmented messages. Once we have the new + design implemented these problem shouldnt show up. + + Thanks to Andy Guy for reporting this + problem. + Mon Apr 15 16:58:40 2002 Ossama Othman * orbsvcs/orbsvcs/Naming/Naming_Utils.cpp (init_new_naming): diff --git a/TAO/tao/Incoming_Message_Queue.cpp b/TAO/tao/Incoming_Message_Queue.cpp index 737e329ea7b..4f825485ba2 100644 --- a/TAO/tao/Incoming_Message_Queue.cpp +++ b/TAO/tao/Incoming_Message_Queue.cpp @@ -163,3 +163,29 @@ TAO_Queued_Data::TAO_Queued_Data (const TAO_Queued_Data &qd) next_ (0) { } + + +/*static*/ void +TAO_Queued_Data::replace_data_block (ACE_Message_Block &mb) +{ + size_t newsize = + ACE_CDR::total_length (&mb, 0) + ACE_CDR::MAX_ALIGNMENT; + + ACE_Data_Block *db = + mb.data_block ()->clone_nocopy (); + + if (db->size (newsize) == -1) + return; + + ACE_Message_Block tmp (db); + ACE_CDR::mb_align (&tmp); + + tmp.copy (mb.rd_ptr (), mb.length()); + mb.data_block (tmp.data_block ()->duplicate ()); + + mb.rd_ptr (tmp.rd_ptr ()); + mb.wr_ptr (tmp.wr_ptr ()); + + // Remove the DONT_DELETE flags from mb + mb.clr_self_flags (ACE_Message_Block::DONT_DELETE); +} diff --git a/TAO/tao/Incoming_Message_Queue.h b/TAO/tao/Incoming_Message_Queue.h index 6037ca825af..4a4d6109608 100644 --- a/TAO/tao/Incoming_Message_Queue.h +++ b/TAO/tao/Incoming_Message_Queue.h @@ -166,6 +166,11 @@ public: /// Pounter to the next element in the queue. TAO_Queued_Data *next_; + +private: + /// Replace the datablock with a one allocated on the heap or + /// allocator + static void replace_data_block (ACE_Message_Block &mb); }; diff --git a/TAO/tao/Incoming_Message_Queue.inl b/TAO/tao/Incoming_Message_Queue.inl index 3f82216bed8..a1e68a9386f 100644 --- a/TAO/tao/Incoming_Message_Queue.inl +++ b/TAO/tao/Incoming_Message_Queue.inl @@ -26,11 +26,25 @@ TAO_Queued_Data::release (TAO_Queued_Data *qd) delete qd; } -/*static*/ + ACE_INLINE TAO_Queued_Data * TAO_Queued_Data::duplicate (TAO_Queued_Data &sqd) { - // @@TODO: Use the global pool for allocationg... + // Check to see if the underlying block is on the stack. If not it + // is fine. If the datablock is on stack, try to make a copy of that + // befor doing a duplicate. + // @@ todo: Theoretically this should be within the Message Block, + // but we dont have much scope to do this in that mess. Probably in + // the next stage of MB rewrite we should be okay + ACE_Message_Block::Message_Flags fl = + sqd.msg_block_->self_flags (); + + if (ACE_BIT_ENABLED (fl, + ACE_Message_Block::DONT_DELETE)) + (void) TAO_Queued_Data::replace_data_block (*sqd.msg_block_); + + + // @@TODO: Use the pool for allocation... TAO_Queued_Data *qd = 0; ACE_NEW_RETURN (qd, TAO_Queued_Data (sqd), -- cgit v1.2.1