Changeset 2483 for source/ariba/communication
- Timestamp:
- Feb 24, 2009, 10:06:43 PM (16 years ago)
- Location:
- source/ariba/communication
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/communication/BaseCommunication.cpp
r2482 r2483 85 85 86 86 for( ; i != iend; i++){ 87 logging_debug( "local locator found " +(*i)->toString() );87 logging_debug( "local locator found " << (*i)->toString() ); 88 88 IPv4Locator* ipv4locator = dynamic_cast<IPv4Locator*>(*i); 89 89 … … 101 101 localDescriptor.locator = ipv4locator; 102 102 localDescriptor.isUnspec = false; 103 logging_info( "binding to addr = " +ipv4locator->toString() );103 logging_info( "binding to addr = " << ipv4locator->toString() ); 104 104 foundLocator = true; 105 105 break; … … 180 180 LinkID linkid = LinkID::create(); 181 181 182 logging_debug( "creating new local descriptor entry with local link id " +linkid.toString() );183 LinkDescriptor linkDescriptor( linkid, local, LinkID::UNSPECIFIED, remote, descriptor );182 logging_debug( "creating new local descriptor entry with local link id " << linkid.toString() ); 183 LinkDescriptor linkDescriptor( linkid, local, LinkID::UNSPECIFIED, remote, descriptor, false ); 184 184 addLink( linkDescriptor ); 185 185 … … 189 189 // 190 190 191 logging_debug( "sending out base messages with request to open link to " +remote->toString() );191 logging_debug( "sending out base messages with request to open link to " << remote->toString() ); 192 192 AribaBaseMsg baseMsg( remote, AribaBaseMsg::LINK_STATE_OPEN_REQUEST, linkid, 193 193 LinkID::UNSPECIFIED ); … … 206 206 logging_error( "don't know the link you want to drop" ); 207 207 return; 208 } 209 210 // warn if this link has some queued messages attached 211 if( descriptor.waitingmsg.size() > 0 ){ 212 logging_warn( "dropping link " << link.toString() << 213 " that has " << descriptor.waitingmsg.size() << " waiting messages" ); 208 214 } 209 215 … … 231 237 seqnum_t BaseCommunication::sendMessage( const LinkID lid, const Message* message) { 232 238 233 logging_debug( "sending out message to link " +lid.toString() );239 logging_debug( "sending out message to link " << lid.toString() ); 234 240 235 241 // query local link info 236 242 LinkDescriptor& linkDesc = queryLocalLink(lid); 237 243 if( linkDesc.isUnspecified() ){ 238 logging_error( "don't know the link with id " +lid.toString() );239 return 0;244 logging_error( "don't know the link with id " << lid.toString() ); 245 return -1; 240 246 } 241 247 … … 251 257 msg.encapsulate( const_cast<Message*>(message) ); 252 258 253 // send message 254 transport->sendMessage( &msg ); 255 256 return ++currentSeqnum; 259 if( linkDesc.linkup ){ 260 261 // send message 262 transport->sendMessage( &msg ); 263 return ++currentSeqnum; 264 265 } else { 266 267 // queue message 268 logging_info( "link " << lid.toString() << " is not up yet, queueing message" ); 269 linkDesc.waitingmsg.push_back( new Message(msg) ); // TODO ooooo 270 271 return 0; 272 273 } // if( linkDesc.linkup ) 257 274 } 258 275 … … 300 317 301 318 AribaBaseMsg* spovmsg = ((Message*)message)->decapsulate<AribaBaseMsg>(); 302 logging_debug( "receiving base comm message of type " +spovmsg->getTypeString() );319 logging_debug( "receiving base comm message of type " << spovmsg->getTypeString() ); 303 320 304 321 // … … 351 368 const NetworkLocator* remoteLocator = dynamic_cast<const NetworkLocator*>(message->getSourceAddress()); 352 369 353 logging_debug( "localLocator=" + localLocator->toString() + " remoteLocator="+remoteLocator->toString()); 370 logging_debug( "localLocator=" << localLocator->toString() 371 << " remoteLocator=" << remoteLocator->toString()); 354 372 355 373 // ask the registered listeners if this link … … 372 390 373 391 LinkDescriptor linkDescriptor(localLink, localLocator, remoteLink, 374 remoteLocator, EndpointDescriptor(remoteLocator) );392 remoteLocator, EndpointDescriptor(remoteLocator), true); 375 393 376 394 logging_debug( "saving new link descriptor with " << … … 378 396 "[local locator " << localLocator->toString() << "] " << 379 397 "[remote link " << remoteLink.toString() << "] " << 380 "[remote locator " << remoteLocator->toString() << "]" ); 398 "[remote locator " << remoteLocator->toString() << "]" << 399 "[link up true]" ); 381 400 382 401 addLink( linkDescriptor ); … … 400 419 // the link is now open 401 420 // 402 421 403 422 BOOST_FOREACH( CommunicationEvents* i, eventListener ){ 404 423 i->onLinkUp( localLink, localLocator, remoteLocator ); … … 420 439 421 440 if (linkDesc.isUnspecified()) { 422 logging_warn("Failed to find local link " +spovmsg->getRemoteLink().toString());441 logging_warn("Failed to find local link " << spovmsg->getRemoteLink().toString()); 423 442 return false; 424 443 } 425 444 426 445 linkDesc.remoteLink = spovmsg->getLocalLink(); 427 logging_debug( "the link is now up with local link id " + spovmsg->getRemoteLink().toString() ); 446 linkDesc.linkup = true; 447 448 logging_debug( "the link is now up with local link id " << spovmsg->getRemoteLink().toString() ); 428 449 429 450 BOOST_FOREACH( CommunicationEvents* i, eventListener ){ … … 431 452 } 432 453 454 if( linkDesc.waitingmsg.size() > 0 ){ 455 logging_info( "sending out queued messages on link " << linkDesc.localLink.toString() ); 456 457 BOOST_FOREACH( Message* msg, linkDesc.waitingmsg ){ 458 sendMessage( linkDesc.localLink, msg ); 459 delete msg; 460 } 461 462 linkDesc.waitingmsg.clear(); 463 } 464 433 465 } // LINK_STATE_OPEN_REPLY 434 466 … … 440 472 441 473 const LinkID& localLink = spovmsg->getRemoteLink(); 442 logging_debug( "received link close request for link " +localLink.toString() );474 logging_debug( "received link close request for link " << localLink.toString() ); 443 475 444 476 // … … 450 482 LinkDescriptor& linkDesc = queryLocalLink( localLink ); 451 483 if (linkDesc.isUnspecified()) { 452 logging_warn("Failed to find local link " +localLink.toString());484 logging_warn("Failed to find local link " << localLink.toString()); 453 485 return false; 454 486 } … … 469 501 470 502 const LinkID& localLink = spovmsg->getRemoteLink(); 471 logging_debug( "received link update for link " +localLink.toString() );503 logging_debug( "received link update for link " << localLink.toString() ); 472 504 473 505 // … … 477 509 LinkDescriptor& linkDesc = queryLocalLink( localLink ); 478 510 if (linkDesc.isUnspecified()) { 479 logging_warn("Failed to update local link " +localLink.toString());511 logging_warn("Failed to update local link " << localLink.toString()); 480 512 return false; 481 513 } … … 517 549 518 550 for( ; i != iend; i++){ 519 if( (*i).localLink == localLink){ 520 linkSet.erase( i ); 521 break; 522 } 551 if( (*i).localLink != localLink) continue; 552 553 BOOST_FOREACH( Message* msg, i->waitingmsg ){ 554 delete msg; 555 } 556 557 i->waitingmsg.clear(); 558 linkSet.erase( i ); 559 560 break; 523 561 } 524 562 } … … 568 606 info.type != NetworkChangeInterface::EventTypeAddressDelete ) return; 569 607 570 logging_info( "base communication is handling network address changes");608 logging_info( "base communication is handling network address changes" ); 571 609 572 610 // … … 610 648 611 649 for( ; i != iend; i++){ 612 logging_debug( "local locator found " +(*i)->toString() );650 logging_debug( "local locator found " << (*i)->toString() ); 613 651 IPv4Locator* ipv4locator = dynamic_cast<IPv4Locator*>(*i); 614 652 -
source/ariba/communication/BaseCommunication.h
r2482 r2483 46 46 #include <vector> 47 47 #include <iostream> 48 #include <deque> 48 49 #include <algorithm> 49 50 #include <boost/foreach.hpp> … … 77 78 using std::map; 78 79 using std::vector; 80 using std::deque; 79 81 using std::pair; 80 82 using std::make_pair; … … 222 224 remoteLink(), 223 225 remoteLocator(NULL), 224 remoteEndpoint(EndpointDescriptor::UNSPECIFIED){ 226 remoteEndpoint(EndpointDescriptor::UNSPECIFIED), 227 linkup(false) { 225 228 } 226 229 227 230 LinkDescriptor(const LinkID& _localLink, const NetworkLocator*& _localLocator, 228 231 const LinkID& _remoteLink, const NetworkLocator*& _remoteLocator, 229 const EndpointDescriptor& _remoteEndpoint ) :232 const EndpointDescriptor& _remoteEndpoint, bool _linkup ) : 230 233 localLink(_localLink), 231 234 localLocator(_localLocator), 232 235 remoteLink(_remoteLink), 233 236 remoteLocator(_remoteLocator), 234 remoteEndpoint(_remoteEndpoint){ 237 remoteEndpoint(_remoteEndpoint), 238 linkup(_linkup) { 235 239 } 236 240 … … 240 244 remoteLink(desc.remoteLink), 241 245 remoteLocator(desc.remoteLocator), 242 remoteEndpoint(desc.remoteEndpoint){ 246 remoteEndpoint(desc.remoteEndpoint), 247 linkup(desc.linkup) { 248 249 BOOST_FOREACH( Message* msg, desc.waitingmsg ){ 250 waitingmsg.push_back( msg ); 251 } 243 252 } 244 253 … … 252 261 const NetworkLocator* remoteLocator; 253 262 EndpointDescriptor remoteEndpoint; 263 264 bool linkup; 265 deque<Message*> waitingmsg; 254 266 }; 255 267
Note:
See TracChangeset
for help on using the changeset viewer.