Skip to content

Commit ece048d

Browse files
committed
Use stronger memory ordering for initialized flag synchronization
Apply code review feedback to use Ordering::AcqRel for the swap operation and Ordering::Release for the store operation to ensure proper synchronization across threads when setting the initialized flag.
1 parent b2f3adf commit ece048d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/stdlib/src/sqlite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ mod _sqlite {
903903
type Args = ConnectArgs;
904904

905905
fn init(zelf: PyRef<Self>, args: Self::Args, vm: &VirtualMachine) -> PyResult<()> {
906-
let was_initialized = Radium::swap(&zelf.initialized, false, Ordering::Relaxed);
906+
let was_initialized = Radium::swap(&zelf.initialized, false, Ordering::AcqRel);
907907

908908
// Reset factories to their defaults, matching CPython's behavior.
909909
zelf.reset_factories(vm);
@@ -931,7 +931,7 @@ mod _sqlite {
931931

932932
let mut guard = zelf.db.lock();
933933
*guard = Some(db);
934-
Radium::store(&zelf.initialized, true, Ordering::Relaxed);
934+
Radium::store(&zelf.initialized, true, Ordering::Release);
935935
Ok(())
936936
}
937937
}

0 commit comments

Comments
 (0)