-
Notifications
You must be signed in to change notification settings - Fork 107
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
Threading issues with asynchronous messaging to inactive subscription #64
Comments
Hi @dalijap that is a good point. One additional check can be before the method invoke to check if the Subscriber is not nil:
Other than that we could also think about a callback in case of exception. Because as you can see from the method below the exception will be handled:
Then also around the crash, it would be limited to the single thread/task. We can also think to change the Subscription into an interface. What do you think? do you have additional suggestions for the issue? Thanks :) |
here a PR #65 |
Using the last change #65 that was proposed by @spinettaro in a production application that does not have a heavy use of Teventbus, and with TEurekalog enabled to send me messages when application freezes for more than 10sec, I get occasionally a log event like the following: |
To be honest, it is difficult to compare with before #65, as I had many changes in the code and a bug fix in a component that was used by after Teventmessage comes. |
There are threading issues in asynchronous messaging with inactive subscription.
Namely code in Post methods checks whether subscription is active before invoking subscription method
But, depending on threading mode PostToChannel and PostToSubscription methods can invoke subscription method asynchronously with TThread.Queue or TTask.Run or TThread.CreateAnonymousThread
During that time subscription can get inactive and that can cause crashes by calling subscription method on dead object.
The text was updated successfully, but these errors were encountered: