Skip to content

Commit 32d597c

Browse files
committed
fix: enforce Send/Sync bounds and correct OnceCell instantiation for async queue
1 parent b2e3fab commit 32d597c

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/provenance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::println;
22
use core::sync::atomic::Ordering;
3-
use crate::vfs::{STATE_VERIFIED, STATE_CORRUPTED, CachedVfsBlock};
3+
use crate::vfs::{STATE_VERIFIED, STATE_CORRUPTED};
44
use crate::task::CryptoVerificationJob;
55

66
#[derive(Debug, Clone)]

src/task/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ pub struct CryptoVerificationJob {
3131
}
3232

3333
// Global thread-safe async queue for block validation
34-
pub static VERIFICATION_QUEUE: OnceCell<ArrayQueue<CryptoVerificationJob>> = OnceCell::new();
34+
#[derive(Clone, Copy)]
35+
pub struct CryptoVerificationJob {
36+
pub block_ptr: *mut CachedVfsBlock,
37+
pub expected_hash: [u8; 32],
38+
}
39+
40+
unsafe impl Send for CryptoVerificationJob {}
41+
unsafe impl Sync for CryptoVerificationJob {}
42+
43+
pub static VERIFICATION_QUEUE: OnceCell<ArrayQueue<CryptoVerificationJob>> = OnceCell::uninit();
3544

3645
pub fn init_queue() {
3746
VERIFICATION_QUEUE.init_once(|| ArrayQueue::new(32));

src/vfs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ pub const STATE_PENDING: u8 = 0;
9696
pub const STATE_VERIFIED: u8 = 1;
9797
pub const STATE_CORRUPTED: u8 = 2;
9898

99-
#[derive(Clone)]
10099
pub struct CachedVfsBlock {
101100
pub block_id: u64,
102101
pub data: [u8; 4096],

0 commit comments

Comments
 (0)