ConnectionPtr Node::getMulticast() { if( !isReachable( )) return 0; ConnectionPtr connection = _impl->outMulticast.data; if( connection && !connection->isClosed( )) return connection; lunchbox::ScopedMutex<> mutex( _impl->outMulticast ); if( _impl->multicasts.empty( )) return 0; MCData data = _impl->multicasts.back(); _impl->multicasts.pop_back(); NodePtr node = data.node; // prime multicast connections on peers LBINFO << "Announcing id " << node->getNodeID() << " to multicast group " << data.connection->getDescription() << std::endl; #ifdef COLLAGE_BIGENDIAN uint32_t cmd = CMD_NODE_ID_BE; lunchbox::byteswap( cmd ); #else const uint32_t cmd = CMD_NODE_ID; #endif OCommand( Connections( 1, data.connection ), cmd ) << node->getNodeID() << getType() << node->serialize(); _impl->outMulticast.data = data.connection; return data.connection; }
void LocalNode::_removeConnection( ConnectionPtr connection ) { EQASSERT( connection.isValid( )); _incoming.removeConnection( connection ); void* buffer( 0 ); uint64_t bytes( 0 ); connection->getRecvData( &buffer, &bytes ); EQASSERTINFO( !connection->isConnected() || buffer, *connection ); EQASSERT( !buffer || bytes == sizeof( uint64_t )); if( !connection->isClosed( )) connection->close(); // cancels pending IO's delete reinterpret_cast< uint64_t* >( buffer ); }