-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[QUIC] Review comments #58608
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsNotes from yesterday.
|
Tagging subscribers to this area: @dotnet/ncl Issue DetailsNotes from yesterday.
|
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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??? |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes from yesterday.
cc @wfurt @CarnaViire