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

Handling the error when removing a change in ReaderHistory::remove_changes_with_guid may be incorrect [9813] #1531

Closed
VladimirVassiliev opened this issue Oct 30, 2020 · 1 comment

Comments

@VladimirVassiliev
Copy link

Handling the error when removing a change in ReaderHistory::remove_changes_with_guid may be incorrect. Here is the code:

bool ReaderHistory::remove_changes_with_guid(
        const GUID_t& a_guid)
{
    std::vector<CacheChange_t*> changes_to_remove;

    if (mp_reader == nullptr || mp_mutex == nullptr)
    {
        logError(RTPS_READER_HISTORY, "You need to create a Reader with History before removing any changes");
        return false;
    }

    {
        //Lock scope
        std::lock_guard<RecursiveTimedMutex> guard(*mp_mutex);
        for (std::vector<CacheChange_t*>::iterator chit = m_changes.begin(); chit != m_changes.end(); ++chit)
        {
            if ((*chit)->writerGUID == a_guid)
            {
                changes_to_remove.push_back((*chit));
            }
        }
    }//End lock scope

    for (std::vector<CacheChange_t*>::iterator chit = changes_to_remove.begin(); chit != changes_to_remove.end();
            ++chit)
    {
        if (!remove_change(*chit))
        {
            logError(RTPS_READER_HISTORY, "One of the cachechanged in the GUID removal bulk could not be removed");
            return false;
        }
    }
    return true;
}

Should it continue iterating to remove other changes? The most likely reason the remove_change returns false is that the change is no longer there. Is it guaranteed that there cannot be any more changes with that GUID?

Expected Behavior

Current Behavior

Steps to Reproduce

System information

  • Fast-RTPS version:
  • OS:
  • Network interfaces:
  • ROS2:

Additional context

Additional resources

  • Wireshark capture
  • XML profiles file
@imontesino imontesino changed the title Handling the error when removing a change in ReaderHistory::remove_changes_with_guid may be incorrect Handling the error when removing a change in ReaderHistory::remove_changes_with_guid may be incorrect [9813] Nov 5, 2020
@JLBuenoLopez
Copy link
Contributor

#2363 refactored the ReaderHistory class and it fixed this issue. I am going to proceed and close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants