[AndroidClientHandler] Prevent orphaned thread in DoProcessRequest#344
[AndroidClientHandler] Prevent orphaned thread in DoProcessRequest#344grendello merged 2 commits intodotnet:masterfrom leonluc-dev:master
Conversation
|
Hello! I'm the build bot for the Mono project. I need approval from a Mono team member to build this pull request. A team member should reply with "approve" to approve a build of this pull request, "whitelist" to whitelist this and all future pull requests from this contributor, or "build" to explicitly request a build, even if one has already been done. Contributors can ignore this message. |
|
@grendello: Can you review? @gameleon-dev: Would it be possible to create a unit test for this? It doesn't seem like it would require a dedicated server endpoint, so it seems like it should be possible to unit test this... Unit tests would go into |
|
While it seems difficult to unit test the issue this pull request addresses (orphaned thread), it should be possible to test if the cancellation requests are handled properly with something like the following psuedo code: I will try to write a unit test based on the above psuedo code and add it to this pull request. |
Followup to #321
In the current implementation the WaitOne task will never finish if the cancellationToken is never cancelled.
This results in an orphaned task/thread.
This can be solved by creating a CancellationTokenSource for the WaitOne thread and linking it to the original cancellation token. This CancellationTokenSource can then be canceled after the task completes or raises and exception, making sure the WaitOne task runs to completion and is properly disposed of every run of this method.