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

StandardRouter.Route will block if handler of arriving message registers more routes #99

Open
ebudan opened this issue Aug 22, 2022 · 1 comment
Milestone

Comments

@ebudan
Copy link

ebudan commented Aug 22, 2022

Is your feature request related to a problem? Please describe.

Uncertain whether to file this should be a bug or a documentation request.
I will describe the issue for the public, and welcome your recommendations.

I am working on a less-than-trivial system that reacts to a control message by building internal logic, including setting up new subscriptions. My base message handlers ultimately call StandardRouter.RegisterHandler(), which will block thanks to StandardRouter.Router()'s previous lock. (I manage to reproduce this systematically when one client publishes a retained control message triggering this setup logic while the receiving client is offline and then activates, connects and receives the message in its onConnect() handler. Currently trying to figure out how to structure my code to circumvent this, but not there yet.)

Describe the solution you'd like

A low impact solution (in both senses) would be documentation for StandardRouter, pointing out the pitfall.

I personally would consider releasing the lock in StandardRouter.Route() after copying the subscriptions map and before calling the handlers would help, but I can't guess how this will affect possible performance requirements the project has in here.

Happy to submit a pull request in case of consensus.

@MattBrittan
Copy link
Contributor

I believe that the router changes in the next release should provide a way around this (the router is no longer the default approach; instead you can use OnPublishReceived and handle messages without the router.

@MattBrittan MattBrittan added this to the Version 1.0.0 milestone Feb 12, 2024
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