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

YamuxStream is tagged to Unreadable too early, since there may be data that hasn't been processed #167

Open
Saigut opened this issue Sep 13, 2021 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@Saigut
Copy link

Saigut commented Sep 13, 2021

From testing of my program, after YamuxStream tagging stream being unreadable in onFINReceived at this line, there may still be remaining data to be processed in onLengthRead.
So I think tagging stream being unreadable in onFINReceived is too early.

I have no better idea for now, so I just comment this line to workaround this issue.

@creativeid00
Copy link

I would say that it is more like the stream acceptance callback is called too late.
I got the same issue during bitswap message receiving from a remote go-ipfs peer. The go-ipfs peers sends 3 frames:

  1. frame.type WINDOW_UPDATE (1 '\x1')
    frame.length 0
    frame.flags 1
  2. frame.type DATA (0 '\0')
    frame.length 248
    frame.flags 0
  3. frame.type WINDOW_UPDATE (1 '\x1')
    frame.length 0
    frame.flags 4
    The last frame contains FIN flag that leads to onFINReceived call. Protocol handler is not called neither after the 1st frame nor after the second one. It is called when the last frame received, some response sent to the remote ipfs peer and Multiselect instance is closed. By that time the yamux stream has already been tagged as Unreadable.

@creativeid00
Copy link

Detailed investigation has shown that YamuxStream::doRead returns corresponding error

return deferReadCallback(Error::STREAM_NOT_READABLE, std::move(read_cb_));
only when no pending data is available in the internal_read_buffer_.
if (bytes_available_now >= bytes || (some && bytes_available_now > 0)) {

I'm not sure what is a semantics of YamuxStream::isClosedForRead method but it looks like the size of pending data should be checked within the method also.

@dhuseby dhuseby added the help wanted Extra attention is needed label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants