Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
MiguelCompany committed Jun 26, 2024
1 parent c27efd7 commit 6f43c32
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 179 deletions.
8 changes: 4 additions & 4 deletions src/cpp/rtps/transport/TCPChannelResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@ void TCPChannelResource::set_socket_options(
if (!asio_helpers::try_setting_buffer_size<asio::socket_base::send_buffer_size>(
socket, desired_value, minimum_value, configured_value))
{
EPROSIMA_LOG_ERROR(TCP_TRANSPORT,
logError(TCP_TRANSPORT,
"Couldn't set send buffer size to minimum value: " << minimum_value);
}
else if (desired_value != configured_value)
{
EPROSIMA_LOG_WARNING(TCP_TRANSPORT,
logWarning(TCP_TRANSPORT,
"Couldn't set send buffer size to desired value. "
<< "Using " << configured_value << " instead of " << desired_value);
}
Expand All @@ -402,12 +402,12 @@ void TCPChannelResource::set_socket_options(
if (!asio_helpers::try_setting_buffer_size<asio::socket_base::receive_buffer_size>(
socket, desired_value, minimum_value, configured_value))
{
EPROSIMA_LOG_ERROR(TCP_TRANSPORT,
logError(TCP_TRANSPORT,
"Couldn't set receive buffer size to minimum value: " << minimum_value);
}
else if (desired_value != configured_value)
{
EPROSIMA_LOG_WARNING(TCP_TRANSPORT,
logWarning(TCP_TRANSPORT,
"Couldn't set receive buffer size to desired value. "
<< "Using " << configured_value << " instead of " << desired_value);
}
Expand Down
63 changes: 9 additions & 54 deletions src/cpp/rtps/transport/TCPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@

#include <rtps/transport/TCPTransportInterface.h>

<<<<<<< HEAD
#include <utility>
#include <cstring>
#include <algorithm>
#include <chrono>
#include <thread>
=======
#include <algorithm>
#include <cstring>
#include <chrono>
#include <limits>
#include <set>
#include <thread>
#include <utility>
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))

#include <asio/steady_timer.hpp>
#include <fastdds/dds/log/Log.hpp>
Expand Down Expand Up @@ -385,31 +378,31 @@ bool TCPTransportInterface::init(

if (cfg_max_msg_size > maximumMessageSize)
{
EPROSIMA_LOG_ERROR(TRANSPORT_TCP, "maxMessageSize cannot be greater than " << maximumMessageSize);
logError(TRANSPORT_TCP, "maxMessageSize cannot be greater than " << maximumMessageSize);
return false;
}

if (cfg_send_size > max_int_value)
{
EPROSIMA_LOG_ERROR(TRANSPORT_TCP, "sendBufferSize cannot be greater than " << max_int_value);
logError(TRANSPORT_TCP, "sendBufferSize cannot be greater than " << max_int_value);
return false;
}

if (cfg_recv_size > max_int_value)
{
EPROSIMA_LOG_ERROR(TRANSPORT_TCP, "receiveBufferSize cannot be greater than " << max_int_value);
logError(TRANSPORT_TCP, "receiveBufferSize cannot be greater than " << max_int_value);
return false;
}

if ((cfg_send_size > 0) && (cfg_max_msg_size > cfg_send_size))
{
EPROSIMA_LOG_ERROR(TRANSPORT_TCP, "maxMessageSize cannot be greater than sendBufferSize");
logError(TRANSPORT_TCP, "maxMessageSize cannot be greater than sendBufferSize");
return false;
}

if ((cfg_recv_size > 0) && (cfg_max_msg_size > cfg_recv_size))
{
EPROSIMA_LOG_ERROR(TRANSPORT_TCP, "maxMessageSize cannot be greater than receiveBufferSize");
logError(TRANSPORT_TCP, "maxMessageSize cannot be greater than receiveBufferSize");
return false;
}

Expand Down Expand Up @@ -450,58 +443,20 @@ bool TCPTransportInterface::init(
if (!asio_helpers::configure_buffer_sizes(
*initial_peer_local_locator_socket_, *configuration(), send_size, recv_size))
{
<<<<<<< HEAD
socket_base::send_buffer_size option;
initial_peer_local_locator_socket_->get_option(option);
set_send_buffer_size(option.value());

if (configuration()->sendBufferSize < s_minimumSocketBuffer)
{
set_send_buffer_size(s_minimumSocketBuffer);
}
}

if (configuration()->receiveBufferSize == 0)
{
socket_base::receive_buffer_size option;
initial_peer_local_locator_socket_->get_option(option);
set_receive_buffer_size(option.value());

if (configuration()->receiveBufferSize < s_minimumSocketBuffer)
{
set_receive_buffer_size(s_minimumSocketBuffer);
}
}

if (configuration()->maxMessageSize > s_maximumMessageSize)
{
logError(RTCP_MSG_OUT, "maxMessageSize cannot be greater than 65000");
=======
EPROSIMA_LOG_ERROR(TRANSPORT_TCP, "Couldn't set buffer sizes to minimum value: " << cfg_max_msg_size);
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
logError(TRANSPORT_TCP, "Couldn't set buffer sizes to minimum value: " << cfg_max_msg_size);
return false;
}

if (cfg_send_size > 0 && send_size != cfg_send_size)
{
<<<<<<< HEAD
logError(RTCP_MSG_OUT, "maxMessageSize cannot be greater than send_buffer_size");
return false;
=======
EPROSIMA_LOG_WARNING(TRANSPORT_TCP, "UDPTransport sendBufferSize could not be set to the desired value. "
logWarning(TRANSPORT_TCP, "UDPTransport sendBufferSize could not be set to the desired value. "
<< "Using " << send_size << " instead of " << cfg_send_size);
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
}

if (cfg_recv_size > 0 && recv_size != cfg_recv_size)
{
<<<<<<< HEAD
logError(RTCP_MSG_OUT, "maxMessageSize cannot be greater than receive_buffer_size");
return false;
=======
EPROSIMA_LOG_WARNING(TRANSPORT_TCP, "UDPTransport receiveBufferSize could not be set to the desired value. "
logWarning(TRANSPORT_TCP, "UDPTransport receiveBufferSize could not be set to the desired value. "
<< "Using " << recv_size << " instead of " << cfg_recv_size);
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
}

set_send_buffer_size(send_size);
Expand Down
117 changes: 19 additions & 98 deletions src/cpp/rtps/transport/UDPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,76 +130,31 @@ bool UDPTransportInterface::init(

if (cfg_max_msg_size > maximumMessageSize)
{
<<<<<<< HEAD
// Check system buffer sizes.
ip::udp::socket socket(io_service_);
socket.open(generate_protocol());

if (configuration()->sendBufferSize == 0)
{
socket_base::send_buffer_size option;
socket.get_option(option);
set_send_buffer_size(static_cast<uint32_t>(option.value()));

if (configuration()->sendBufferSize < s_minimumSocketBuffer)
{
set_send_buffer_size(s_minimumSocketBuffer);
mSendBufferSize = s_minimumSocketBuffer;
}
}

if (configuration()->receiveBufferSize == 0)
{
socket_base::receive_buffer_size option;
socket.get_option(option);
set_receive_buffer_size(static_cast<uint32_t>(option.value()));

if (configuration()->receiveBufferSize < s_minimumSocketBuffer)
{
set_receive_buffer_size(s_minimumSocketBuffer);
mReceiveBufferSize = s_minimumSocketBuffer;
}
}
}

if (configuration()->maxMessageSize > s_maximumMessageSize)
{
logError(RTPS_MSG_OUT, "maxMessageSize cannot be greater than 65000");
=======
EPROSIMA_LOG_ERROR(TRANSPORT_UDP, "maxMessageSize cannot be greater than " << maximumMessageSize);
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
logError(TRANSPORT_UDP, "maxMessageSize cannot be greater than " << maximumMessageSize);
return false;
}

if (cfg_send_size > max_int_value)
{
<<<<<<< HEAD
logError(RTPS_MSG_OUT, "maxMessageSize cannot be greater than send_buffer_size");
=======
EPROSIMA_LOG_ERROR(TRANSPORT_UDP, "sendBufferSize cannot be greater than " << max_int_value);
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
logError(TRANSPORT_UDP, "sendBufferSize cannot be greater than " << max_int_value);
return false;
}

if (cfg_recv_size > max_int_value)
{
<<<<<<< HEAD
logError(RTPS_MSG_OUT, "maxMessageSize cannot be greater than receive_buffer_size");
=======
EPROSIMA_LOG_ERROR(TRANSPORT_UDP, "receiveBufferSize cannot be greater than " << max_int_value);
logError(TRANSPORT_UDP, "receiveBufferSize cannot be greater than " << max_int_value);
return false;
}

if ((cfg_send_size > 0) && (cfg_max_msg_size > cfg_send_size))
{
EPROSIMA_LOG_ERROR(TRANSPORT_UDP, "maxMessageSize cannot be greater than sendBufferSize");
logError(TRANSPORT_UDP, "maxMessageSize cannot be greater than sendBufferSize");
return false;
}

if ((cfg_recv_size > 0) && (cfg_max_msg_size > cfg_recv_size))
{
EPROSIMA_LOG_ERROR(TRANSPORT_UDP, "maxMessageSize cannot be greater than receiveBufferSize");
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
logError(TRANSPORT_UDP, "maxMessageSize cannot be greater than receiveBufferSize");
return false;
}

Expand All @@ -211,7 +166,7 @@ bool UDPTransportInterface::init(
socket.open(generate_protocol(), ec);
if (!!ec)
{
EPROSIMA_LOG_ERROR(TRANSPORT_UDP, "Error creating socket: " << ec.message());
logError(TRANSPORT_UDP, "Error creating socket: " << ec.message());
return false;
}

Expand All @@ -220,13 +175,13 @@ bool UDPTransportInterface::init(
{
if (cfg_send_size > 0 && mSendBufferSize != cfg_send_size)
{
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, "UDPTransport sendBufferSize could not be set to the desired value. "
logWarning(TRANSPORT_UDP, "UDPTransport sendBufferSize could not be set to the desired value. "
<< "Using " << mSendBufferSize << " instead of " << cfg_send_size);
}

if (cfg_recv_size > 0 && mReceiveBufferSize != cfg_recv_size)
{
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, "UDPTransport receiveBufferSize could not be set to the desired value. "
logWarning(TRANSPORT_UDP, "UDPTransport receiveBufferSize could not be set to the desired value. "
<< "Using " << mReceiveBufferSize << " instead of " << cfg_recv_size);
}

Expand All @@ -235,7 +190,7 @@ bool UDPTransportInterface::init(
}
else
{
EPROSIMA_LOG_ERROR(TRANSPORT_UDP, "Couldn't set buffer sizes to minimum value: " << cfg_max_msg_size);
logError(TRANSPORT_UDP, "Couldn't set buffer sizes to minimum value: " << cfg_max_msg_size);
}

return ret;
Expand Down Expand Up @@ -276,13 +231,8 @@ bool UDPTransportInterface::OpenAndBindInputSockets(
catch (asio::system_error const& e)
{
(void)e;
<<<<<<< HEAD
logInfo(RTPS_MSG_OUT, "UDPTransport Error binding at port: (" << IPLocator::getPhysicalPort(locator) << ")"
<< " with msg: " << e.what());
=======
EPROSIMA_LOG_INFO(TRANSPORT_UDP, "UDPTransport Error binding at port: ("
logInfo(TRANSPORT_UDP, "UDPTransport Error binding at port: ("
<< IPLocator::getPhysicalPort(locator) << ")" << " with msg: " << e.what());
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
mInputSockets.erase(IPLocator::getPhysicalPort(locator));
return false;
}
Expand Down Expand Up @@ -316,12 +266,12 @@ eProsimaUDPSocket UDPTransportInterface::OpenAndBindUnicastOutputSocket(
if (!asio_helpers::try_setting_buffer_size<socket_base::send_buffer_size>(
socket, mSendBufferSize, configuration()->maxMessageSize, configured_value))
{
EPROSIMA_LOG_ERROR(TRANSPORT_UDP,
logError(TRANSPORT_UDP,
"Couldn't set send buffer size to minimum value: " << configuration()->maxMessageSize);
}
else if (configured_value != mSendBufferSize)
{
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, "UDPTransport sendBufferSize could not be set to the desired value. "
logWarning(TRANSPORT_UDP, "UDPTransport sendBufferSize could not be set to the desired value. "
<< "Using " << configured_value << " instead of " << mSendBufferSize);
}
}
Expand Down Expand Up @@ -381,11 +331,7 @@ bool UDPTransportInterface::OpenOutputChannel(
catch (asio::system_error const& e)
{
(void)e;
<<<<<<< HEAD
logWarning(RTPS_MSG_OUT, "UDPTransport Error binding interface "
=======
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, "UDPTransport Error binding interface "
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
logWarning(TRANSPORT_UDP, "UDPTransport Error binding interface "
<< localhost_name() << " (skipping) with msg: " << e.what());
}
}
Expand All @@ -409,11 +355,7 @@ bool UDPTransportInterface::OpenOutputChannel(
catch (asio::system_error const& e)
{
(void)e;
<<<<<<< HEAD
logWarning(RTPS_MSG_OUT, "UDPTransport Error binding interface "
=======
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, "UDPTransport Error binding interface "
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
logWarning(TRANSPORT_UDP, "UDPTransport Error binding interface "
<< (*locIt).name << " (skipping) with msg: " << e.what());
}
}
Expand Down Expand Up @@ -445,11 +387,7 @@ bool UDPTransportInterface::OpenOutputChannel(
{
(void)e;
/* TODO Que hacer?
<<<<<<< HEAD
logError(RTPS_MSG_OUT, "UDPTransport Error binding at port: (" << IPLocator::getPhysicalPort(locator) << ")"
=======
EPROSIMA_LOG_ERROR(TRANSPORT_UDP, "UDPTransport Error binding at port: (" << IPLocator::getPhysicalPort(locator) << ")"
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
logError(TRANSPORT_UDP, "UDPTransport Error binding at port: (" << IPLocator::getPhysicalPort(locator) << ")"
<< " with msg: " << e.what());
for (auto& socket : mOutputSockets)
{
Expand Down Expand Up @@ -594,41 +532,24 @@ bool UDPTransportInterface::send(
if ((ec.value() == asio::error::would_block) ||
(ec.value() == asio::error::try_again))
{
<<<<<<< HEAD
logWarning(RTPS_MSG_OUT, "UDP send would have blocked. Packet is dropped.");
return true;
}

logWarning(RTPS_MSG_OUT, ec.message());
=======
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, "UDP send would have blocked. Packet is dropped.");
logWarning(TRANSPORT_UDP, "UDP send would have blocked. Packet is dropped.");
return true;
}

EPROSIMA_LOG_WARNING(TRANSPORT_UDP, ec.message());
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
logWarning(TRANSPORT_UDP, ec.message());
return false;
}
}
catch (const std::exception& error)
{
<<<<<<< HEAD
logWarning(RTPS_MSG_OUT, error.what());
=======
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, error.what());
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
logWarning(TRANSPORT_UDP, error.what());
return false;
}

(void)bytesSent;
<<<<<<< HEAD
logInfo(RTPS_MSG_OUT, "UDPTransport: " << bytesSent << " bytes TO endpoint: " << destinationEndpoint
<< " FROM " << getSocketPtr(socket)->local_endpoint());
=======
EPROSIMA_LOG_INFO(TRANSPORT_UDP,
logInfo(TRANSPORT_UDP,
"UDPTransport: " << bytesSent << " bytes TO endpoint: " << destinationEndpoint <<
" FROM " << getSocketPtr(socket)->local_endpoint());
>>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795))
success = true;
}

Expand Down
Loading

0 comments on commit 6f43c32

Please sign in to comment.