Refactor the stream-closing logic in tor-proto
This commit changes the permitted call sequence to StreamMap::terminate
to allow up to one explicit ClosePendingStream
, followed by exactly one mpsc channel closure. It also changes the behavior on an incorrect call sequence to return a Bug
, rather than panicking.
Making these changes allows a fair amount of refactoring and code removal in IncomingStream
.
Closes #1065 (closed).
Also fixes a bug where IncomingStream::discard()
did not actually prevent an End
from being sent.