Client::poll_ready and send_request may return Connection Errors (#132)
Closes #131
This commit is contained in:
@@ -337,10 +337,7 @@ where
|
||||
self.ensure_can_reserve(frame.promised_id())?;
|
||||
|
||||
// Make sure that the stream state is valid
|
||||
store[stream]
|
||||
.state
|
||||
.ensure_recv_open()
|
||||
.map_err(|e| e.into_connection_recv_error())?;
|
||||
store[stream].state.ensure_recv_open()?;
|
||||
|
||||
// TODO: Streams in the reserved states do not count towards the concurrency
|
||||
// limit. However, it seems like there should be a cap otherwise this
|
||||
|
||||
@@ -56,6 +56,9 @@ where
|
||||
|
||||
/// Task that calls `poll_complete`.
|
||||
task: Option<task::Task>,
|
||||
|
||||
/// If the connection errors, a copy is kept for any StreamRefs.
|
||||
conn_error: Option<proto::Error>,
|
||||
}
|
||||
|
||||
impl<B, P> Streams<B, P>
|
||||
@@ -71,6 +74,7 @@ where
|
||||
recv: Recv::new(&config),
|
||||
send: Send::new(&config),
|
||||
task: None,
|
||||
conn_error: None,
|
||||
},
|
||||
store: Store::new(),
|
||||
})),
|
||||
@@ -193,6 +197,8 @@ where
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
actions.conn_error = Some(err.shallow_clone());
|
||||
|
||||
last_processed_id
|
||||
}
|
||||
|
||||
@@ -337,6 +343,7 @@ where
|
||||
let mut me = self.inner.lock().unwrap();
|
||||
let me = &mut *me;
|
||||
|
||||
me.actions.ensure_no_conn_error()?;
|
||||
me.actions.send.ensure_next_stream_id()?;
|
||||
|
||||
// The `pending` argument is provided by the `Client`, and holds
|
||||
@@ -424,6 +431,7 @@ where
|
||||
let mut me = self.inner.lock().unwrap();
|
||||
let me = &mut *me;
|
||||
|
||||
me.actions.ensure_no_conn_error()?;
|
||||
me.actions.send.ensure_next_stream_id()?;
|
||||
|
||||
if let Some(key) = key {
|
||||
@@ -733,4 +741,12 @@ where
|
||||
self.recv.ensure_not_idle(id)
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_no_conn_error(&self) -> Result<(), proto::Error> {
|
||||
if let Some(ref err) = self.conn_error {
|
||||
Err(err.shallow_clone())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user