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

[QUIC] Stream refactorings #59346

Closed
7 of 16 tasks
ManickaP opened this issue Sep 20, 2021 · 2 comments
Closed
7 of 16 tasks

[QUIC] Stream refactorings #59346

ManickaP opened this issue Sep 20, 2021 · 2 comments
Labels
area-System.Net.Quic enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@ManickaP
Copy link
Member

ManickaP commented Sep 20, 2021

Based on our group code-review:

  • We should make sure that we never return from a final state (Abort etc.) back to writing.
  • Also we're missing final state for writing (we have one for reading).
  • Do not use Handle... for private helpers that are not msquic callbacks, e.g.:
  • Consolidate the state machine transitions from so many small helpers, i.e.: Handle... helpers. Blocked by having 3 different Write methods.
  • NIT: shouldComplete (all vars) naming is not ideal
  • Should we go back to success state after failed attempt to call msquic send or should we go into aborted state?
    private void HandleWriteFailedState()
    {
    lock (_state)
    {
    if (_state.SendState == SendState.Pending)
    {
    _state.SendState = SendState.Finished;
    }
    }
    }
  • Should we be issuing abortive shutdown (immediate) in cancellation of ShutdownCompleted? Beware of shutdown event handler releasing memory and having memory leaks.
    using CancellationTokenRegistration registration = cancellationToken.UnsafeRegister(static (s, token) =>
    {
    var state = (State)s!;
    bool shouldComplete = false;
    lock (state)
    {
    if (state.ShutdownState == ShutdownState.None)
    {
    state.ShutdownState = ShutdownState.Canceled;
    shouldComplete = true;
    }
    }
    if (shouldComplete)
    {
    state.ShutdownCompletionSource.SetException(
    ExceptionDispatchInfo.SetCurrentStackTrace(new OperationCanceledException("Wait for shutdown was canceled", token)));
    }
    }, _state);
  • NIT: Naming of Shutdown which closes the writing side of the stream:
  • Use constants for _state.ShutdownDone
    releaseHandles = Interlocked.Exchange(ref _state.ShutdownDone, 1) == 2;
  • Use constant for 0xffffffff
    StartShutdown(QUIC_STREAM_SHUTDOWN_FLAGS.ABORT_RECEIVE, 0xffffffff);
  • Merge NativeCallbackHandler with HandleEvent in MsQuicStream. Why is this a seperate function? We should be consistent with other msquic objects like connection and listener. - both connection and listener have only one method.
  • Rename HandleEventRecv and HandleEventPeerRecvAborted to both caontain full Receive word as do the msquic event names.
  • Add high-level comments for HandleEventRecv and how it works together ReadAsync. The comments are there, just spread out across the code so it's hard to follow the logic.
  • HandleEventSendComplete: the cancelled flag will be set in 2 known cases: connection is getting aborted/closed or we issued Send with FIN flag quickly followed by another Send (the second will be cancelled). Since there might be race with connection close event we might consider ignore this SEND_COMPLETE in case of Cancelled==1.
  • CleanupReadStateAndCheckPending could use a nicer name, but no one has any good suggestions.
  • Add comments for the other state enums and their transitions as we do for ReadState.
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Net.Quic untriaged New issue has not been triaged by the area owner labels Sep 20, 2021
@ghost
Copy link

ghost commented Sep 20, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Based on our group code-review:

  • We should make sure that we never return from a final state (Abort etc.) back to writing.
  • Also we're missing final state for writing (we have one for reading).
  • Do not use Handle... for private helpers that are not msquic callbacks, e.g.:
  • Consolidate the state machine transitions from so many small helpers, i.e.: Handle... helpers. Blocked by having 3 different Write methods.
  • NIT: shouldComplete (all vars) naming is not ideal
  • [ ]
Author: ManickaP
Assignees: -
Labels:

untriaged, area-System.Net.Quic

Milestone: -

@ManickaP
Copy link
Member Author

Closed by #71969

@karelz karelz modified the milestones: Future, 7.0.0 Jul 19, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Quic enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

3 participants