Skip to content

Commit

Permalink
Refs #5142 Fixing WAN and added GTEST check on compiling TMutexTests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisGP authored and richiware committed Apr 24, 2019
1 parent 8c1dccc commit 459a4c1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
31 changes: 25 additions & 6 deletions src/cpp/transport/TCPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,32 @@ bool TCPTransportInterface::send(
std::shared_ptr<TCPChannelResource>& channel,
const Locator_t& remote_locator)
{
if (channel->locator() != IPLocator::toPhysicalLocator(remote_locator) ||
send_buffer_size > configuration()->sendBufferSize)
bool locator_mismatch = false;

if (channel->locator() != IPLocator::toPhysicalLocator(remote_locator))
{
locator_mismatch = true;
}

// Maybe is WAN?
if (locator_mismatch && IPLocator::hasWan(remote_locator))
{
Locator_t wan_locator;
wan_locator.kind = remote_locator.kind;
wan_locator.port = IPLocator::toPhysicalLocator(remote_locator).port;
IPLocator::setIPv4(wan_locator, IPLocator::toWanstring(remote_locator)); // WAN to IP
//std::cout << "WANLocator: " << IPLocator::to_string(wan_locator) << std::endl;
if(channel->locator() == wan_locator)
{
locator_mismatch = false;
}
}

if (locator_mismatch || send_buffer_size > configuration()->sendBufferSize)
{
//std::cout << "ChannelLocator: " << IPLocator::to_string(channel->locator()) << std::endl;
//std::cout << "RemoteLocator: " << IPLocator::to_string(remote_locator) << std::endl;

logWarning(RTCP, "SEND [RTPS] Failed: Not connect: " << IPLocator::getLogicalPort(remote_locator) \
<< " @ IP: " << IPLocator::toIPv4string(remote_locator));
return false;
Expand Down Expand Up @@ -1267,8 +1290,6 @@ bool TCPTransportInterface::fillMetatrafficUnicastLocator(
IPLocator::setLogicalPort(locator, static_cast<uint16_t>(metatraffic_unicast_port));
}

// TODO: Add WAN address

return true;
}

Expand Down Expand Up @@ -1338,8 +1359,6 @@ bool TCPTransportInterface::fillUnicastLocator(
IPLocator::setLogicalPort(locator, static_cast<uint16_t>(well_known_port));
}

// TODO: Add WAN address

return true;
}

Expand Down
28 changes: 15 additions & 13 deletions test/realtime/mutex_testing_tool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@
include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake)
check_gtest()

add_library(mutex_testing_tool SHARED TMutex.cpp)
if(GTEST_FOUND)
add_library(mutex_testing_tool SHARED TMutex.cpp)

add_library(mutex_testing_tool_preload SHARED Mutex.cpp)
target_link_libraries(mutex_testing_tool_preload PRIVATE mutex_testing_tool ${CMAKE_DL_LIBS})
add_library(mutex_testing_tool_preload SHARED Mutex.cpp)
target_link_libraries(mutex_testing_tool_preload PRIVATE mutex_testing_tool ${CMAKE_DL_LIBS})

add_executable(TMutexTests TMutexTests.cpp)
target_include_directories(TMutexTests PRIVATE ${GTEST_INCLUDE_DIRS})
target_link_libraries(TMutexTests mutex_testing_tool ${GTEST_LIBRARIES})
STRING(REPLACE " " "\\ " MUTEX_PRELOAD_LIBRARY_FILE "$<TARGET_FILE:mutex_testing_tool_preload>")
add_gtest(TMutexTests SOURCES TMutexTests.cpp
ENVIRONMENTS
"LD_LIBRARY_PATH=$<TARGET_FILE_DIR:mutex_testing_tool_preload>"
"LD_PRELOAD=$<TARGET_FILE_NAME:mutex_testing_tool_preload>"
LABELS "NoMemoryCheck"
)
add_executable(TMutexTests TMutexTests.cpp)
target_include_directories(TMutexTests PRIVATE ${GTEST_INCLUDE_DIRS})
target_link_libraries(TMutexTests mutex_testing_tool ${GTEST_LIBRARIES})
STRING(REPLACE " " "\\ " MUTEX_PRELOAD_LIBRARY_FILE "$<TARGET_FILE:mutex_testing_tool_preload>")
add_gtest(TMutexTests SOURCES TMutexTests.cpp
ENVIRONMENTS
"LD_LIBRARY_PATH=$<TARGET_FILE_DIR:mutex_testing_tool_preload>"
"LD_PRELOAD=$<TARGET_FILE_NAME:mutex_testing_tool_preload>"
LABELS "NoMemoryCheck"
)
endif(GTEST_FOUND)

0 comments on commit 459a4c1

Please sign in to comment.