Chore: simplify lqosd pattern checks and sorting

This commit is contained in:
Herbert Wolverson committed 2026-03-12 14:52:57 -05:00
1 parent ef84a5f5b3
commit e740c09970
5 files changed
+8 -8

No files matched your search

@@ -65,7 +65,7 @@ pub(super) async fn circuit_watcher(
};
if let Ok(payload) = encode_ws_message(&result) {
if let Err(_) = tx.send(payload).await {
if tx.send(payload).await.is_err() {
info!("Channel is gone");
break;
}
@@ -94,7 +94,7 @@ pub(super) async fn flows_by_circuit(
flows,
};
if let Ok(payload) = encode_ws_message(&result) {
if let Err(_) = tx.send(payload).await {
if tx.send(payload).await.is_err() {
debug!("Channel is gone");
break;
}
@@ -63,7 +63,7 @@ pub(super) async fn ping_monitor(
result: PingState::ChannelTest,
};
if let Ok(payload) = encode_ws_message(&channel_test) {
if let Err(_) = tx.send(payload).await {
if tx.send(payload).await.is_err() {
debug!("Channel is gone");
break;
}
@@ -79,7 +79,7 @@ async fn send_timeout(tx: tokio::sync::mpsc::Sender<std::sync::Arc<Vec<u8>>>, ip
result: PingState::NoResponse,
};
if let Ok(payload) = encode_ws_message(&result)
&& let Err(_) = tx.send(payload).await
&& tx.send(payload).await.is_err()
{
info!("Channel is gone");
}
@@ -177,7 +177,7 @@ impl TimeBuffer {
return 0;
}
let mut slice = slice.to_vec();
slice.sort_by(|a, b| a.cmp(b));
slice.sort();
let mid = slice.len() / 2;
if slice.len() % 2 == 0 {
(slice[mid] + slice[mid - 1]) / 2
@@ -414,7 +414,7 @@ impl TimeBuffer {
.collect();
// Sort the buffer
buffer.sort_unstable_by(|a, b| a.cmp(b));
buffer.sort_unstable();
// Deduplicate and count, decorate with name
buffer
@@ -250,7 +250,7 @@ impl FlowActor {
}
// A flow event arrives
recv(rx) -> msg => {
if let Ok(_) = msg {
if msg.is_ok() {
drain_events(&mut flows, &cmd_rx);
}
}
@@ -354,7 +354,7 @@ pub unsafe extern "C" fn flowbee_handle_events(
let Ok(event) = FlowbeeEvent::read_from_bytes(data_slice) else {
return 0;
};
if let Ok(_) = FLOW_BYTES.push(event) {
if FLOW_BYTES.push(event).is_ok() {
// Wake FlowActor, but coalesce wakeups under load.
let _ = tx.try_send(());
}