Skip to content

Commit 00e4c92

Browse files
committed
apply review
1 parent efdf8a7 commit 00e4c92

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

crates/stdlib/src/multiprocessing.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ mod _multiprocessing {
230230

231231
impl Drop for SemHandle {
232232
fn drop(&mut self) {
233+
// Guard against default/uninitialized state.
234+
// Note: SEM_FAILED is (sem_t*)-1, not null, but valid handles are never null
235+
// and SEM_FAILED is never stored (error is returned immediately on sem_open failure).
233236
if !self.raw.is_null() {
234237
// SEM_CLOSE(sem) sem_close(sem)
235238
unsafe {
@@ -433,9 +436,8 @@ mod _multiprocessing {
433436
));
434437
}
435438
// if (self->count > 1) { --self->count; Py_RETURN_NONE; }
436-
let current = self.count.load(Ordering::Acquire);
437-
if current > 1 {
438-
self.count.store(current - 1, Ordering::Release);
439+
if self.count.load(Ordering::Acquire) > 1 {
440+
self.count.fetch_sub(1, Ordering::Release);
439441
return Ok(());
440442
}
441443
// assert(self->count == 1);

0 commit comments

Comments
 (0)