File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments