The current structure of LF mode leaves the publisher's forwarder with shared ownership with the publisher's session (bound to an io thread) but has a strong shared_ptr in the Relay's registry.
Having the shared_ptr in the relay thread is also a tsan hazard -- the publisher is writing to it (eg largest object, subscribers_.size()) and the relay shouldn't be allowed to read it.
My fix is to make a helper class that abstracts the reference to the forwarder that makes it impossible to touch it in the wrong thread in LF mode.
The current structure of LF mode leaves the publisher's forwarder with shared ownership with the publisher's session (bound to an io thread) but has a strong shared_ptr in the Relay's registry.
Having the shared_ptr in the relay thread is also a tsan hazard -- the publisher is writing to it (eg largest object, subscribers_.size()) and the relay shouldn't be allowed to read it.
My fix is to make a helper class that abstracts the reference to the forwarder that makes it impossible to touch it in the wrong thread in LF mode.