Promote SendRequest::pending to an OpaqueStreamRef. (#281)

Because `self.pending` doesn't necessarily get cleaned up in a timely fashion -
rather, only when the user calls `poll_ready()` - it was possible for it to
refer to a stream that has already been closed. This would lead to a panic the
next time that `poll_ready()` was called.

Instead, use an `OpaqueStreamRef`, bumping the refcount.

A change to an existing test is included which demonstrates the issue.
This commit is contained in:
Geoffry Song
2018-06-06 10:16:22 -07:00
committed by Sean McArthur
parent 1b9469ff75
commit 23234fa14f
5 changed files with 11 additions and 14 deletions

View File

@@ -223,7 +223,7 @@ pub struct Handshake<T, B: IntoBuf = Bytes> {
/// [`Error`]: ../struct.Error.html
pub struct SendRequest<B: IntoBuf> {
inner: proto::Streams<B::Buf, Peer>,
pending: Option<proto::StreamKey>,
pending: Option<proto::OpaqueStreamRef>,
}
/// Returns a `SendRequest` instance once it is ready to send at least one
@@ -568,7 +568,7 @@ where
.map_err(Into::into)
.map(|stream| {
if stream.is_pending_open() {
self.pending = Some(stream.key());
self.pending = Some(stream.clone_to_opaque());
}
let response = ResponseFuture {