mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 09:45:31 +00:00
udp: uring: combine SendBuffers metadata lookups
This commit is contained in:
parent
1be6d4fa61
commit
aae19c4cb3
2 changed files with 17 additions and 18 deletions
|
|
@ -297,24 +297,25 @@ impl SocketWorker {
|
|||
} else if self.config.statistics.active() {
|
||||
let send_buffer_index = send_buffer_index as usize;
|
||||
|
||||
let (statistics, extra_bytes) =
|
||||
if self.send_buffers.receiver_is_ipv4(send_buffer_index) {
|
||||
(&self.shared_state.statistics_ipv4, EXTRA_PACKET_SIZE_IPV4)
|
||||
} else {
|
||||
(&self.shared_state.statistics_ipv6, EXTRA_PACKET_SIZE_IPV6)
|
||||
};
|
||||
let (response_type, receiver_is_ipv4) =
|
||||
self.send_buffers.response_type_and_ipv4(send_buffer_index);
|
||||
|
||||
let (statistics, extra_bytes) = if receiver_is_ipv4 {
|
||||
(&self.shared_state.statistics_ipv4, EXTRA_PACKET_SIZE_IPV4)
|
||||
} else {
|
||||
(&self.shared_state.statistics_ipv6, EXTRA_PACKET_SIZE_IPV6)
|
||||
};
|
||||
|
||||
statistics
|
||||
.bytes_sent
|
||||
.fetch_add(result as usize + extra_bytes, Ordering::Relaxed);
|
||||
|
||||
let response_counter =
|
||||
match self.send_buffers.response_type(send_buffer_index) {
|
||||
ResponseType::Connect => &statistics.responses_sent_connect,
|
||||
ResponseType::Announce => &statistics.responses_sent_announce,
|
||||
ResponseType::Scrape => &statistics.responses_sent_scrape,
|
||||
ResponseType::Error => &statistics.responses_sent_error,
|
||||
};
|
||||
let response_counter = match response_type {
|
||||
ResponseType::Connect => &statistics.responses_sent_connect,
|
||||
ResponseType::Announce => &statistics.responses_sent_announce,
|
||||
ResponseType::Scrape => &statistics.responses_sent_scrape,
|
||||
ResponseType::Error => &statistics.responses_sent_error,
|
||||
};
|
||||
|
||||
response_counter.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,12 +191,10 @@ impl SendBuffers {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn receiver_is_ipv4(&mut self, index: usize) -> bool {
|
||||
self.buffers[index].receiver_is_ipv4
|
||||
}
|
||||
pub fn response_type_and_ipv4(&self, index: usize) -> (ResponseType, bool) {
|
||||
let buffer = self.buffers.get(index).unwrap();
|
||||
|
||||
pub fn response_type(&mut self, index: usize) -> ResponseType {
|
||||
self.buffers[index].response_type
|
||||
(buffer.response_type, buffer.receiver_is_ipv4)
|
||||
}
|
||||
|
||||
pub fn mark_index_as_free(&mut self, index: usize) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue