Changeset 5614


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

Location:
source/ariba
Files:
10 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 );
  • source/ariba/communication/BaseCommunication.h

    r5485 r5614  
    288288        NetworkChangeDetection networkMonitor;
    289289#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 );
    290303
    291304        /// event listener
     
    306319        void send( Message* message, const LinkDescriptor& descriptor );
    307320
     321
     322
    308323        /// state of the base communication
    309324        bool started;
  • source/ariba/utility/system/StartupWrapper.cpp

    r5483 r5614  
    9898        {
    9999                log4cxx::LoggerPtr logger(log4cxx::Logger::getRootLogger());
    100                 logger->setLevel(log4cxx::Level::getDebug());
     100                logger->setLevel(log4cxx::Level::getInfo());
    101101        }
    102102
  • source/ariba/utility/transport/rfcomm/rfcomm.cpp

    r5524 r5614  
    182182}
    183183
    184 void rfcomm::terminate(const address_v* local, const address_v* remote) {
     184void rfcomm::terminate( const address_v* remote) {
    185185        // get end-point
    186186        rfcomm_endpoint endpoint = *remote;
  • source/ariba/utility/transport/rfcomm/rfcomm.hpp

    r5406 r5614  
    3636        virtual void send( const address_v* remote, const uint8_t* data, size_t size );
    3737        virtual void send( const endpoint_set& endpoints, const uint8_t* data, size_t size );
    38         virtual void terminate( const address_v* local, const address_v* remote );
     38        virtual void terminate( const address_v* remote );
    3939        virtual void register_listener( transport_listener* listener );
    4040
  • source/ariba/utility/transport/tcpip/tcpip.cpp

    r5444 r5614  
    135135}
    136136
    137 void tcpip::terminate(const address_v* local, const address_v* remote) {
     137void tcpip::terminate( const address_v* remote) {
    138138        tcpip_endpoint endpoint = *remote;
    139139        appladdress peer = convert(endpoint);
  • source/ariba/utility/transport/tcpip/tcpip.hpp

    r5284 r5614  
    3131        virtual void send( const address_v* remote, const uint8_t* data, size_t size );
    3232        virtual void send( const endpoint_set& endpoints, const uint8_t* data, size_t size );
    33         virtual void terminate( const address_v* local, const address_v* remote );
     33        virtual void terminate( const address_v* remote );
    3434        virtual void register_listener( transport_listener* listener );
    3535
  • source/ariba/utility/transport/transport_peer.cpp

    r5284 r5614  
    5656}
    5757
    58 void transport_peer::terminate( const address_v* local, const address_v* remote ) {
     58void transport_peer::terminate( const address_v* remote ) {
    5959        if (remote->instanceof<tcpip_endpoint>() && tcp!=NULL)
    60                 tcp->terminate(local,remote);
     60                tcp->terminate(remote);
    6161        if (remote->instanceof<rfcomm_endpoint>() && rfc!=NULL)
    62                 rfc->terminate(local,remote);
     62                rfc->terminate(remote);
    6363}
    6464
  • source/ariba/utility/transport/transport_peer.hpp

    r5284 r5614  
    2929        virtual void send( const address_v* remote, const uint8_t* data, size_t size );
    3030        virtual void send( const endpoint_set& endpoints, const uint8_t* data, size_t size );
    31         virtual void terminate( const address_v* local, const address_v* remote );
     31        virtual void terminate( const address_v* remote );
    3232        virtual void register_listener( transport_listener* listener );
    3333
  • source/ariba/utility/transport/transport_protocol.hpp

    r5284 r5614  
    2222        virtual void send( const address_v* remote, const uint8_t* data, size_t size ) = 0;
    2323        virtual void send( const endpoint_set& endpoints, const uint8_t* data, size_t size ) = 0;
    24         virtual void terminate( const address_v* local, const address_v* remote ) = 0;
     24        virtual void terminate( const address_v* remote ) = 0;
    2525        virtual void register_listener( transport_listener* listener ) = 0;
    2626};
Note: See TracChangeset for help on using the changeset viewer.