Skip to content

[SCTP] Stream::read: partial read OR returning the expected size of the buffer #273

@melekes

Description

@melekes

The problem I'm facing right now is where I'm passing a buffer to Stream::read, which is not big enough (Error::ErrShortBuffer). Note there's no indication of the expected size => you're forced to guess the number.

Also note it's different from TcpStream https://doc.rust-lang.org/std/io/trait.Read.html#tymethod.read, which partially reads the data and does not put any restrictions on the size of the buffer (i.e. you, the caller, is in control of how fast you're consuming data).

I can see that the code in Pion is identical to one here, but I nonetheless think we need to change something.

Either

  1. switch to "tcp stream" partial reading model
  2. indicate the expected buffer size by changing ErrShortBuffer to be ErrShortBuffer { min: usize }

(1) is more "rust" therefore preferred.

There's also talk about auto-tuning buffer size, which is slightly related pion/sctp#218 (comment)


https://github.com/webrtc-rs/sctp/blob/ed21dae1aa7dc5f37bd40fb344fa19746b932570/src/queue/reassembly_queue.rs#L282

also, why are we subtracting n_bytes before we've actually successfully written them to client's buffer?


Migrated from webrtc-rs/sctp#28

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededsubcrate:dataFor issues specific to the data cratesubcrate:sctpFor issues specific to the SCTP crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions