fix(metrics): use AtomicU32 for drop counter to support MIPS targets

Also bumps version to 0.4.1.
This commit is contained in:
Nils Andreas Svee committed 2026-04-14 02:14:55 +07:00
1 parent 99e80c381d
commit 8739ed4419
4 files changed
+10 -10

No files matched your search

Generated
+1 -1
View File
@@ -392,7 +392,7 @@ dependencies = [
[[package]] [[package]]
name = "sqm-autorate-rust" name = "sqm-autorate-rust"
version = "0.4.0" version = "0.4.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"fastrand", "fastrand",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "sqm-autorate-rust" name = "sqm-autorate-rust"
version = "0.4.0" version = "0.4.1"
edition = "2024" edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+2 -2
View File
@@ -19,7 +19,7 @@ use ::log::{debug, info};
use std::collections::HashMap; use std::collections::HashMap;
use std::net::IpAddr; use std::net::IpAddr;
use std::str::FromStr; use std::str::FromStr;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::sync::mpsc::{channel, sync_channel, RecvTimeoutError}; use std::sync::mpsc::{channel, sync_channel, RecvTimeoutError};
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
use std::thread::sleep; use std::thread::sleep;
@@ -95,7 +95,7 @@ fn main() -> anyhow::Result<()> {
let (error_tx, error_rx) = channel::<anyhow::Error>(); let (error_tx, error_rx) = channel::<anyhow::Error>();
let (reselect_tx, reselect_rx) = channel(); let (reselect_tx, reselect_rx) = channel();
let dropped = Arc::new(AtomicU64::new(0)); let dropped = Arc::new(AtomicU32::new(0));
let (metrics_tx, metrics_thread_handle) = if config.observability_enabled { let (metrics_tx, metrics_thread_handle) = if config.observability_enabled {
let (tx, rx) = sync_channel(1000); let (tx, rx) = sync_channel(1000);
+6 -6
View File
@@ -5,7 +5,7 @@ use log::{error, info, warn};
use rustix::time::ClockId; use rustix::time::ClockId;
use std::fmt::Write; use std::fmt::Write;
use std::net::{IpAddr, TcpStream, UdpSocket}; use std::net::{IpAddr, TcpStream, UdpSocket};
use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::mpsc::{Receiver, RecvTimeoutError, SyncSender}; use std::sync::mpsc::{Receiver, RecvTimeoutError, SyncSender};
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
@@ -116,18 +116,18 @@ pub enum Metric {
tags: &'static [(&'static str, &'static str)], tags: &'static [(&'static str, &'static str)],
}, },
Dropped { Dropped {
count: u64, count: u32,
}, },
} }
#[derive(Clone)] #[derive(Clone)]
pub struct MetricsSender { pub struct MetricsSender {
tx: Option<SyncSender<(Metric, u64)>>, tx: Option<SyncSender<(Metric, u64)>>,
dropped: Arc<AtomicU64>, dropped: Arc<AtomicU32>,
} }
impl MetricsSender { impl MetricsSender {
pub fn new(tx: SyncSender<(Metric, u64)>, dropped: Arc<AtomicU64>) -> Self { pub fn new(tx: SyncSender<(Metric, u64)>, dropped: Arc<AtomicU32>) -> Self {
Self { Self {
tx: Some(tx), tx: Some(tx),
dropped, dropped,
@@ -137,7 +137,7 @@ impl MetricsSender {
pub fn disabled() -> Self { pub fn disabled() -> Self {
Self { Self {
tx: None, tx: None,
dropped: Arc::new(AtomicU64::new(0)), dropped: Arc::new(AtomicU32::new(0)),
} }
} }
@@ -153,7 +153,7 @@ impl MetricsSender {
pub struct Metrics { pub struct Metrics {
pub config: Config, pub config: Config,
pub metrics_dropped: Arc<AtomicU64>, pub metrics_dropped: Arc<AtomicU32>,
pub metrics_rx: Receiver<(Metric, u64)>, pub metrics_rx: Receiver<(Metric, u64)>,
} }