mirror of
https://github.com/wez/wezterm.git
synced 2024-11-27 12:23:46 +03:00
prep for dealing with unilaterally sent pdus
This commit is contained in:
parent
764597851c
commit
1d2b4291d3
@ -146,10 +146,10 @@ fn run_terminal_gui(config: Arc<config::Config>, opts: &StartCommand) -> Result<
|
||||
};
|
||||
|
||||
let domain: Arc<dyn Domain> = if opts.mux_client_as_default_domain {
|
||||
let client = Client::new_unix_domain(&config)?;
|
||||
let client = Client::new_unix_domain(&config, None)?;
|
||||
Arc::new(ClientDomain::new(client))
|
||||
} else if opts.mux_tls_client_as_default_domain {
|
||||
let client = Client::new_tls(&config)?;
|
||||
let client = Client::new_tls(&config, None)?;
|
||||
Arc::new(ClientDomain::new(client))
|
||||
} else {
|
||||
Arc::new(LocalDomain::new(&config)?)
|
||||
@ -210,7 +210,7 @@ fn main() -> Result<(), Error> {
|
||||
run_terminal_gui(config, &start)
|
||||
}
|
||||
SubCommand::Cli(cli) => {
|
||||
let client = Client::new_unix_domain(&config)?;
|
||||
let client = Client::new_unix_domain(&config, None)?;
|
||||
match cli.sub {
|
||||
CliSubCommand::List => {
|
||||
let cols = vec![
|
||||
|
@ -57,8 +57,12 @@ macro_rules! rpc {
|
||||
};
|
||||
}
|
||||
|
||||
fn client_thread(mut stream: Box<dyn ReadAndWrite>, rx: Receiver<ReaderMessage>) -> Fallible<()> {
|
||||
let mut next_serial = 0u64;
|
||||
fn client_thread(
|
||||
mut stream: Box<dyn ReadAndWrite>,
|
||||
rx: Receiver<ReaderMessage>,
|
||||
_unilaterals: Option<Sender<Pdu>>,
|
||||
) -> Fallible<()> {
|
||||
let mut next_serial = 1u64;
|
||||
let mut promises = HashMap::new();
|
||||
loop {
|
||||
let msg = if promises.is_empty() {
|
||||
@ -104,11 +108,11 @@ fn client_thread(mut stream: Box<dyn ReadAndWrite>, rx: Receiver<ReaderMessage>)
|
||||
}
|
||||
|
||||
impl Client {
|
||||
pub fn new(stream: Box<dyn ReadAndWrite>) -> Self {
|
||||
pub fn new(stream: Box<dyn ReadAndWrite>, unilaterals: Option<Sender<Pdu>>) -> Self {
|
||||
let (sender, receiver) = channel();
|
||||
|
||||
thread::spawn(move || {
|
||||
if let Err(e) = client_thread(stream, receiver) {
|
||||
if let Err(e) = client_thread(stream, receiver, unilaterals) {
|
||||
log::error!("client thread ended: {}", e);
|
||||
}
|
||||
});
|
||||
@ -116,7 +120,10 @@ impl Client {
|
||||
Self { sender }
|
||||
}
|
||||
|
||||
pub fn new_unix_domain(config: &Arc<Config>) -> Fallible<Self> {
|
||||
pub fn new_unix_domain(
|
||||
config: &Arc<Config>,
|
||||
unilaterals: Option<Sender<Pdu>>,
|
||||
) -> Fallible<Self> {
|
||||
let sock_path = Path::new(
|
||||
config
|
||||
.mux_server_unix_domain_socket_path
|
||||
@ -125,10 +132,10 @@ impl Client {
|
||||
);
|
||||
info!("connect to {}", sock_path.display());
|
||||
let stream = Box::new(UnixStream::connect(sock_path)?);
|
||||
Ok(Self::new(stream))
|
||||
Ok(Self::new(stream, unilaterals))
|
||||
}
|
||||
|
||||
pub fn new_tls(config: &Arc<Config>) -> Fallible<Self> {
|
||||
pub fn new_tls(config: &Arc<Config>, unilaterals: Option<Sender<Pdu>>) -> Fallible<Self> {
|
||||
let remote_address = config
|
||||
.mux_server_remote_address
|
||||
.as_ref()
|
||||
@ -171,7 +178,7 @@ impl Client {
|
||||
e
|
||||
)
|
||||
})?);
|
||||
Ok(Self::new(stream))
|
||||
Ok(Self::new(stream, unilaterals))
|
||||
}
|
||||
|
||||
pub fn send_pdu(&self, pdu: Pdu) -> Future<Pdu> {
|
||||
|
Loading…
Reference in New Issue
Block a user