#include <Reassemble.h>
Inheritance diagram for ACE_RMCast::Reassemble:
Public Member Functions | |
Reassemble (Parameters const ¶ms) | |
virtual void | recv (Message_ptr m) |
Private Types | |
typedef ACE_Hash_Map_Manager_Ex< Address, Data_ptr, AddressHasher, ACE_Equal_To< Address >, ACE_Null_Mutex > | Map |
Private Attributes | |
Parameters const & | params_ |
Map | map_ |
|
Definition at line 35 of file Reassemble.h. |
|
Definition at line 17 of file Reassemble.cpp.
00018 : params_ (params) 00019 { 00020 } |
|
Reimplemented from ACE_RMCast::In_Element. Definition at line 23 of file Reassemble.cpp. References ACE_OS::abort(), ACE_RMCast::Address, ACE_RMCast::Data::buf(), ACE_RMCast::Data_ptr, ACE_OS::memcpy(), ACE_RMCast::Message_ptr, ACE_RMCast::Part::num(), ACE_RMCast::Part::of(), ACE_RMCast::Profile_ptr, ACE_RMCast::In_Element::recv(), ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::release(), ACE_RMCast::Data::size(), and ACE_RMCast::Part::total_size().
00024 { 00025 Map::ENTRY* e; 00026 Address from ( 00027 static_cast<From const*> (m->find (From::id))->address ()); 00028 00029 if (Data const* data = static_cast<Data const*> (m->find (Data::id))) 00030 { 00031 if (Part const* part = static_cast<Part const*> (m->find (Part::id))) 00032 { 00033 if (map_.find (from, e) == -1) 00034 { 00035 // First part of the message. 00036 // 00037 00038 if (part->num () != 1) 00039 { 00040 // We assume that we received NoData for one of the preceding 00041 // fragments. Ignore this one. 00042 return; 00043 } 00044 00045 Data_ptr new_data (new Data (data->buf (), 00046 static_cast<size_t> (data->size ()), 00047 static_cast<size_t> (part->total_size ()))); 00048 00049 //std::cerr << "part->total_size (): " << part->total_size () << endl; 00050 00051 map_.bind (from, new_data); 00052 } 00053 else 00054 { 00055 // Next part of the message. 00056 // 00057 00058 if (part->num () == 1) 00059 ACE_OS::abort (); 00060 00061 00062 Data const* data = static_cast<Data const*> (m->find (Data::id)); 00063 00064 Data_ptr& new_data = e->int_id_; 00065 00066 ACE_OS::memcpy (new_data->buf () + new_data->size (), 00067 data->buf (), 00068 data->size ()); 00069 00070 //std::cerr << "data->size (): " << data->size () << endl 00071 // << "new_data->size (): " << new_data->size () << endl 00072 // << "new_data->capa (): " << new_data->capacity () << endl; 00073 00074 new_data->size (new_data->size () + data->size ()); 00075 00076 00077 if (part->num () == part->of ()) 00078 { 00079 // Reassembly is complete. 00080 // 00081 if (part->total_size () != new_data->size ()) 00082 ACE_OS::abort (); 00083 00084 Message_ptr new_msg (new Message ()); 00085 00086 Address to ( 00087 static_cast<To const*> (m->find (To::id))->address ()); 00088 00089 new_msg->add (Profile_ptr (new To (to))); 00090 new_msg->add (Profile_ptr (new From (from))); 00091 new_msg->add (Profile_ptr (new_data.release ())); 00092 00093 map_.unbind (from); 00094 00095 in_->recv (new_msg); 00096 } 00097 } 00098 } 00099 else 00100 { 00101 // Non-fragmented message. Make sure we are in the consistent state 00102 // and forward it up. 00103 // 00104 if (map_.find (from, e) != -1) 00105 ACE_OS::abort (); 00106 00107 in_->recv (m); 00108 } 00109 } 00110 else if (m->find (NoData::id) != 0) 00111 { 00112 if (map_.find (from, e) != -1) 00113 { 00114 // We already received some fragments. Clean everyhting up. 00115 // 00116 map_.unbind (from); 00117 } 00118 00119 in_->recv (m); 00120 } 00121 } |
|
Definition at line 37 of file Reassemble.h. |
|
Definition at line 27 of file Reassemble.h. |