Skip to content

Commit

Permalink
make target mips-unknown-linux-gnu happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Aug 5, 2024
1 parent 714ed0b commit 7485f34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ protocol = "sparse"
# target = "aarch64-apple-ios"
# target = "x86_64-pc-windows-msvc"
# target = "x86_64-apple-darwin"

[target.'cfg(target_arch = "mips")']
linker = "mips-linux-gnu-gcc"
6 changes: 3 additions & 3 deletions src/traffic_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub unsafe extern "C" fn overtls_set_traffic_status_callback(
log::error!("set traffic status callback failed");
}
if send_interval_secs > 0 {
SEND_INTERVAL_SECS.store(send_interval_secs as u64, std::sync::atomic::Ordering::Relaxed);
SEND_INTERVAL_SECS.store(send_interval_secs, std::sync::atomic::Ordering::Relaxed);
}
}

Expand All @@ -45,7 +45,7 @@ unsafe impl Send for TrafficStatusCallback {}
unsafe impl Sync for TrafficStatusCallback {}

static TRAFFIC_STATUS_CALLBACK: Mutex<Option<TrafficStatusCallback>> = Mutex::new(None);
static SEND_INTERVAL_SECS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
static SEND_INTERVAL_SECS: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(1);

static TRAFFIC_STATUS: LazyLock<Mutex<TrafficStatus>> = LazyLock::new(|| Mutex::new(TrafficStatus::default()));
static TIME_STAMP: LazyLock<Mutex<std::time::Instant>> = LazyLock::new(|| Mutex::new(std::time::Instant::now()));
Expand All @@ -68,7 +68,7 @@ pub(crate) fn traffic_status_update(delta_tx: usize, delta_rx: usize) -> Result<
};
let old_time = { *TIME_STAMP.lock().map_err(|e| Error::from(e.to_string()))? };
let interval_secs = SEND_INTERVAL_SECS.load(std::sync::atomic::Ordering::Relaxed);
if std::time::Instant::now().duration_since(old_time).as_secs() >= interval_secs {
if std::time::Instant::now().duration_since(old_time).as_secs() >= interval_secs as u64 {
send_traffic_stat(&traffic_status)?;
{
let mut time_stamp = TIME_STAMP.lock().map_err(|e| Error::from(e.to_string()))?;
Expand Down

0 comments on commit 7485f34

Please sign in to comment.