Changeset 5614 for source/ariba/communication
- Timestamp:
- Aug 3, 2009, 11:35:20 AM (15 years ago)
- Location:
- source/ariba/communication
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/communication/BaseCommunication.cpp
r5485 r5614 56 56 use_logging_cpp(BaseCommunication); 57 57 58 /// adds an endpoint to the list 59 void BaseCommunication::add_endpoint( const address_v* endpoint ) { 60 BOOST_FOREACH( endpoint_reference& ref, remote_endpoints ) { 61 if (*ref.endpoint == *endpoint) { 62 ref.count++; 63 return; 64 } 65 } 66 endpoint_reference ref; 67 ref.endpoint = endpoint; 68 ref.count = 0; 69 remote_endpoints.push_back(ref); 70 } 71 72 /// removes an endpoint from the list 73 void BaseCommunication::remove_endpoint( const address_v* endpoint ) { 74 for (vector<endpoint_reference>::iterator i = remote_endpoints.begin(); 75 i != remote_endpoints.end(); i++) { 76 if (*i->endpoint == *endpoint) { 77 i->count--; 78 if (i->count==0) { 79 logging_info("No more links to " << i->endpoint->to_string() << ": terminating transports!"); 80 transport->terminate(i->endpoint); 81 remote_endpoints.erase(i); 82 } 83 return; 84 } 85 } 86 } 87 58 88 BaseCommunication::BaseCommunication() { 59 89 this->transport = NULL; … … 254 284 } 255 285 256 /// called when a message is received f orm transport_peer286 /// called when a message is received from transport_peer 257 287 void BaseCommunication::receive_message(transport_protocol* transport, 258 288 const address_vf local, const address_vf remote, const uint8_t* data, … … 482 512 /// add a newly allocated link to the set of links 483 513 void BaseCommunication::addLink( LinkDescriptor* link ) { 514 add_endpoint(link->remoteLocator); 484 515 linkSet.push_back( link ); 485 516 } … … 489 520 for(LinkSet::iterator i=linkSet.begin(); i != linkSet.end(); i++){ 490 521 if( (*i)->localLink != localLink) continue; 522 remove_endpoint((*i)->remoteLocator); 491 523 delete *i; 492 524 linkSet.erase( i ); -
source/ariba/communication/BaseCommunication.h
r5485 r5614 288 288 NetworkChangeDetection networkMonitor; 289 289 #endif 290 /// list of all remote addresses of links to end-points 291 class endpoint_reference { 292 public: 293 int count; ///< the number of open links to this end-point 294 const address_v* endpoint; ///< the end-point itself 295 }; 296 vector<endpoint_reference> remote_endpoints; 297 298 /// adds an end-point to the list 299 void add_endpoint( const address_v* endpoint ); 300 301 /// removes an end-point from the list 302 void remove_endpoint( const address_v* endpoint ); 290 303 291 304 /// event listener … … 306 319 void send( Message* message, const LinkDescriptor& descriptor ); 307 320 321 322 308 323 /// state of the base communication 309 324 bool started;
Note:
See TracChangeset
for help on using the changeset viewer.