diff --git a/src/cpp/rtps/transport/TCPChannelResource.cpp b/src/cpp/rtps/transport/TCPChannelResource.cpp index ff8a9326a8c..2ae5b99ada2 100644 --- a/src/cpp/rtps/transport/TCPChannelResource.cpp +++ b/src/cpp/rtps/transport/TCPChannelResource.cpp @@ -384,12 +384,12 @@ void TCPChannelResource::set_socket_options( if (!asio_helpers::try_setting_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); } @@ -402,12 +402,12 @@ void TCPChannelResource::set_socket_options( if (!asio_helpers::try_setting_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); } diff --git a/src/cpp/rtps/transport/TCPTransportInterface.cpp b/src/cpp/rtps/transport/TCPTransportInterface.cpp index 75cbb7e1b3d..55f8b2b794c 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.cpp +++ b/src/cpp/rtps/transport/TCPTransportInterface.cpp @@ -14,20 +14,13 @@ #include -<<<<<<< HEAD -#include -#include -#include -#include -#include -======= #include #include #include #include #include +#include #include ->>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795)) #include #include @@ -419,31 +412,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; } @@ -484,58 +477,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); diff --git a/src/cpp/rtps/transport/UDPTransportInterface.cpp b/src/cpp/rtps/transport/UDPTransportInterface.cpp index 1e824bfeae3..f63f24f0fb8 100644 --- a/src/cpp/rtps/transport/UDPTransportInterface.cpp +++ b/src/cpp/rtps/transport/UDPTransportInterface.cpp @@ -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(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(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; } @@ -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; } @@ -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); } @@ -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; @@ -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; } @@ -316,12 +266,12 @@ eProsimaUDPSocket UDPTransportInterface::OpenAndBindUnicastOutputSocket( if (!asio_helpers::try_setting_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); } } @@ -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()); } } @@ -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()); } } @@ -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) { @@ -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; } diff --git a/src/cpp/rtps/transport/UDPv4Transport.cpp b/src/cpp/rtps/transport/UDPv4Transport.cpp index 7f33f287f4b..63214acdfb3 100644 --- a/src/cpp/rtps/transport/UDPv4Transport.cpp +++ b/src/cpp/rtps/transport/UDPv4Transport.cpp @@ -26,12 +26,8 @@ #include #include -<<<<<<< HEAD -======= -#include #include ->>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795)) using namespace std; using namespace asio; @@ -304,12 +300,12 @@ eProsimaUDPSocket UDPv4Transport::OpenAndBindInputSocket( if (!asio_helpers::try_setting_buffer_size( socket, mReceiveBufferSize, minimum_value, configured_value)) { - EPROSIMA_LOG_ERROR(TRANSPORT_UDPV4, + logError(TRANSPORT_UDPV4, "Couldn't set receive buffer size to minimum value: " << minimum_value); } else if (mReceiveBufferSize != configured_value) { - EPROSIMA_LOG_WARNING(TRANSPORT_UDPV4, + logWarning(TRANSPORT_UDPV4, "Receive buffer size could not be set to the desired value. " << "Using " << configured_value << " instead of " << mReceiveBufferSize); } diff --git a/src/cpp/rtps/transport/UDPv6Transport.cpp b/src/cpp/rtps/transport/UDPv6Transport.cpp index b020e05e5f0..0815008af1c 100644 --- a/src/cpp/rtps/transport/UDPv6Transport.cpp +++ b/src/cpp/rtps/transport/UDPv6Transport.cpp @@ -304,12 +304,12 @@ eProsimaUDPSocket UDPv6Transport::OpenAndBindInputSocket( if (!asio_helpers::asio_helpers::try_setting_buffer_size( socket, mReceiveBufferSize, minimum_value, configured_value)) { - EPROSIMA_LOG_ERROR(TRANSPORT_UDPV6, + logError(TRANSPORT_UDPV6, "Couldn't set receive buffer size to minimum value: " << minimum_value); } else if (mReceiveBufferSize != configured_value) { - EPROSIMA_LOG_WARNING(TRANSPORT_UDPV6, + logWarning(TRANSPORT_UDPV6, "Receive buffer size could not be set to the desired value. " << "Using " << configured_value << " instead of " << mReceiveBufferSize); } diff --git a/test/unittest/transport/TCPv6Tests.cpp b/test/unittest/transport/TCPv6Tests.cpp index 046a62924a5..be1a4f4b2d2 100644 --- a/test/unittest/transport/TCPv6Tests.cpp +++ b/test/unittest/transport/TCPv6Tests.cpp @@ -12,13 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -<<<<<<< HEAD -======= #include #include ->>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795)) #include -#include #include #include diff --git a/test/unittest/transport/UDPv4Tests.cpp b/test/unittest/transport/UDPv4Tests.cpp index 932058332f9..e26b885f00b 100644 --- a/test/unittest/transport/UDPv4Tests.cpp +++ b/test/unittest/transport/UDPv4Tests.cpp @@ -12,22 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -<<<<<<< HEAD -======= #include #include ->>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795)) #include -#include #include #include -<<<<<<< HEAD + #include -======= #include ->>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795)) #include #include #include diff --git a/test/unittest/transport/UDPv6Tests.cpp b/test/unittest/transport/UDPv6Tests.cpp index 20f310a19d6..6954a0cd24c 100644 --- a/test/unittest/transport/UDPv6Tests.cpp +++ b/test/unittest/transport/UDPv6Tests.cpp @@ -12,13 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -<<<<<<< HEAD -======= #include #include ->>>>>>> 532acfa74 (Handle errors when setting socket buffer sizes (#4760) (#4795)) #include -#include #include #include