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

Avoid completing reader or writer except after they are done #414

Merged
merged 1 commit into from
Feb 7, 2020

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented Feb 7, 2020

This is a follow-up to #350 which was evidently incompletely fixed. In the earlier fix, we arranged to Complete the reader and writer after they were done, which might be sometime after Dispose is called. This was all done in the base type. In the derived type, a Dispose override method Complete()'d the reader and writer anyway, defeating the very thing we were trying to fix.

The fix is to remove these calls to Complete, leaving the base class to schedule these calls as it already does:

Task readerDisposal = this.readingCompleted.WaitAsync().ContinueWith((_, s) => ((MessageHandlerBase)s).DisposeReader(), this, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.Default);
Task writerDisposal = this.writingCompleted.WaitAsync().ContinueWith((_, s) => ((MessageHandlerBase)s).DisposeWriter(), this, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.Default);
this.Completion = Task.WhenAll(readerDisposal, writerDisposal).ContinueWith((_, s) => ((MessageHandlerBase)s).Dispose(true), this, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);

Fixes #413

@AArnott AArnott self-assigned this Feb 7, 2020
@AArnott AArnott added this to the v2.3 milestone Feb 7, 2020
@AArnott AArnott requested a review from ikeras February 7, 2020 22:51
This is a follow-up to microsoft#350 which was evidently incompletely fixed.

Fixes microsoft#413
@codecov-io
Copy link

Codecov Report

Merging #414 into v2.3 will decrease coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             v2.3     #414      +/-   ##
==========================================
- Coverage   90.71%   90.67%   -0.04%     
==========================================
  Files          49       49              
  Lines        3716     3711       -5     
==========================================
- Hits         3371     3365       -6     
- Misses        345      346       +1
Impacted Files Coverage Δ
src/StreamJsonRpc/PipeMessageHandler.cs 90.78% <ø> (-0.57%) ⬇️
src/StreamJsonRpc/MessageHandlerBase.cs 98.73% <0%> (-1.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b6a5874...d7135f8. Read the comment docs.

@AArnott AArnott merged commit 44085fd into microsoft:v2.3 Feb 7, 2020
@AArnott AArnott deleted the fix413 branch February 7, 2020 23:12
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

Successfully merging this pull request may close these issues.

3 participants