Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/ankaios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ pub struct Ankaios{
response_receiver: mpsc::Receiver<Response>,
/// The control interface instance that is used to communicate with the Control Interface.
control_interface: ControlInterface,
/// Flag used to correct the connection checks, will be removed in the near future
connection_established: bool,
/// The timeout used for the requests.
pub timeout: Duration,
}
Expand Down Expand Up @@ -198,6 +200,7 @@ impl Ankaios {
let mut object = Self{
response_receiver,
control_interface: ControlInterface::new(response_sender),
connection_established: false,
timeout,
};

Expand Down Expand Up @@ -688,11 +691,20 @@ impl Ankaios {

match response.content {
ResponseType::CompleteState(complete_state) => {
self.connection_established = true;

Ok(*complete_state)
},
ResponseType::Error(error) => {
log::error!("Error while trying to get the state: {error}");
Err(AnkaiosError::AnkaiosResponseError(error))
if self.connection_established {
log::error!("Error while trying to get the state: {error}");
return Err(AnkaiosError::AnkaiosResponseError(error));
}

// flag connection as established, will be removed in the near future
self.connection_established = true;

Ok(CompleteState::default())
},
_ => {
log::error!("Received unexpected response type.");
Expand Down Expand Up @@ -880,6 +892,7 @@ fn generate_test_ankaios(mock_control_interface: ControlInterface) -> (Ankaios,
(Ankaios{
response_receiver,
control_interface: mock_control_interface,
connection_established: true,
timeout: Duration::from_millis(50),
},
response_sender)
Expand Down