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] Review comments #58608

Closed
wants to merge 1 commit into from
Closed

Conversation

ManickaP
Copy link
Member

@ManickaP ManickaP commented Sep 3, 2021

Notes from yesterday.

cc @wfurt @CarnaViire

@ghost
Copy link

ghost commented Sep 3, 2021

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

Issue Details

Notes from yesterday.

cc @wfurt @CarnaViire

Author: ManickaP
Assignees: -
Labels:

area-System.Net

Milestone: -

@ManickaP ManickaP added NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) area-System.Net.Quic NO-REVIEW Experimental/testing PR, do NOT review it and removed area-System.Net labels Sep 3, 2021
@ghost
Copy link

ghost commented Sep 3, 2021

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

Issue Details

Notes from yesterday.

cc @wfurt @CarnaViire

Author: ManickaP
Assignees: -
Labels:

* NO MERGE *, NO REVIEW, area-System.Net.Quic

Milestone: -

Copy link
Member Author

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First batch, mostly covered by mega issue: #59346

@@ -483,11 +489,13 @@ internal override ValueTask<int> ReadAsync(Memory<byte> destination, Cancellatio
_state.ReadState = ReadState.None;

int taken = CopyMsQuicBuffersToUserBuffer(_state.ReceiveQuicBuffers.AsSpan(0, _state.ReceiveQuicBuffersCount), destination.Span);
// CR: we shouldn't be calling msquic in a lock
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReceiveComplete(taken);

if (taken != _state.ReceiveQuicBuffersTotalBytes)
{
// Need to re-enable receives because MsQuic will pause them when we don't consume the entire buffer.
// CR: we shouldn't be calling msquic in a lock
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -354,6 +354,8 @@ private CancellationTokenRegistration HandleWriteStartState(bool emptyBuffer, Ca
}
}, _state);

// CR: We should make sure that we never return from a final state (Abort etc.) back to writing.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -354,6 +354,8 @@ private CancellationTokenRegistration HandleWriteStartState(bool emptyBuffer, Ca
}
}, _state);

// CR: 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).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +385 to +386
// CR: Consolidate the state machine from so many small helpers (obstacle - 3 different write methods).
// Do not use Handle... for private helpers that are not msquic callbacks.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -845,6 +861,7 @@ private void Dispose(bool disposing)

private void EnableReceive()
{
// CR: assert no lock is taken
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -638,6 +649,8 @@ internal override async ValueTask ShutdownCompleted(CancellationToken cancellati
}
}

// CR: should we be issuing abortive shutdown (immediate) here instead? Beware of shutdown event handler releasing memory and having
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -665,6 +678,7 @@ internal override ValueTask WaitForWriteCompletionAsync(CancellationToken cancel
return new ValueTask(_state.ShutdownWriteCompletionSource.Task.WaitAsync(cancellationToken));
}

// CR: naming ShutdownWrites, this one closes write side of the stream only
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -805,6 +819,7 @@ private void Dispose(bool disposing)
}

// Check if we already got final event.
// CR: use constants for the values of ShutdownDone
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -825,6 +840,7 @@ private void Dispose(bool disposing)
{
try
{
// CR: Use a constant for 0xffffffff
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -866,6 +883,8 @@ private void EnableReceive()
return HandleEvent(state, ref streamEvent);
}

// CR: why is this a seperate function???
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -883,6 +902,7 @@ private static uint HandleEvent(State state, ref StreamEvent evt)
return HandleEventStartComplete(state, ref evt);
// Received data on the stream
case QUIC_STREAM_EVENT_TYPE.RECEIVE:
// CR: naming Receive
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -896,6 +916,7 @@ private static uint HandleEvent(State state, ref StreamEvent evt)
return HandleEventPeerSendAborted(state, ref evt);
// Peer has stopped receiving data, don't send anymore.
case QUIC_STREAM_EVENT_TYPE.PEER_RECEIVE_ABORTED:
// CR: naming Receive
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -922,6 +943,7 @@ private static uint HandleEvent(State state, ref StreamEvent evt)
}
}

// CR: Add high level how the reading works comment.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +1235 to +1237
// CR: canceled will be set when connection gets aborted,
// send with FIN followed in a quick succession by another send
// CR: we might ignore canceled, since there might be a race between connection getting closed and geting this event.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#59346
I'm not 100% sure I've got this right and correctly described it in the issue. @CarnaViire it's 14th bullet point in the issue. could you please check it there?

uint status = MsQuicApi.Api.StreamReceiveCompleteDelegate(_state.Handle, (ulong)bufferLength);
QuicExceptionHelpers.ThrowIfFailed(status, "Could not complete receive call.");
}

// This can fail if the stream isn't started.
private long GetStreamId()
{
// CR: assert no lock is taken
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1526,6 +1553,7 @@ private static uint HandleEventConnectionClose(State state)
private static Exception GetConnectionAbortedException(State state) =>
ThrowHelper.GetConnectionAbortedException(state.ConnectionState.AbortErrorCode);

// CR: naming ??? nobody knows a better name
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1608,6 +1636,7 @@ private enum ReadState
Closed
}

// CR: explain the state machine in comments
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1616,6 +1645,7 @@ private enum ShutdownWriteState
ConnectionClosed
}

// CR: explain the state machine in comments
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1625,6 +1655,7 @@ private enum ShutdownState
ConnectionClosed
}

// CR: explain the state machine in comments
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is it. I'll drop this Draft PR by the end of this week, we should have everything from the session covered.

@@ -34,6 +34,8 @@ internal sealed class State

public readonly SafeMsQuicConfigurationHandle? ConnectionConfiguration;
public readonly Channel<MsQuicConnection> AcceptConnectionQueue;
// CR: Connections before finished negotiation, we hold them back until they're fully connected / initialized.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManickaP ManickaP closed this Sep 30, 2021
@ManickaP ManickaP deleted the mapichov/code_review branch September 30, 2021 16:03
@karelz karelz added this to the 7.0.0 milestone Oct 14, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Quic NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) NO-REVIEW Experimental/testing PR, do NOT review it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants