Skip to content

write method calls send_data before poll_ready #78

Open

Description

@WesleyRosenblum

On stream.rs#L28-L29, stream.send_data is called prior to stream.poll_ready.

stream.poll_ready should be called first, similar to as described in https://docs.rs/futures/latest/futures/sink/trait.Sink.html#tymethod.poll_ready.

Thanks for considering this issue, and let me know if you have any questions!

Activity

  1. seanmonstar commented on Feb 8, 2022

    @seanmonstar
    Member

    Huh, good point. I don't recall why the order was switched there... Granted, technically we aren't using Sink specifically, but the pattern is definitely similar.

  2. camshaft commented on Feb 8, 2022

    @camshaft
    Contributor

    Another option would be to rename the methods to something like set_data and poll_send_data, which it seems like is how it's being used currently.

    But if we're considering an API change, I'm not sure why we couldn't just change it to:

    fn poll_send_data(&mut self, buf: &mut dyn Buf) -> Poll<Result<()>>;

    It would remove the need for the stream implementation to convert/store the buffer and make things a bit simpler, IMO.

  3. seanmonstar commented on Feb 8, 2022

    @seanmonstar
    Member

    That change would require that the bytes always be copied out, no? I guess unless it was already a Bytes. Whereas currently, by passing ownership of the impl Buf, a QUIC implementation could copy, but it could also choose to store it, kinda like h2 does.

  4. camshaft commented on Feb 8, 2022

    @camshaft
    Contributor

    Not necessarily. If the caller used copy_to_bytes with chunk lengths the Buf impl would specialize on it:

    let len = buf.chunk().len();
    let bytes = buf.copy_to_bytes(len);

    (see, for example, impl Buf for Bytes)

  5. seanmonstar commented on Feb 9, 2022

    @seanmonstar
    Member

    Yea, that's what I meant by if it was already a Bytes. If it was a custom impl Buf, it would end up being copied into a Bytes... I think there's merit in discussing if the API around sending data is the right one. But for this specific issue, it also looks like that's a simple bug: the calls should be reversed.

  6. added
    E-easyEffort: easy. A task that would be a great starting point for a new contributor.
    C-bugCategory: bug. Something is wrong. This is bad!
    on Feb 9, 2022
  7. Ruben2424 commented on Sep 20, 2026

    @Ruben2424
    Contributor

    I merged #360 with changes in that area. Leaving this issue open to discuss if and how the methods should change.

  8. added
    B-rfcBlocked: request for comments. Needs more discussion.
    A-traitArea: quic trait abstraction
    and removed
    E-easyEffort: easy. A task that would be a great starting point for a new contributor.
    C-bugCategory: bug. Something is wrong. This is bad!
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-traitArea: quic trait abstractionB-rfcBlocked: request for comments. Needs more discussion.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions