Skip to content

Commit 54e8586

Browse files
committed
Only attempt logout out of session if the session is connected
1 parent df15f92 commit 54e8586

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

crates/hotfix/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ impl<M: FixMessage, S: MessageStore> Session<M, S> {
809809
self.logout_and_terminate("internal error").await;
810810
}
811811
}
812-
} else {
812+
} else if self.state.is_connected() {
813813
// we are currently outside scheduled session time
814814
self.initiate_graceful_logout("End of session time").await;
815815
}

crates/hotfix/src/session/state.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ impl SessionState {
120120
}
121121
}
122122

123+
pub fn is_connected(&self) -> bool {
124+
self.get_writer().is_some()
125+
}
126+
123127
pub fn try_transition_to_awaiting_logout(&mut self) -> bool {
124128
if matches!(self, SessionState::AwaitingLogout { .. }) {
125129
debug!("already in awaiting logout state");

0 commit comments

Comments
 (0)