Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ACE_RMCast_Reassembly Class Reference

Reassemble multiple data fragments into a single data message. More...

#include <RMCast_Reassembly.h>

Inheritance diagram for ACE_RMCast_Reassembly:

Inheritance graph
[legend]
Collaboration diagram for ACE_RMCast_Reassembly:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_RMCast_Reassembly (void)
 Constructor. More...

virtual ~ACE_RMCast_Reassembly (void)
 Destructor. More...

virtual int close (void)
virtual int data (ACE_RMCast::Data &data)
 Push data through the stack. More...


Private Types

typedef ACE_Hash_Map_Manager<
ACE_UINT32, ACE_RMCast_Partial_Message *,
ACE_Null_Mutex
Message_Map
typedef ACE_Hash_Map_Iterator<
ACE_UINT32, ACE_RMCast_Partial_Message *,
ACE_Null_Mutex
Message_Map_Iterator

Private Methods

void close_i (void)
 Cleanup resources, but do not close the other modules in the stack. More...


Private Attributes

ACE_SYNCH_MUTEX mutex_
 A mutex used to synchronize all the internal operations. More...

Message_Map messages_
 A map, indexed by sequence number, of the partially received messages. More...


Detailed Description

Reassemble multiple data fragments into a single data message.

Data messages may not fit in a single MTU in the transport layer, in that case the application configure a RMCast_Fragment module on the sender side. On the receiver side this layer reassemble the messages sent from a single source, and passes the messages up the stream.

Definition at line 35 of file RMCast_Reassembly.h.


Member Typedef Documentation

typedef ACE_Hash_Map_Manager<ACE_UINT32,ACE_RMCast_Partial_Message*,ACE_Null_Mutex> ACE_RMCast_Reassembly::Message_Map [private]
 

Definition at line 58 of file RMCast_Reassembly.h.

typedef ACE_Hash_Map_Iterator<ACE_UINT32,ACE_RMCast_Partial_Message*,ACE_Null_Mutex> ACE_RMCast_Reassembly::Message_Map_Iterator [private]
 

Definition at line 61 of file RMCast_Reassembly.h.


Constructor & Destructor Documentation

ACE_RMCast_Reassembly::ACE_RMCast_Reassembly void   
 

Constructor.

Definition at line 18 of file RMCast_Reassembly.cpp.

00019   :  ACE_RMCast_Module ()
00020 {
00021 }

ACE_RMCast_Reassembly::~ACE_RMCast_Reassembly void    [virtual]
 

Destructor.

Definition at line 23 of file RMCast_Reassembly.cpp.

References close_i.

00024 {
00025   (void) this->close_i ();
00026 }


Member Function Documentation

int ACE_RMCast_Reassembly::close void    [virtual]
 

We cleanup the resources in the destructor

Reimplemented from ACE_RMCast_Module.

Definition at line 33 of file RMCast_Reassembly.cpp.

References ACE_RMCast_Module::close, and close_i.

00034 {
00035   this->close_i ();
00036   return this->ACE_RMCast_Module::close ();
00037 }

void ACE_RMCast_Reassembly::close_i void    [private]
 

Cleanup resources, but do not close the other modules in the stack.

Definition at line 117 of file RMCast_Reassembly.cpp.

References messages_.

Referenced by close, and ~ACE_RMCast_Reassembly.

00118 {
00119   for (Message_Map_Iterator i = this->messages_.begin ();
00120        i != this->messages_.end ();
00121        ++i)
00122     {
00123       ACE_RMCast_Partial_Message *message = (*i).int_id_;
00124       if (message != 0)
00125         delete message;
00126     }
00127   this->messages_.unbind_all ();
00128 }

int ACE_RMCast_Reassembly::data ACE_RMCast::Data   data [virtual]
 

Push data through the stack.

Reimplemented from ACE_RMCast_Module.

Definition at line 40 of file RMCast_Reassembly.cpp.

References ACE_ERROR, ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_SYNCH_MUTEX, ACE_RMCast_Module::data, ACE_RMCast::Data::fragment_offset, ACE_RMCast_Partial_Message::fragment_received, ACE_RMCast_Partial_Message::is_complete, ACE_Message_Block::length, LM_ERROR, ACE_RMCast_Partial_Message::message_body, messages_, ACE_RMCast_Module::next, ACE_RMCast::Data::payload, ACE_RMCast::Data::sequence_number, ACE_RMCast::Data::source, and ACE_RMCast::Data::total_size.

00041 {
00042   if (this->next () == 0)
00043     return 0;
00044 
00045   // ACE_DEBUG ((LM_DEBUG,
00046   //             "Reassembly::data - %d,%d,%d\n",
00047   //             data.sequence_number,
00048   //             data.total_size,
00049   //             data.fragment_offset));
00050 
00051   if (data.payload->length () + data.fragment_offset > data.total_size)
00052     {
00053       ACE_ERROR ((LM_ERROR,
00054                   "RMCast_Reassembly::data - invalid size\n"));
00055       return -1; // Corrupt message?
00056     }
00057 
00058   ACE_RMCast_Partial_Message *message;
00059 
00060   {
00061     ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1);
00062     if (this->messages_.find (data.sequence_number, message) == -1)
00063       {
00064         ACE_NEW_RETURN (message,
00065                         ACE_RMCast_Partial_Message (data.total_size),
00066                         -1);
00067 
00068         // ACE_DEBUG ((LM_DEBUG,
00069         //             "Reassembly::data - new message\n"));
00070         if (this->messages_.bind (data.sequence_number,
00071                                   message) == -1)
00072           return -1; // Internal error?
00073       }
00074 
00075     if (message->fragment_received (data.total_size,
00076                                     data.fragment_offset,
00077                                     data.payload) == -1)
00078       {
00079         // ACE_DEBUG ((LM_DEBUG,
00080         //             "Error in fragment_received\n"));
00081         return -1;
00082       }
00083 
00084     if (!message->is_complete ())
00085       {
00086         // ACE_DEBUG ((LM_DEBUG,
00087         //             "Reassembly::data - message still incomplete\n"));
00088         return 0;
00089       }
00090 
00091     if (this->messages_.unbind (data.sequence_number) == -1)
00092       {
00093         // ACE_DEBUG ((LM_DEBUG,
00094         //            "Reassembly::data - message now complete\n"));
00095         return -1;
00096       }
00097   }
00098 
00099   // Push the message...
00100   ACE_RMCast::Data downstream_data;
00101   downstream_data.source = data.source;
00102   downstream_data.sequence_number = data.sequence_number;
00103   downstream_data.total_size = ACE_static_cast(
00104                                     ACE_UINT32,
00105                                     message->message_body ()->length ());
00106   downstream_data.fragment_offset = 0;
00107   downstream_data.payload = message->message_body ();
00108 
00109   int r = this->next ()->data (downstream_data);
00110 
00111   delete message;
00112 
00113   return r;
00114 }


Member Data Documentation

Message_Map ACE_RMCast_Reassembly::messages_ [private]
 

A map, indexed by sequence number, of the partially received messages.

Definition at line 65 of file RMCast_Reassembly.h.

Referenced by close_i, and data.

ACE_SYNCH_MUTEX ACE_RMCast_Reassembly::mutex_ [private]
 

A mutex used to synchronize all the internal operations.

Definition at line 55 of file RMCast_Reassembly.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 13:14:10 2003 for ACE_RMCast by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002