Ignore:
Timestamp:
May 26, 2009, 8:03:39 PM (15 years ago)
Author:
Christoph Mayer
Message:

-autolink message buffer von basecomm nach baseoverlay und komplette logik hochgezogen damit mit neuem overlay routing zurecht kommt, damit ist letzer fehler raus

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/overlay/BaseOverlay.cpp

    r3705 r3712  
    270270        LinkMapping::iterator i = linkMapping.find( link );
    271271
     272        // find the link item to drop
    272273        if( i == linkMapping.end() ){
    273274                logging_warn( "can't drop link, mapping unknown " << link.toString() );
     
    275276        }
    276277
     278        LinkItem item = i->second;
     279
     280        // delete all queued messages
     281        if( item.waitingmsg.size() > 0 ){
     282
     283                logging_warn( "dropping link " << link.toString() <<
     284                        " that has " << item.waitingmsg.size() << " waiting messages" );
     285
     286                item.deleteWaiting();
     287        }
     288
     289        // erase the mapping and drop the link
    277290        linkMapping.erase( i );
    278 
    279         LinkItem item = i->second;
    280291        bc->dropLink( link );
    281292
     293        // tell sideports and listeners of the drop
    282294        item.interface->onLinkDown( link, item.node );
    283295        sideport->onLinkDown(link, this->nodeId, item.node, this->spovnetId );
     
    287299
    288300        logging_debug( "baseoverlay is sending data message on link " << link.toString() );
     301
     302        //
     303        // get the mapping for this link
     304        //
    289305
    290306        LinkMapping::iterator i = linkMapping.find( link );
     
    294310        }
    295311
    296         OverlayMsg overmsg(
    297                 OverlayMsg::OverlayMessageTypeData,     i->second.service, nodeId );
     312        i->second.markused();
     313
     314        //
     315        // check if the link is up yet, if its an autlink queue message
     316        //
     317
     318        if( !i->second.linkup ){
     319
     320                if( i->second.autolink ){
     321                        logging_info( "auto link " << link.toString() << " is not up yet, queueing message" );
     322                        i->second.waitingmsg.push_back( new Message(*message) );
     323                } else {
     324                        logging_error("link " << link.toString() << " is not up yet, dropping message" );
     325                }
     326
     327                return -1;
     328        }
     329
     330        //
     331        // send the message through the basecomm
     332        //
     333
     334        OverlayMsg overmsg( OverlayMsg::OverlayMessageTypeData, i->second.service, nodeId );
    298335        overmsg.encapsulate( const_cast<Message*>(message) );
    299336
    300         i->second.markused();
    301337        return bc->sendMessage( link, &overmsg );
    302338}
     
    308344        LinkMapping::iterator i = linkMapping.begin();
    309345        LinkMapping::iterator iend = linkMapping.end();
     346
     347        //
     348        // see if we find a link for this node and service destination
     349        //
    310350
    311351        for( ; i != iend; i++ ){
     
    316356        }
    317357
     358        //
     359        // if we found no link, create an auto link
     360        //
     361
    318362        if( link == LinkID::UNSPECIFIED ){
    319363
     
    322366                                ". creating auto link ...");
    323367
     368                // call basecomm to create a link
    324369                link = establishLink( node, service );
     370
     371                // this will call onlinkup on us, if everything worked we now have a mapping
    325372                LinkMapping::iterator i = linkMapping.find( link );
     373                i->second.autolink = true;
    326374
    327375                if( i == linkMapping.end() || link == LinkID::UNSPECIFIED ){
     
    330378                        return -1;
    331379                }
    332 
    333                 i->second.autolink = true;
    334380
    335381                logging_debug( "establishing autolink in progress to node "
     
    531577        sideport->onLinkDown( id, this->nodeId, i->second.node, this->spovnetId );
    532578
     579        // delete all queued messages
     580        if( i->second.waitingmsg.size() > 0 ){
     581
     582                logging_warn( "dropping link " << id.toString() <<
     583                        " that has " << i->second.waitingmsg.size() << " waiting messages" );
     584
     585                i->second.deleteWaiting();
     586        }
     587
    533588        linkMapping.erase( i );
    534589}
     
    788843
    789844                // update our link mapping information for this link
    790                 bool changed =
    791                         ( i->second.node != sourcenode ) ||
    792                         ( i->second.service != service );
     845                bool changed = ( i->second.node != sourcenode ) || ( i->second.service != service );
    793846                i->second.node = sourcenode;
    794847                i->second.service = service;
     
    818871
    819872                // ask the service whether it wants to accept this link
    820                 if( iface->onLinkRequest(sourcenode) ){
    821 
    822                         logging_debug("link " << link.toString() <<
    823                                         " has been accepted by service " << service.toString());
    824 
    825                         // call the notification functions
    826                         iface->onLinkUp( link, sourcenode );
    827                         sideport->onLinkUp( link, nodeId, sourcenode, this->spovnetId );
    828 
    829                 } else {
     873                if( !iface->onLinkRequest(sourcenode) ){
    830874
    831875                        logging_debug("link " << link.toString() <<
     
    836880                        // drop the link
    837881                        dropLink( link );
    838                 }
     882
     883                        return true;
     884                }
     885
     886                //
     887                // link has been accepted, link is now up, send messages out first
     888                //
     889
     890                i->second.linkup = true;
     891                logging_debug("link " << link.toString() <<
     892                                                " has been accepted by service " << service.toString() << " and is now up");
     893
     894                if( i->second.waitingmsg.size() > 0 ){
     895                        logging_info( "sending out queued messages on link " << link.toString() );
     896
     897                        BOOST_FOREACH( Message* msg, i->second.waitingmsg ){
     898                                sendMessage( msg, link );
     899                                delete msg;
     900                        }
     901
     902                        i->second.waitingmsg.clear();
     903                }
     904
     905                // call the notification functions
     906                iface->onLinkUp( link, sourcenode );
     907                sideport->onLinkUp( link, nodeId, sourcenode, this->spovnetId );
    839908
    840909                return true;
Note: See TracChangeset for help on using the changeset viewer.