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

Ref. 7290 propagate errors on take_next_data [7292] #962

Merged
merged 3 commits into from
Jan 23, 2020
Merged
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
2 changes: 1 addition & 1 deletion include/fastrtps/subscriber/SubscriberHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class SubscriberHistory: public rtps::ReaderHistory
rtps::CacheChange_t* a_change,
std::vector<rtps::CacheChange_t*>& instance_changes);

void deserialize_change(
bool deserialize_change(
rtps::CacheChange_t* change,
uint32_t ownership_strength,
void* data,
Expand Down
38 changes: 21 additions & 17 deletions src/cpp/subscriber/SubscriberHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool SubscriberHistory::received_change(
{
if (mp_reader == nullptr || mp_mutex == nullptr)
{
logError(RTPS_HISTORY, "You need to create a Reader with this History before using it");
logError(SUBSCRIBER, "You need to create a Reader with this History before using it");
return false;
}

Expand Down Expand Up @@ -255,7 +255,7 @@ bool SubscriberHistory::find_key_for_change(
{
if (!a_change->instanceHandle.isDefined() && mp_subImpl->getType() != nullptr)
{
logInfo(RTPS_HISTORY, "Getting Key of change with no Key transmitted")
logInfo(SUBSCRIBER, "Getting Key of change with no Key transmitted")
mp_subImpl->getType()->deserialize(&a_change->serializedPayload, mp_getKeyObject);
bool is_key_protected = false;
#if HAVE_SECURITY
Expand All @@ -268,23 +268,27 @@ bool SubscriberHistory::find_key_for_change(
}
else if (!a_change->instanceHandle.isDefined())
{
logWarning(RTPS_HISTORY, "NO KEY in topic: " << mp_subImpl->getAttributes().topic.topicName
logWarning(SUBSCRIBER, "NO KEY in topic: " << mp_subImpl->getAttributes().topic.topicName
<< " and no method to obtain it";);
return false;
}

return find_key(a_change, &map_it);
}

void SubscriberHistory::deserialize_change(
bool SubscriberHistory::deserialize_change(
CacheChange_t* change,
uint32_t ownership_strength,
void* data,
SampleInfo_t* info)
{
if (change->kind == ALIVE)
{
mp_subImpl->getType()->deserialize(&change->serializedPayload, data);
if (!mp_subImpl->getType()->deserialize(&change->serializedPayload, data))
{
logError(SUBSCRIBER, "Deserialization of data failed");
return false;
}
}

if (info != nullptr)
Expand All @@ -307,6 +311,8 @@ void SubscriberHistory::deserialize_change(
info->iHandle = change->instanceHandle;
info->related_sample_identity = change->write_params.sample_identity();
}

return true;
}

bool SubscriberHistory::readNextData(
Expand All @@ -316,7 +322,7 @@ bool SubscriberHistory::readNextData(
{
if (mp_reader == nullptr || mp_mutex == nullptr)
{
logError(RTPS_HISTORY, "You need to create a Reader with this History before using it");
logError(SUBSCRIBER, "You need to create a Reader with this History before using it");
return false;
}

Expand All @@ -331,8 +337,7 @@ bool SubscriberHistory::readNextData(
logInfo(SUBSCRIBER, mp_reader->getGuid().entityId << ": reading " << change->sequenceNumber);
uint32_t ownership = wp && mp_subImpl->getAttributes().qos.m_ownership.kind == EXCLUSIVE_OWNERSHIP_QOS ?
wp->ownership_strength() : 0;
deserialize_change(change, ownership, data, info);
return true;
return deserialize_change(change, ownership, data, info);
}
}
return false;
Expand All @@ -346,7 +351,7 @@ bool SubscriberHistory::takeNextData(
{
if (mp_reader == nullptr || mp_mutex == nullptr)
{
logError(RTPS_HISTORY, "You need to create a Reader with this History before using it");
logError(SUBSCRIBER, "You need to create a Reader with this History before using it");
return false;
}

Expand All @@ -362,9 +367,9 @@ bool SubscriberHistory::takeNextData(
" from writer: " << change->writerGUID);
uint32_t ownership = wp && mp_subImpl->getAttributes().qos.m_ownership.kind == EXCLUSIVE_OWNERSHIP_QOS ?
wp->ownership_strength() : 0;
deserialize_change(change, ownership, data, info);
remove_change_sub(change);
return true;
bool deserialized = deserialize_change(change, ownership, data, info);
bool removed = remove_change_sub(change);
return (deserialized && removed);
EduPonz marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -404,13 +409,12 @@ bool SubscriberHistory::find_key(
return false;
}


bool SubscriberHistory::remove_change_sub(
CacheChange_t* change)
{
if (mp_reader == nullptr || mp_mutex == nullptr)
{
logError(RTPS_HISTORY, "You need to create a Reader with this History before using it");
logError(SUBSCRIBER, "You need to create a Reader with this History before using it");
return false;
}

Expand All @@ -433,7 +437,7 @@ bool SubscriberHistory::remove_change_sub(
}
if (!found)
{
logWarning(SUBSCRIBER, "Change not found, something is wrong");
logError(SUBSCRIBER, "Change not found on this key, something is wrong");
}
}

Expand All @@ -452,7 +456,7 @@ bool SubscriberHistory::set_next_deadline(
{
if (mp_reader == nullptr || mp_mutex == nullptr)
{
logError(RTPS_HISTORY, "You need to create a Reader with this History before using it");
logError(SUBSCRIBER, "You need to create a Reader with this History before using it");
return false;
}
std::lock_guard<RecursiveTimedMutex> guard(*mp_mutex);
Expand Down Expand Up @@ -482,7 +486,7 @@ bool SubscriberHistory::get_next_deadline(
{
if (mp_reader == nullptr || mp_mutex == nullptr)
{
logError(RTPS_HISTORY, "You need to create a Reader with this History before using it");
logError(SUBSCRIBER, "You need to create a Reader with this History before using it");
return false;
}
std::lock_guard<RecursiveTimedMutex> guard(*mp_mutex);
Expand Down