mux: fix disconnect when a lot of output is dumped to the terminal
The root cause and secondary effect were a little surprising: the mux pub/sub notification pipe filled up and because the mux notify routine uses `retain` with the success of the send as a predicate it meant that the full pipe resulted in the muxer killing that end of the subscriber and that in turn made the ClientSession loop fail when it was dispatching a notify on the other end, which terminated the loop and disconnected the client. Now, with this fixed, we have a flow control problem and the terminal will remain busy with ctrl-c not being effective in the mux session.
This commit is contained in:
1 parent
3352013614
commit
4442e8030d
2 files changed
+7
-3
No files matched your search
@@ -579,7 +579,7 @@ impl<S: ReadAndWrite> ClientSession<S> {
|
||||
Ok(decoded) => {
|
||||
log::trace!("writing pdu with serial {}", decoded.serial);
|
||||
decoded.pdu.encode(&mut self.stream, decoded.serial)?;
|
||||
self.stream.flush()?;
|
||||
self.stream.flush().context("while flushing stream")?;
|
||||
}
|
||||
Err(TryRecvError::Empty) => break,
|
||||
Err(TryRecvError::Disconnected) => bail!("ClientSession was destroyed"),
|
||||
@@ -592,7 +592,7 @@ impl<S: ReadAndWrite> ClientSession<S> {
|
||||
MuxNotification::TabOutput(tab_id) => tabs_to_output.insert(tab_id),
|
||||
},
|
||||
Err(TryRecvError::Empty) => break,
|
||||
Err(TryRecvError::Disconnected) => bail!("ClientSession was destroyed"),
|
||||
Err(TryRecvError::Disconnected) => bail!("mux_rx is Disconnected"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,11 @@ pub struct PollableSender<T> {
|
||||
|
||||
impl<T: Send + Sync + 'static> PollableSender<T> {
|
||||
pub fn send(&self, item: T) -> anyhow::Result<()> {
|
||||
self.write.lock().unwrap().write_all(b"x")?;
|
||||
// Attempt to write to the pipe; if it fails due to
|
||||
// being full, that's fine: it means that the other end
|
||||
// is going to be signalled already so they won't miss
|
||||
// anything if our write doesn't happen.
|
||||
self.write.lock().unwrap().write_all(b"x").ok();
|
||||
self.sender.send(item).map_err(Error::msg)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user