Skip to content

Commit 5c52305

Browse files
committed
Refs #24015: Remove unused keep_alive logic
Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
1 parent 74adc61 commit 5c52305

5 files changed

Lines changed: 4 additions & 91 deletions

File tree

src/cpp/rtps/transport/TCPChannelResource.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ TCPChannelResource::TCPChannelResource(
5353
: ChannelResource(maxMsgSize)
5454
, parent_ (parent)
5555
, locator_(locator)
56-
, waiting_for_keep_alive_(false)
5756
, connection_status_(eConnectionStatus::eDisconnected)
5857
, tcp_connection_type_(TCPConnectionType::TCP_CONNECT_TYPE)
5958
{
@@ -65,7 +64,6 @@ TCPChannelResource::TCPChannelResource(
6564
: ChannelResource(maxMsgSize)
6665
, parent_(parent)
6766
, locator_()
68-
, waiting_for_keep_alive_(false)
6967
, connection_status_(eConnectionStatus::eDisconnected)
7068
, tcp_connection_type_(TCPConnectionType::TCP_ACCEPT_TYPE)
7169
{
@@ -196,7 +194,6 @@ void TCPChannelResource::add_logical_port(
196194
}
197195
}
198196
}
199-
200197
}
201198

202199
void TCPChannelResource::send_pending_open_logical_ports(

src/cpp/rtps/transport/TCPChannelResource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class TCPChannelResource : public ChannelResource
6565

6666
TCPTransportInterface* parent_;
6767
Locator locator_;
68-
bool waiting_for_keep_alive_;
6968
// Must be accessed after lock pending_logical_mutex_
7069
std::map<TCPTransactionId, uint16_t> negotiating_logical_ports_;
7170
std::map<TCPTransactionId, uint16_t> last_checked_logical_port_;

src/cpp/rtps/transport/TCPTransportInterface.cpp

Lines changed: 3 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,10 @@ namespace rtps {
7777

7878
using Log = fastdds::dds::Log;
7979

80-
static const int s_default_keep_alive_frequency = 5000; // 5 SECONDS
81-
static const int s_default_keep_alive_timeout = 15000; // 15 SECONDS
82-
//static const int s_clean_deleted_sockets_pool_timeout = 100; // 100 MILLISECONDS
83-
8480
TCPTransportDescriptor::TCPTransportDescriptor()
8581
: SocketTransportDescriptor(s_maximumMessageSize, s_maximumInitialPeersRange)
86-
, keep_alive_frequency_ms(s_default_keep_alive_frequency)
87-
, keep_alive_timeout_ms(s_default_keep_alive_timeout)
82+
, keep_alive_frequency_ms(0)
83+
, keep_alive_timeout_ms(0)
8884
, max_logical_port(100)
8985
, logical_port_range(20)
9086
, logical_port_increment(2)
@@ -168,7 +164,6 @@ TCPTransportInterface::TCPTransportInterface(
168164
#if TLS_FOUND
169165
, ssl_context_(asio::ssl::context::sslv23)
170166
#endif // if TLS_FOUND
171-
, keep_alive_event_(io_context_timers_)
172167
{
173168
}
174169

@@ -181,13 +176,6 @@ void TCPTransportInterface::clean()
181176
assert(receiver_resources_.size() == 0);
182177
alive_.store(false);
183178

184-
keep_alive_event_.cancel();
185-
if (io_context_timers_thread_.joinable())
186-
{
187-
io_context_timers_.stop();
188-
io_context_timers_thread_.join();
189-
}
190-
191179
{
192180
std::vector<std::shared_ptr<TCPChannelResource>> channels;
193181
std::vector<eprosima::fastdds::rtps::Locator> delete_channels;
@@ -583,14 +571,7 @@ bool TCPTransportInterface::init(
583571

584572
if (0 < configuration()->keep_alive_frequency_ms)
585573
{
586-
auto ioContextTimersFunction = [&]()
587-
{
588-
asio::executor_work_guard<asio::io_context::executor_type> work = make_work_guard(io_context_timers_.
589-
get_executor());
590-
io_context_timers_.run();
591-
};
592-
io_context_timers_thread_ = create_thread(ioContextTimersFunction,
593-
configuration()->keep_alive_thread, "dds.tcp_keep");
574+
EPROSIMA_LOG_WARNING(RTCP, "Keep alive feature only available in Fast DDS Pro.");
594575
}
595576

596577
return true;
@@ -1075,64 +1056,6 @@ bool TCPTransportInterface::OpenInputChannel(
10751056
return success;
10761057
}
10771058

1078-
void TCPTransportInterface::keep_alive()
1079-
{
1080-
std::map<Locator, std::shared_ptr<TCPChannelResource>> tmp_vec;
1081-
1082-
{
1083-
std::unique_lock<std::mutex> scopedLock(sockets_map_mutex_); // Why mutex here?
1084-
tmp_vec = channel_resources_;
1085-
}
1086-
1087-
1088-
for (auto& channel_resource : tmp_vec)
1089-
{
1090-
if (TCPChannelResource::TCPConnectionType::TCP_CONNECT_TYPE == channel_resource.second->tcp_connection_type())
1091-
{
1092-
rtcp_message_manager_->sendKeepAliveRequest(channel_resource.second);
1093-
}
1094-
}
1095-
//TODO Check timeout.
1096-
1097-
/*
1098-
const TCPTransportDescriptor* config = configuration(); // Keep a copy for us.
1099-
1100-
std::chrono::time_point<std::chrono::system_clock> time_now = std::chrono::system_clock::now();
1101-
std::chrono::time_point<std::chrono::system_clock> next_time = time_now +
1102-
std::chrono::milliseconds(config->keep_alive_frequency_ms);
1103-
std::chrono::time_point<std::chrono::system_clock> timeout_time =
1104-
time_now + std::chrono::milliseconds(config->keep_alive_timeout_ms);
1105-
1106-
while (channel && TCPChannelResource::TCPConnectionStatus::TCP_CONNECTED == channel->tcp_connection_status())
1107-
{
1108-
if (channel->connection_established())
1109-
{
1110-
// KeepAlive
1111-
if (config->keep_alive_frequency_ms > 0 && config->keep_alive_timeout_ms > 0)
1112-
{
1113-
time_now = std::chrono::system_clock::now();
1114-
1115-
// Keep Alive Management
1116-
if (!channel->waiting_for_keep_alive_ && time_now > next_time)
1117-
{
1118-
std::unique_lock<std::mutex> scopedLock(sockets_map_mutex_); // Why mutex here?
1119-
rtcp_message_manager_->sendKeepAliveRequest(channel);
1120-
channel->waiting_for_keep_alive_ = true;
1121-
next_time = time_now + std::chrono::milliseconds(config->keep_alive_frequency_ms);
1122-
timeout_time = time_now + std::chrono::milliseconds(config->keep_alive_timeout_ms);
1123-
}
1124-
else if (channel->waiting_for_keep_alive_ && time_now >= timeout_time)
1125-
{
1126-
// Disable the socket to erase it after the reception.
1127-
close_tcp_socket(channel);
1128-
}
1129-
}
1130-
}
1131-
}
1132-
EPROSIMA_LOG_INFO(RTCP, "End perform_rtcp_management_thread " << channel->locator());
1133-
*/
1134-
}
1135-
11361059
void TCPTransportInterface::create_listening_thread(
11371060
const std::shared_ptr<TCPChannelResource>& channel)
11381061
{

src/cpp/rtps/transport/TCPTransportInterface.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class TCPTransportInterface : public TransportInterface
9696
asio::ssl::context ssl_context_;
9797
#endif // if TLS_FOUND
9898
eprosima::thread io_context_thread_;
99-
eprosima::thread io_context_timers_thread_;
10099
std::shared_ptr<RTCPMessageManager> rtcp_message_manager_;
101100
std::mutex rtcp_message_manager_mutex_;
102101
std::condition_variable rtcp_message_manager_cv_;
@@ -112,8 +111,6 @@ class TCPTransportInterface : public TransportInterface
112111

113112
std::vector<std::pair<TCPChannelResource*, uint64_t>> sockets_timestamp_;
114113

115-
asio::steady_timer keep_alive_event_;
116-
117114
std::map<Locator, std::shared_ptr<TCPAcceptor>> acceptors_;
118115

119116
eprosima::fastdds::statistics::rtps::OutputTrafficManager statistics_info_;
@@ -497,8 +494,6 @@ class TCPTransportInterface : public TransportInterface
497494

498495
virtual TCPTransportDescriptor* configuration() = 0;
499496

500-
void keep_alive();
501-
502497
void update_network_interfaces() override;
503498

504499
bool is_localhost_allowed() const override;

src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ ResponseCode RTCPMessageManager::processOpenLogicalPortResponse(
645645
}
646646

647647
ResponseCode RTCPMessageManager::processKeepAliveResponse(
648-
std::shared_ptr<TCPChannelResource>& channel,
648+
std::shared_ptr<TCPChannelResource>& /*channel*/,
649649
ResponseCode respCode,
650650
const TCPTransactionId& transaction_id)
651651
{
@@ -654,7 +654,6 @@ ResponseCode RTCPMessageManager::processKeepAliveResponse(
654654
switch (respCode)
655655
{
656656
case RETCODE_OK:
657-
channel->waiting_for_keep_alive_ = false;
658657
break;
659658
case RETCODE_UNKNOWN_LOCATOR:
660659
return RETCODE_UNKNOWN_LOCATOR;

0 commit comments

Comments
 (0)