Skip to content
  • eta's avatar
    Get rid of unbounded stream sender, and RawCellStream · c5597541
    eta authored
    Previously, the reactor would use an `UnboundedSender` to send things to
    the `RawCellStream`, in order that the reactor wouldn't block if you
    failed to read from the latter. This is bad, though, since it means
    people can just run us out of memory by sending lots of things.
    
    To fix this, we make the new `StreamReader` type (which does the reading
    parts from `RawCellStream`) keep track of the stream's receive window
    and issue SENDMEs once *it* has consumed enough data to require it, thus
    meaning that we shouldn't get sent enough data to fill the channel
    between reactor and `StreamReader` (and, if we do, that's someone trying
    to flood us, and we abort the circuit).
    
    As hinted to above, the `RawCellStream` was removed and its reading
    functionalities replaced by `StreamReader`; its writing functionalities
    are handled by `StreamTarget` anyway, so we just give out one of those
    for the write end. This now means we don't need any mutexes!
    
    note: this commit introduces a known issue, arti#230
    c5597541