OpenDDS
Snapshot(2023/04/07-19:43)
|
#include <TcpTransport.h>
Classes | |
class | Connector |
Private Types | |
typedef ACE_Hash_Map_Manager_Ex< PriorityKey, TcpDataLink_rch, ACE_Hash< PriorityKey >, ACE_Equal_To< PriorityKey >, ACE_Null_Mutex > | AddrLinkMap |
Map Type: (key) PriorityKey to (value) TcpDataLink_rch. More... | |
typedef ACE_SYNCH_MUTEX | LockType |
typedef ACE_Guard< LockType > | GuardType |
typedef ConditionVariable< LockType > | ConditionVariableType |
Private Attributes | |
unique_ptr< TcpAcceptor > | acceptor_ |
Used to accept passive connections on our local_address_. More... | |
Connector | connector_ |
Open TcpConnections using non-blocking connect. More... | |
AddrLinkMap | links_ |
This is the map of connected DataLinks. More... | |
AddrLinkMap | pending_release_links_ |
LockType | links_lock_ |
This lock is used to protect the links_ data member. More... | |
ConnectionMap | connections_ |
LockType | connections_lock_ |
Atomic< size_t > | last_link_ |
Friends | |
class | TcpConnection |
class | TcpDataLink |
This class provides the "Tcp" transport specific implementation. It creates the acceptor for listening the incoming requests using TCP and maintains a collection of TCP specific connections/datalinks.
Notes about object ownership: 1) Own the datalink objects, passive connection objects, acceptor object and TcpConnectionReplaceTask object(used during reconnecting). 2) Reference to TransportReactorTask object owned by base class.
Definition at line 48 of file TcpTransport.h.
|
private |
Map Type: (key) PriorityKey to (value) TcpDataLink_rch.
Definition at line 121 of file TcpTransport.h.
|
private |
Definition at line 128 of file TcpTransport.h.
|
private |
Definition at line 127 of file TcpTransport.h.
|
private |
Definition at line 126 of file TcpTransport.h.
|
explicit |
Definition at line 36 of file TcpTransport.cpp.
References configure_i(), DBG_ENTRY_LVL, OpenDDS::DCPS::TransportImpl::open(), and OpenDDS::DCPS::TransportImpl::shutdown().
|
virtual |
|
privatevirtual |
accept_datalink() is called from TransportClient to initiate an association as the passive peer. A DataLink may be returned if one is already connected and ready to use, otherwise passively wait for a physical connection from the active side (either in the form of a connection event or handshaking message). Upon completion of the physical connection, the transport calls back to TransportClient::use_datalink().
Implements OpenDDS::DCPS::TransportImpl.
Definition at line 219 of file TcpTransport.cpp.
References ACE_ERROR, OpenDDS::DCPS::TransportImpl::AcceptConnectResult::ACR_SUCCESS, OpenDDS::DCPS::DataLink::add_on_start_callback(), OpenDDS::DCPS::TransportImpl::add_pending_connection(), OpenDDS::DCPS::PriorityKey::address(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), OpenDDS::DCPS::TransportImpl::RemoteTransport::blob_, blob_to_key(), OpenDDS::DCPS::LogGuid::c_str(), connect_tcp_datalink(), connections_, connections_lock_, DBG_ENTRY_LVL, OpenDDS::DCPS::TcpDataLink::do_association_actions(), find_datalink_i(), OpenDDS::DCPS::RcHandle< T >::in(), OpenDDS::DCPS::PriorityKey::is_active(), OpenDDS::DCPS::PriorityKey::is_loopback(), OpenDDS::DCPS::RcHandle< T >::is_nil(), OpenDDS::DCPS::TransportImpl::is_shut_down(), links_, links_lock_, LM_DEBUG, LM_ERROR, OpenDDS::DCPS::TransportImpl::ConnectionAttribs::local_id_, OpenDDS::DCPS::PriorityKey::priority(), OpenDDS::DCPS::TransportImpl::ConnectionAttribs::priority_, OpenDDS::DCPS::rchandle_from(), ACE_Guard< ACE_LOCK >::release(), OpenDDS::DCPS::TransportImpl::RemoteTransport::repo_id_, OpenDDS::DCPS::RcHandle< T >::reset(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(), and VDBG_LVL.
|
private |
Definition at line 171 of file TcpTransport.cpp.
References ACE_DEBUG, OpenDDS::DCPS::DCPS_debug_level, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), OpenDDS::DCPS::RcHandle< T >::in(), OpenDDS::DCPS::DataLink::invoke_on_start_callbacks(), links_, links_lock_, LM_WARNING, ACE_Guard< ACE_LOCK >::release(), and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind().
Referenced by OpenDDS::DCPS::TcpConnection::active_open(), and OpenDDS::DCPS::TcpConnection::handle_timeout().
|
private |
Definition at line 63 of file TcpTransport.cpp.
References config(), and OpenDDS::DCPS::AssociationData::get_remote_address().
Referenced by accept_datalink(), and connect_datalink().
|
privatevirtual |
Reimplemented from OpenDDS::DCPS::TransportImpl.
Definition at line 390 of file TcpTransport.cpp.
References ACE_Hash_Map_Entry< EXT_ID, INT_ID >::int_id_, links_, links_lock_, ACE_Hash_Map_Iterator_Base_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::next(), and pending_release_links_.
TcpInst_rch OpenDDS::DCPS::TcpTransport::config | ( | ) | const |
Definition at line 57 of file TcpTransport.cpp.
References OpenDDS::DCPS::TransportImpl::config(), and OpenDDS::DCPS::dynamic_rchandle_cast().
Referenced by blob_to_key(), connect_datalink(), connect_tcp_datalink(), connection_info_i(), fresh_link(), and passive_connection().
|
privatevirtual |
Definition at line 319 of file TcpTransport.cpp.
References acceptor_, ACE_ERROR, ACE_ERROR_RETURN, ACE_TEXT(), connector_, OpenDDS::DCPS::TransportImpl::create_reactor_task(), DBG_ENTRY_LVL, OpenDDS::DCPS::get_fully_qualified_hostname(), ACE_INET_Addr::get_port_number(), OpenDDS::DCPS::ReactorTask::get_reactor(), hostname(), LM_DEBUG, LM_ERROR, ACE_Connector< class, class >::open(), OpenDDS::DCPS::TransportImpl::reactor_task(), TheServiceParticipant, and VDBG_LVL.
Referenced by TcpTransport().
|
privatevirtual |
connect_datalink() is called from TransportClient to initiate an association as the active peer. A DataLink may be returned if one is already connected and ready to use, otherwise initiate a connection to the passive side and return from this method. Upon completion of the physical connection, the transport calls back to TransportClient::use_datalink().
Implements OpenDDS::DCPS::TransportImpl.
Definition at line 74 of file TcpTransport.cpp.
References ACE_ERROR, OpenDDS::DCPS::TransportImpl::AcceptConnectResult::ACR_SUCCESS, OpenDDS::DCPS::DataLink::add_on_start_callback(), OpenDDS::DCPS::TransportImpl::add_pending_connection(), OpenDDS::DCPS::PriorityKey::address(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), OpenDDS::DCPS::TransportImpl::RemoteTransport::blob_, blob_to_key(), config(), ACE_Connector< class, class >::connect(), connector_, DBG_ENTRY_LVL, OpenDDS::DCPS::TcpDataLink::do_association_actions(), EWOULDBLOCK, find_datalink_i(), OpenDDS::DCPS::RcHandle< T >::in(), OpenDDS::DCPS::DataLink::invoke_on_start_callbacks(), OpenDDS::DCPS::PriorityKey::is_active(), OpenDDS::DCPS::PriorityKey::is_loopback(), OpenDDS::DCPS::TransportImpl::is_shut_down(), links_, links_lock_, LM_DEBUG, LM_ERROR, ACE_Time_Value::msec(), OpenDDS::DCPS::PriorityKey::priority(), OpenDDS::DCPS::TransportImpl::ConnectionAttribs::priority_, OpenDDS::DCPS::rchandle_from(), OpenDDS::DCPS::TransportImpl::RemoteTransport::repo_id_, OpenDDS::DCPS::DataLink::transport_priority(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(), ACE_Synch_Options::USE_REACTOR, ACE_Synch_Options::USE_TIMEOUT, and VDBG_LVL.
|
private |
Common code used by accept_datalink(), passive_connection(), and active completion.
Code common to make_active_connection() and make_passive_connection().
Definition at line 674 of file TcpTransport.cpp.
References ACE_DEBUG, ACE_TEXT(), config(), OpenDDS::DCPS::TcpDataLink::connect(), DBG_ENTRY_LVL, OpenDDS::DCPS::DCPS_debug_level, last_link_, LM_DEBUG, OpenDDS::DCPS::Atomic< T >::load(), OpenDDS::DCPS::TransportImpl::reactor_task(), OpenDDS::DCPS::ref(), OpenDDS::DCPS::TcpDataLink::reuse_existing_connection(), and OpenDDS::DCPS::DataLink::transport_priority().
Referenced by accept_datalink(), OpenDDS::DCPS::TcpConnection::active_open(), passive_connection(), and OpenDDS::DCPS::TcpDataLink::reconnect().
|
privatevirtual |
Called by our connection_info() method to allow the concrete TransportImpl subclass to do the dirty work since it really is the one that knows how to populate the supplied TransportLocator object.
Implements OpenDDS::DCPS::TransportImpl.
Definition at line 470 of file TcpTransport.cpp.
References config(), DBG_ENTRY_LVL, LM_DEBUG, and VDBG_LVL.
|
private |
Definition at line 189 of file TcpTransport.cpp.
References ACE_TEXT(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), OpenDDS::DCPS::DataLink::cancel_release(), DBG_ENTRY_LVL, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), OpenDDS::DCPS::RcHandle< T >::in(), links_, LM_DEBUG, pending_release_links_, OpenDDS::DCPS::RcHandle< T >::reset(), OpenDDS::DCPS::TcpDataLink::set_release_pending(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(), and VDBG_LVL.
Referenced by accept_datalink(), and connect_datalink().
int OpenDDS::DCPS::TcpTransport::fresh_link | ( | TcpConnection_rch | connection | ) |
This function is called by the TcpReconnectTask thread to check if the passively accepted connection is the re-established connection. If it is, then the "old" connection object in the datalink is replaced by the "new" connection object.
Definition at line 719 of file TcpTransport.cpp.
References config(), DBG_ENTRY_LVL, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), OpenDDS::DCPS::TcpDataLink::get_connection(), OpenDDS::DCPS::RcHandle< T >::in(), OpenDDS::DCPS::RcHandle< T >::is_nil(), OpenDDS::DCPS::TransportImpl::is_shut_down(), links_, links_lock_, and OpenDDS::DCPS::TcpDataLink::reconnect().
Referenced by passive_connection().
|
private |
|
private |
|
private |
Called by the TcpConnection object when it has been created by the acceptor and needs to be attached to a DataLink. The DataLink may or may not already be created and waiting for this passive connection to appear.
This method is called by a TcpConnection object that has been created and opened by our acceptor_ as a result of passively accepting a connection on our local address. Ultimately, the connection object needs to be paired with a DataLink object that is (or will be) expecting this passive connection to be established.
Definition at line 600 of file TcpTransport.cpp.
References ACE_ERROR, ACE_TEXT(), config(), connect_tcp_datalink(), connections_, connections_lock_, DBG_ENTRY_LVL, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), fresh_link(), OpenDDS::DCPS::RcHandle< T >::is_nil(), OpenDDS::DCPS::TransportImpl::is_shut_down(), links_, links_lock_, LM_DEBUG, LM_ERROR, ACE_Guard< ACE_LOCK >::release(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(), and VDBG_LVL.
Referenced by OpenDDS::DCPS::TcpConnection::handle_setup_input().
|
privatevirtual |
Called by the DataLink to release itself.
Implements OpenDDS::DCPS::TransportImpl.
Definition at line 487 of file TcpTransport.cpp.
References ACE_DEBUG, ACE_ERROR, ACE_TEXT(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), OpenDDS::DCPS::DataLink::datalink_release_delay(), DBG_ENTRY_LVL, OpenDDS::DCPS::DCPS_debug_level, OpenDDS::DCPS::RcHandle< T >::in(), OpenDDS::DCPS::DataLink::is_active(), OpenDDS::DCPS::DataLink::is_loopback(), links_, links_lock_, LM_DEBUG, LM_ERROR, OpenDDS::DCPS::TimePoint_T< MonotonicClock >::now(), pending_release_links_, OpenDDS::DCPS::TcpDataLink::remote_address(), OpenDDS::DCPS::DataLink::schedule_delayed_release(), OpenDDS::DCPS::DataLink::schedule_stop(), OpenDDS::DCPS::TcpDataLink::set_release_pending(), OpenDDS::DCPS::DataLink::set_scheduling_release(), OpenDDS::DCPS::TimeDuration::str(), OpenDDS::DCPS::DataLink::transport_priority(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(), VDBG_LVL, and OpenDDS::DCPS::TimeDuration::zero_value.
|
privatevirtual |
Called during the shutdown() method in order to give the concrete TransportImpl subclass a chance to do something when the shutdown "event" occurs.
Implements OpenDDS::DCPS::TransportImpl.
Definition at line 406 of file TcpTransport.cpp.
References acceptor_, connections_, connections_lock_, DBG_ENTRY_LVL, ACE_Hash_Map_Entry< EXT_ID, INT_ID >::int_id_, links_, links_lock_, ACE_Hash_Map_Iterator_Base_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::next(), OpenDDS::DCPS::TransportImpl::pending_connections_, OpenDDS::DCPS::TransportImpl::pending_connections_lock_, pending_release_links_, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind_all().
|
privatevirtual |
stop_accepting_or_connecting() is called from TransportClient to terminate the accepting process begun by accept_datalink() or connect_datalink(). This allows the TransportImpl to clean up any resources associated with this pending connection. The TransportClient* passed in to accept or connect is not valid after this method is called.
Implements OpenDDS::DCPS::TransportImpl.
Definition at line 297 of file TcpTransport.cpp.
References LM_DEBUG, OpenDDS::DCPS::TransportImpl::pending_connections_, OpenDDS::DCPS::TransportImpl::pending_connections_lock_, and VDBG_LVL.
|
inlineprivatevirtual |
Implements OpenDDS::DCPS::TransportImpl.
Definition at line 86 of file TcpTransport.h.
|
virtual |
Remove any pending_release mappings.
Reimplemented from OpenDDS::DCPS::TransportImpl.
Definition at line 761 of file TcpTransport.cpp.
References ACE_ERROR, OpenDDS::DCPS::DataLink::datalink_release_delay(), OpenDDS::DCPS::DataLink::is_active(), OpenDDS::DCPS::DataLink::is_loopback(), OpenDDS::DCPS::TimeDuration::is_zero(), links_lock_, LM_DEBUG, LM_ERROR, pending_release_links_, OpenDDS::DCPS::TcpDataLink::remote_address(), OpenDDS::DCPS::DataLink::transport_priority(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(), and VDBG_LVL.
|
friend |
The TcpConnection is our friend. It tells us when it has been created (by our acceptor_), and is seeking the DataLink that should be (or will be) expecting the passive connection.
Definition at line 94 of file TcpTransport.h.
|
friend |
Definition at line 95 of file TcpTransport.h.
|
private |
Used to accept passive connections on our local_address_.
Definition at line 144 of file TcpTransport.h.
Referenced by configure_i(), and shutdown_i().
|
private |
Map of passive connection objects that need to be paired with a DataLink.
Definition at line 163 of file TcpTransport.h.
Referenced by accept_datalink(), passive_connection(), and shutdown_i().
|
private |
This protects the connections_ and the pending_connections_ data members.
Definition at line 167 of file TcpTransport.h.
Referenced by accept_datalink(), passive_connection(), and shutdown_i().
|
private |
Open TcpConnections using non-blocking connect.
Definition at line 152 of file TcpTransport.h.
Referenced by OpenDDS::DCPS::TcpConnection::active_reconnect_i(), OpenDDS::DCPS::TcpConnection::close(), configure_i(), connect_datalink(), and OpenDDS::DCPS::TcpConnection::handle_timeout().
|
private |
Definition at line 168 of file TcpTransport.h.
Referenced by connect_tcp_datalink().
|
private |
This is the map of connected DataLinks.
Definition at line 155 of file TcpTransport.h.
Referenced by accept_datalink(), async_connect_failed(), client_stop(), connect_datalink(), find_datalink_i(), fresh_link(), passive_connection(), release_datalink(), and shutdown_i().
|
private |
This lock is used to protect the links_ data member.
Definition at line 159 of file TcpTransport.h.
Referenced by accept_datalink(), async_connect_failed(), client_stop(), connect_datalink(), fresh_link(), passive_connection(), release_datalink(), shutdown_i(), and unbind_link().
|
private |
Definition at line 156 of file TcpTransport.h.
Referenced by client_stop(), find_datalink_i(), release_datalink(), shutdown_i(), and unbind_link().