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

Use Lifetime pattern in XMPP connection #62

Open
ForNeVeR opened this issue Jul 20, 2019 · 0 comments
Open

Use Lifetime pattern in XMPP connection #62

ForNeVeR opened this issue Jul 20, 2019 · 0 comments

Comments

@ForNeVeR
Copy link
Member

Let's use JetBrains.Dataflow.Lifetime here to prevent the following case:

  1. Thread 1 performs Volatile.Read (and reads the "good" client)
  2. Thread 2 performs Volatile.Write(None)
  3. Thread 1 starts to perform some calls on the client
  4. Thread 2 at the same time calls client.Dispose()

As the result, client could become disposed in parallel with some calls by thread 1, which is very bad (at least theoretically). It is in my opinion worse than any calls on a non-disposed client (even if it has already failed).

Here we should use the lifetime pattern and lifetime.Using, and instead of Volatile.Read we better call lifetime.ExecuteIfAlive that should prevent us from disposing a lifetime that has some ongoing calls on it.

Originally posted as a comment to #59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant