git commit -m "PDP: release locks and remove change on domain-id mism…#6408
git commit -m "PDP: release locks and remove change on domain-id mism…#6408lobmoo wants to merge 1 commit into
Conversation
…atch When a received Participant DATA has a different domain_id, return path left reader and PDP mutexes held and did not remove the change from history. Ensure locks are released and change removed before returning."
|
When the same multicast address and port are configured for different domain IDs, and they communicate within the same physical network, the early return path causes a memory leak. Without setting a participant's pool size, this will continue until system memory is exhausted. |
|
第一次收到这个 writer 的 seq=1,last_notified 还是默认 0,所以 thereIsUpperRecordOf(...) 返回 false,流程继续往下走。 同一个 writer 再发 seq=1 的重复包,会被挡住,因为 last_notified=1,thereIsUpperRecordOf(1) 为 true。 |
Title: PDP: release locks and remove change on domain-id mismatch
Description
Problem: When processing received Participant DATA, if the
participant_data.domain_iddiffers from the local domain, the current return path exits without releasing previously acquired locks (the reader mutex and the PDP mutex) and without removing thechangefrom the PDP reader history. This can lead to deadlocks or history leaks.Change: In
src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp, insideon_new_cache_change_added, whencheck_discovery_conditions(temp_participant_data_)returnsfalse(domain-id mismatch), the code now performs the following before returning:reader->getMutex().unlock();lock.unlock();parent_pdp_->builtin_endpoints_->remove_from_pdp_reader_history(change);Rationale: Ensure all early return paths that hold locks properly release them and clean up resources to avoid potential deadlocks and leftover history entries.
Scope: This affects only PDP discovery early-return logic for domain-id mismatch cases. It does not change normal participant processing flow or public APIs.
Testing recommendations:
changeis removed from the reader history (e.g., by checking history size or using log assertions).Files changed
src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp(around lines 121-128)Patch snippet
Contributor Checklist
Reviewer Checklist
Backports (optional)
Notes
If you want, I can create a local branch, apply this patch, commit, and push the branch to your remote and prepare a draft PR.