Skip to content

Commit

Permalink
refact: add delete ServerState instances for StateBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
justRkive committed Sep 19, 2024
1 parent 2252c04 commit 85d58af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/async_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub mod resolver_error;
pub mod server_info;
pub mod slist;
pub mod state_block;
pub mod server_state;
pub mod server_entry;

use self::lookup_response::LookupResponse;
Expand Down
9 changes: 4 additions & 5 deletions src/async_resolver/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@ impl Resolution {
let mut iter = 0..upper_limit_of_retransmission_loops;
'global_cycle: while let Some(_retransmission) = iter.next() {
println!("Retransmission: {}", _retransmission);
let number_of_servers = self.state_block.get_server_state().get_servers().len();
let number_of_servers = self.state_block.get_servers().len();

for _ in 0..number_of_servers {
println!("Server retrans");
let server_state = self.state_block.get_server_state();
let server_entry_clone = server_state.get_current_server_entry().clone();
let server_entry_clone = self.state_block.get_current_server_entry().clone();
if !server_entry_clone.is_active() { continue; }

//start timer
Expand All @@ -113,8 +112,8 @@ impl Resolution {

if self.received_appropriate_response() { break 'global_cycle }

self.state_block.get_server_state().get_current_server_entry().increment_retransmissions();
self.state_block.get_server_state().increment_current_server_index();
self.state_block.get_current_server_entry().increment_retransmissions();
self.state_block.increment_current_server_index();
}

// // let mut servers_iter: std::slice::Iter<super::server_entry::ServerEntry> = servers_to_query.iter();
Expand Down
5 changes: 4 additions & 1 deletion src/async_resolver/state_block.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use tokio::time::Instant;

use crate::async_resolver::server_state::ServerState;
use super::{server_entry::ServerEntry, server_info::ServerInfo};

/// This struct represent the state of information of a pending request.
Expand Down Expand Up @@ -94,4 +93,8 @@ impl StateBlock {
pub fn get_current_server_entry(&mut self) -> &mut ServerEntry {
&mut self.servers[self.current_server_index]
}

pub fn get_servers(&self) -> &Vec<ServerEntry> {
&self.servers
}
}

0 comments on commit 85d58af

Please sign in to comment.