Server.lock_channel
Lock a wait-for channel, blocking later lock attempts on it.
Source and package
- Qualified name
-
libtmux::server:: Server:: lock _channel - Module
- server
- Declared in
Server- Package
- libtmux
- Source
- crates/libtmux/src/server/channels.rs
-
Description#
Self::with_channel_lock()pairs this with the unlock, which is usually what a caller wants. A lock another locker holds waits for its turn, up toServer::default_timeout().Errors
Returns an error when tmux refuses the channel name, and
crate::ErrorKind::Timeoutwhen the channel is still held afterServer::default_timeout(). A handle fromServer::over_control_mode()is refused, for the reasonSelf::wait_for_channel()gives.Cancel safety
Nothing is left held. The lock is taken in a task of its own, so a lock that is dropped -- or that runs out of time -- while queued behind another locker is not withdrawn from tmux, which cannot withdraw one: it is granted in turn and released at once. Between those two, later lockers wait as they would for any other holder.
Shutting the server down while such a lock is queued is the exception, because it kills the client: tmux then grants the lock to a client that is gone and every later lock on the channel blocks forever. A tmux defect (
cmd_wait_for_unlockincmd-wait-for.c), measured on 3.2a, 3.7d and 3.8.