Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

接続相手のポートとの通信でCOMM_FAILURE_WaitingForReply例外が発生した場合に接続をリトライする #1043

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/lib/rtm/InPortCorbaCdrConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include <rtm/NVUtil.h>
#include <rtm/InPortCorbaCdrConsumer.h>

#if defined(minor)
#undef minor
#endif

namespace RTC
{
/*!
Expand Down Expand Up @@ -83,6 +87,27 @@ namespace RTC
// (IDL)OpenRTM::DataPort::ReturnCode_t -> DataPortStatus
return convertReturnCode(_ptr()->put(m_data));
}
#ifdef ORB_IS_OMNIORB
catch (const CORBA::COMM_FAILURE& ex)
{
if (ex.minor() == omni::COMM_FAILURE_WaitingForReply)
{
RTC_DEBUG(("Retry put message"));
try
{
return convertReturnCode(_ptr()->put(m_data));
}
catch (...)
{
return DataPortStatus::CONNECTION_LOST;
}
}
else
{
return DataPortStatus::CONNECTION_LOST;
}
}
#endif
catch (...)
{
return DataPortStatus::CONNECTION_LOST;
Expand Down
25 changes: 25 additions & 0 deletions src/lib/rtm/InPortDSConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include <rtm/NVUtil.h>
#include <rtm/InPortDSConsumer.h>

#if defined(minor)
#undef minor
#endif

namespace RTC
{
/*!
Expand Down Expand Up @@ -82,6 +86,27 @@ namespace RTC
// (IDL)OpenRTM::DataPort::ReturnCode_t -> DataPortStatus
return convertReturnCode(_ptr()->push(m_data));
}
#ifdef ORB_IS_OMNIORB
catch (const CORBA::COMM_FAILURE& ex)
{
if (ex.minor() == omni::COMM_FAILURE_WaitingForReply)
{
RTC_DEBUG(("Retry push message"));
try
{
return convertReturnCode(_ptr()->push(m_data));
}
catch (...)
{
return DataPortStatus::CONNECTION_LOST;
}
}
else
{
return DataPortStatus::CONNECTION_LOST;
}
}
#endif
catch (...)
{
return DataPortStatus::CONNECTION_LOST;
Expand Down
31 changes: 30 additions & 1 deletion src/lib/rtm/InPortSHMConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <mutex>
#include <memory>

#if defined(minor)
#undef minor
#endif


namespace RTC
{
Expand Down Expand Up @@ -109,15 +113,40 @@ namespace RTC
{
RTC_PARANOID(("put()"));

std::lock_guard<std::mutex> guard(m_mutex);
try
{
std::lock_guard<std::mutex> guard(m_mutex);
m_shmem.setEndian(m_endian);
m_shmem.create_memory(m_memory_size, m_shm_address.c_str());
m_shmem.write(data);

return convertReturnCode(_ptr()->put());
}
#ifdef ORB_IS_OMNIORB
catch (const CORBA::COMM_FAILURE& ex)
{
if (ex.minor() == omni::COMM_FAILURE_WaitingForReply)
{
RTC_DEBUG(("Retry put message"));
try
{
m_shmem.setEndian(m_endian);
m_shmem.create_memory(m_memory_size, m_shm_address.c_str());
m_shmem.write(data);

return convertReturnCode(_ptr()->put());
}
catch (...)
{
return DataPortStatus::CONNECTION_LOST;
}
}
else
{
return DataPortStatus::CONNECTION_LOST;
}
}
#endif
catch (...)
{
return DataPortStatus::CONNECTION_LOST;
Expand Down
28 changes: 27 additions & 1 deletion src/lib/rtm/OutPortCorbaCdrConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include <rtm/OutPortCorbaCdrConsumer.h>
#include <rtm/NVUtil.h>

#if defined(minor)
#undef minor
#endif

namespace RTC
{
/*!
Expand Down Expand Up @@ -99,7 +103,29 @@ namespace RTC

try
{
::OpenRTM::PortStatus ret(_ptr()->get(cdr_data.out()));
::OpenRTM::PortStatus ret(::OpenRTM::PortStatus::PORT_ERROR);
try
{
ret = _ptr()->get(cdr_data.out());
}
#ifdef ORB_IS_OMNIORB
catch (const CORBA::COMM_FAILURE& ex)
{
if (ex.minor() == omni::COMM_FAILURE_WaitingForReply)
{
RTC_DEBUG(("Retry get message"));
ret = _ptr()->get(cdr_data.out());
}
else
{
throw;
}
}
#endif
catch (...)
{
throw;
}

if (ret == ::OpenRTM::PORT_OK)
{
Expand Down
28 changes: 27 additions & 1 deletion src/lib/rtm/OutPortDSConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <rtm/OutPortDSConsumer.h>
#include <rtm/NVUtil.h>

#if defined(minor)
#undef minor
#endif

namespace RTC
{
/*!
Expand Down Expand Up @@ -97,7 +101,29 @@ namespace RTC

try
{
::RTC::PortStatus ret(_ptr()->pull(cdr_data.out()));
::RTC::PortStatus ret(::RTC::PortStatus::PORT_ERROR);
try
{
ret = _ptr()->pull(cdr_data.out());
}
#ifdef ORB_IS_OMNIORB
catch (const CORBA::COMM_FAILURE& ex)
{
if (ex.minor() == omni::COMM_FAILURE_WaitingForReply)
{
RTC_DEBUG(("Retry pull message"));
ret = _ptr()->pull(cdr_data.out());
}
else
{
throw;
}
}
#endif
catch (...)
{
throw;
}

if (ret == ::RTC::PORT_OK)
{
Expand Down
Loading
Loading