Commit e87a722
committed
fix(rmw): make set() wait for in-flight dispatches on other threads
Dropping the state guard before dispatch fixed the deadlock but removed a
lifetime guarantee rmw_zenoh_cpp provides deliberately: it invokes the
callback under event_mutex_, which event_set_callback also takes, so once
set_callback(nullptr) returns no callback is in flight and the caller may
free what user_data pointed at.
Without that, a delivery thread could snapshot (callback, user_data), drop
the guard, and then be overtaken by a set(None) that clears the slot and
returns -- after which the entity is destroyed and the snapshot dangles.
Restoring the C++ shape would reinstate the deadlock, so exclusion and
lifetime are separated: each dispatch registers its thread, and set() waits
for registrations on *other* threads. Scoping the wait that way is what
keeps a callback re-entering set() on its own thread from waiting on
itself.1 parent faee5a3 commit e87a722
1 file changed
Lines changed: 304 additions & 11 deletions
0 commit comments