Skip to content

Commit adf2af7

Browse files
committed
Implement function to notify the awaiter of an active session
1 parent dafd5b6 commit adf2af7

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

crates/hotfix/src/session.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ impl<M: FixMessage, S: MessageStore> Session<M, S> {
689689
if !is_active {
690690
// we are currently outside scheduled session time
691691
self.initiate_graceful_logout("End of session time").await;
692+
} else {
693+
self.state.notify_session_awaiter();
692694
}
693695

694696
let deadline = Instant::now() + Duration::from_secs(SCHEDULE_CHECK_INTERVAL);

crates/hotfix/src/session/state.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl SessionState {
103103
}
104104

105105
pub fn register_session_awaiter(
106-
&self,
106+
&mut self,
107107
responder: oneshot::Sender<AwaitingActiveSessionResponse>,
108108
) {
109109
match self {
@@ -118,7 +118,7 @@ impl SessionState {
118118
error!("failed to send session awaiter response: {err:?}");
119119
}
120120
} else {
121-
// set the session_awaiter on the current state
121+
*session_awaiter = Some(responder);
122122
}
123123
}
124124
_ => {
@@ -129,6 +129,19 @@ impl SessionState {
129129
}
130130
}
131131
}
132+
133+
pub fn notify_session_awaiter(&mut self) {
134+
if let SessionState::Disconnected {
135+
session_awaiter, ..
136+
} = self
137+
{
138+
if let Some(awaiter) = session_awaiter.take() {
139+
if let Err(err) = awaiter.send(AwaitingActiveSessionResponse::Active) {
140+
error!("failed to send session awaiter response: {err:?}");
141+
}
142+
}
143+
}
144+
}
132145
}
133146

134147
/// Session state we're in while processing messages we requested to be resent.

0 commit comments

Comments
 (0)