Changeset 3712 for source/ariba/overlay/BaseOverlay.cpp
- Timestamp:
- May 26, 2009, 8:03:39 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.cpp
r3705 r3712 270 270 LinkMapping::iterator i = linkMapping.find( link ); 271 271 272 // find the link item to drop 272 273 if( i == linkMapping.end() ){ 273 274 logging_warn( "can't drop link, mapping unknown " << link.toString() ); … … 275 276 } 276 277 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 277 290 linkMapping.erase( i ); 278 279 LinkItem item = i->second;280 291 bc->dropLink( link ); 281 292 293 // tell sideports and listeners of the drop 282 294 item.interface->onLinkDown( link, item.node ); 283 295 sideport->onLinkDown(link, this->nodeId, item.node, this->spovnetId ); … … 287 299 288 300 logging_debug( "baseoverlay is sending data message on link " << link.toString() ); 301 302 // 303 // get the mapping for this link 304 // 289 305 290 306 LinkMapping::iterator i = linkMapping.find( link ); … … 294 310 } 295 311 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 ); 298 335 overmsg.encapsulate( const_cast<Message*>(message) ); 299 336 300 i->second.markused();301 337 return bc->sendMessage( link, &overmsg ); 302 338 } … … 308 344 LinkMapping::iterator i = linkMapping.begin(); 309 345 LinkMapping::iterator iend = linkMapping.end(); 346 347 // 348 // see if we find a link for this node and service destination 349 // 310 350 311 351 for( ; i != iend; i++ ){ … … 316 356 } 317 357 358 // 359 // if we found no link, create an auto link 360 // 361 318 362 if( link == LinkID::UNSPECIFIED ){ 319 363 … … 322 366 ". creating auto link ..."); 323 367 368 // call basecomm to create a link 324 369 link = establishLink( node, service ); 370 371 // this will call onlinkup on us, if everything worked we now have a mapping 325 372 LinkMapping::iterator i = linkMapping.find( link ); 373 i->second.autolink = true; 326 374 327 375 if( i == linkMapping.end() || link == LinkID::UNSPECIFIED ){ … … 330 378 return -1; 331 379 } 332 333 i->second.autolink = true;334 380 335 381 logging_debug( "establishing autolink in progress to node " … … 531 577 sideport->onLinkDown( id, this->nodeId, i->second.node, this->spovnetId ); 532 578 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 533 588 linkMapping.erase( i ); 534 589 } … … 788 843 789 844 // 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 ); 793 846 i->second.node = sourcenode; 794 847 i->second.service = service; … … 818 871 819 872 // 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) ){ 830 874 831 875 logging_debug("link " << link.toString() << … … 836 880 // drop the link 837 881 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 ); 839 908 840 909 return true;
Note:
See TracChangeset
for help on using the changeset viewer.