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

SHUTDOWN_COMPLETE event happening before all received data could be processed #1384

Closed
CarnaViire opened this issue Mar 26, 2021 · 0 comments · Fixed by #1382
Closed

SHUTDOWN_COMPLETE event happening before all received data could be processed #1384

CarnaViire opened this issue Mar 26, 2021 · 0 comments · Fixed by #1382
Labels
Area: API Area: Core Related to the shared, core protocol logic Bug: Core A code bug in the Core MsQuic code
Milestone

Comments

@CarnaViire
Copy link
Member

I am investigating failing tests in System.Net.Quic library that uses msquic. The tests are very basic, there is a peer sending some data to an endpoint (let me call it my app) in a unidirectional stream and then indicating a graceful shutdown. After that, as soon as my app's msquic acks this shutdown, SHUTDOWN_COMPLETE event appears on both sides. On my app side though, this event doesn't seem to pay attention to pending RECEIVE data (the one that got buffered by msquic but is yet to be read by the app). It may be important that the app reads the data asynchronously (i.e. returns QUIC_STATUS_PENDING, and then calls to StreamReceiveComplete and StreamReceiveSetEnabled when finished)

There are two scenarios in which I got SHUTDOWN_COMPLETE event in the middle of processing the data.

1. When the reads are complete

(peer sends e.g. 10K and I receive in a buffer of the same size)

I sometimes will get SHUTDOWN_COMPLETE right away after the last RECEIVE -- even before I'm able to call StreamReceiveComplete, and in this case StreamReceiveComplete will fail. Events will go as follows:

[PEER] data sent
[PEER] received event SEND_COMPLETE
        [APP] received event RECEIVE
[PEER] shutdown sent
        [APP] read started
[PEER] received event SEND_SHUTDOWN_COMPLETE
[PEER] received event SHUTDOWN_COMPLETE
        [APP] received event SHUTDOWN_COMPLETE
        [APP] read finished, will call StreamReceiveComplete
[PEER] connection closed
        [APP][ERROR] message: Exception occurred during connection callback: The channel has been closed.
        [APP][ERROR] System.Net.Quic.QuicException : Could not complete receive call. Error Code: INVALID_STATE

2. When reads are partial

(peer sends e.g. 10K and I read data in an 1K buffer several times)

In this case, I don't get any errors, but I lose data. E.g. I will read 3K and then I'll get a SHUTDOWN_COMPLETE event. After that there is no way to get the rest of data, even though it was already buffered inside msquic.

Expected behavior

Is it possible for PEER_SEND_SHUTDOWN/SHUTDOWN_COMPLETE to behave in line with RECEIVE events (so I'll get it after I notify msquic that previous receive is completed)?

cc @nibanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: API Area: Core Related to the shared, core protocol logic Bug: Core A code bug in the Core MsQuic code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants