diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-06 14:04:26 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-06 14:06:58 +0100 |
commit | 1513de1a207bbd95d7440a4d71a09ad31e6d58ca (patch) | |
tree | 6d94629e7d9d761f3dc0d0253fd2bc9abec09b82 | |
parent | a72bce485f41c52ff434c3320541b2f7a9e4e0b1 (diff) |
chap: only cause timeout if actually waiting for something
-rw-r--r-- | src/chap.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/chap.rs b/src/chap.rs index 4a31876..1fbc80e 100644 --- a/src/chap.rs +++ b/src/chap.rs @@ -85,9 +85,11 @@ impl ChapClient { /// Waits for and returns the next packet to send. pub async fn to_send(&mut self) -> ChapPacket { tokio::select! { - packet = self.output_rx.recv() => packet.expect("output channel is closed"), - _ = self.timeout.tick() => self.fail(), - } + packet = self.output_rx.recv() => packet.expect("output channel is closed"), + _ = self.timeout.tick(), if self.state == ChapClientState::Waiting + || self.state == ChapClientState::ResponseSent + || self.state == ChapClientState::ReauthSent => self.fail(), + } } /// Feeds a packet into the state machine for processing. |