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

Fixed ClientWebSocket disposal #455

Merged
merged 1 commit into from
Oct 2, 2019
Merged

Fixed ClientWebSocket disposal #455

merged 1 commit into from
Oct 2, 2019

Conversation

vslee
Copy link
Collaborator

@vslee vslee commented Oct 1, 2019

  • cancel CTS and set 'disposed' bool after attempting to close connection
  • dispose of the webSocket
  • mark messageQueue as complete
  • close MemoryStream in ReadTask()

- cancel CTS and set 'disposed' bool after attempting to close connection
- dispose of the webSocket
- mark messageQueue as complete
- close MemoryStream in ReadTask()
@vslee vslee added the maintenance such as tests label Oct 1, 2019
@jjxtra
Copy link
Collaborator

jjxtra commented Oct 1, 2019

Only question I have is can we ensure Dispose is only called once? What did you run into having dispose set to true and checked before doing the task.run?

@vslee
Copy link
Collaborator Author

vslee commented Oct 1, 2019

If the either the cancellationToken is cancelled, or the disposed is set to true first, then the connection may be prematurely disconnected prior to the task.run running. And thus, the CloseAsync/CloseOutputAsync is not always run.

@vslee
Copy link
Collaborator Author

vslee commented Oct 1, 2019

In terms of Dispose() being called more than once, it would just spawn another Task, but then everything inside would be okay. It would check to see if the socket is open, and if not, then it wouldn't try to close it again. And the last three lines can be called multiple times w/o issue.

@jjxtra jjxtra merged commit d577c7e into DigitalRuby:master Oct 2, 2019
vslee added a commit that referenced this pull request Oct 2, 2019
- cancel CTS and set 'disposed' bool after attempting to close connection
- dispose of the webSocket
- mark messageQueue as complete
- close MemoryStream in ReadTask()

(cherry picked from commit d577c7e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance such as tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants