Ignore:
Timestamp:
Aug 3, 2009, 11:35:20 AM (15 years ago)
Author:
mies
Message:

added termination of transports when no link is up anymore to an end-point

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/communication/BaseCommunication.cpp

    r5485 r5614  
    5656use_logging_cpp(BaseCommunication);
    5757
     58/// adds an endpoint to the list
     59void 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
     73void 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
    5888BaseCommunication::BaseCommunication() {
    5989        this->transport = NULL;
     
    254284}
    255285
    256 /// called when a message is received form transport_peer
     286/// called when a message is received from transport_peer
    257287void BaseCommunication::receive_message(transport_protocol* transport,
    258288        const address_vf local, const address_vf remote, const uint8_t* data,
     
    482512/// add a newly allocated link to the set of links
    483513void BaseCommunication::addLink( LinkDescriptor* link ) {
     514        add_endpoint(link->remoteLocator);
    484515        linkSet.push_back( link );
    485516}
     
    489520        for(LinkSet::iterator i=linkSet.begin(); i != linkSet.end(); i++){
    490521                if( (*i)->localLink != localLink) continue;
     522                remove_endpoint((*i)->remoteLocator);
    491523                delete *i;
    492524                linkSet.erase( i );
Note: See TracChangeset for help on using the changeset viewer.