fix(router): startup race (#1706)

* fix(router): retry messages when server is not ready for all startup signals

* style(fmt): rustfmt
This commit is contained in:
Aram Drevekenin 2022-09-02 10:21:09 +02:00 committed by GitHub
parent 533a19c26b
commit b17f73bf08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -474,6 +474,7 @@ fn route_action(
should_break should_break
} }
// this should only be used for one-off startup instructions
macro_rules! send_to_screen_or_retry_queue { macro_rules! send_to_screen_or_retry_queue {
($rlocked_sessions:expr, $message:expr, $instruction: expr, $retry_queue:expr) => {{ ($rlocked_sessions:expr, $message:expr, $instruction: expr, $retry_queue:expr) => {{
match $rlocked_sessions.as_ref() { match $rlocked_sessions.as_ref() {
@ -547,7 +548,6 @@ pub(crate) fn route_thread_main(
.unwrap(); .unwrap();
}, },
ClientToServerMsg::TerminalPixelDimensions(pixel_dimensions) => { ClientToServerMsg::TerminalPixelDimensions(pixel_dimensions) => {
// this is experimental, please be cautious implementing this elsewhere
send_to_screen_or_retry_queue!( send_to_screen_or_retry_queue!(
rlocked_sessions, rlocked_sessions,
ScreenInstruction::TerminalPixelDimensions(pixel_dimensions), ScreenInstruction::TerminalPixelDimensions(pixel_dimensions),
@ -555,35 +555,33 @@ pub(crate) fn route_thread_main(
retry_queue retry_queue
); );
}, },
ClientToServerMsg::BackgroundColor(background_color_instruction) => { ClientToServerMsg::BackgroundColor(ref background_color_instruction) => {
rlocked_sessions send_to_screen_or_retry_queue!(
.as_ref() rlocked_sessions,
.unwrap() ScreenInstruction::TerminalBackgroundColor(
.senders background_color_instruction.clone()
.send_to_screen(ScreenInstruction::TerminalBackgroundColor( ),
background_color_instruction, instruction,
)) retry_queue
.unwrap(); );
}, },
ClientToServerMsg::ForegroundColor(foreground_color_instruction) => { ClientToServerMsg::ForegroundColor(ref foreground_color_instruction) => {
rlocked_sessions send_to_screen_or_retry_queue!(
.as_ref() rlocked_sessions,
.unwrap() ScreenInstruction::TerminalForegroundColor(
.senders foreground_color_instruction.clone()
.send_to_screen(ScreenInstruction::TerminalForegroundColor( ),
foreground_color_instruction, instruction,
)) retry_queue
.unwrap(); );
}, },
ClientToServerMsg::ColorRegisters(color_registers) => { ClientToServerMsg::ColorRegisters(ref color_registers) => {
rlocked_sessions send_to_screen_or_retry_queue!(
.as_ref() rlocked_sessions,
.unwrap() ScreenInstruction::TerminalColorRegisters(color_registers.clone()),
.senders instruction,
.send_to_screen(ScreenInstruction::TerminalColorRegisters( retry_queue
color_registers, );
))
.unwrap();
}, },
ClientToServerMsg::NewClient( ClientToServerMsg::NewClient(
client_attributes, client_attributes,