Skip to content

Commit fdaddcb

Browse files
committed
Modify test to remove counter
1 parent 7d70746 commit fdaddcb

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

Modules/_multiprocessing/semaphore.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,11 +1025,11 @@ remove_counter(CounterObject *counter)
10251025

10261026
memset(counter, 0, sizeof(CounterObject));
10271027
--shm_semlock_counters.header->n_semlocks;
1028-
/* ---
1028+
/* --- */
10291029
if (shm_semlock_counters.header->n_semlocks == 0) {
10301030
res = delete_shm_semlock_counters(false);
10311031
}
1032-
-- */
1032+
/* -- */
10331033
return res;
10341034
}
10351035

@@ -1535,14 +1535,18 @@ semlock_dealloc(SemLockObject* self)
15351535
SEM_CLOSE(self->handle_mutex);
15361536
}
15371537

1538-
ACQUIRE_GLOCK;
1539-
DEBUG_PID_FUNC(self->name, self->handle_mutex, self->counter, "");
1540-
--self->counter->n_instances;
1541-
if (self->counter && (self->created || !self->counter->n_instances)) {
1542-
res = remove_counter(self->counter);
1543-
self->counter = NULL;
1538+
if (ACQUIRE_GLOCK) {
1539+
DEBUG_PID_FUNC(self->name, self->handle_mutex, self->counter, "");
1540+
if (self->counter) {
1541+
DEBUG_PID_FUNC(self->name, self->handle_mutex, self->counter, "decref counter");
1542+
--self->counter->n_instances;
1543+
if (!self->counter->n_instances) {
1544+
res = remove_counter(self->counter);
1545+
self->counter = NULL;
1546+
}
1547+
}
1548+
RELEASE_GLOCK;
15441549
}
1545-
RELEASE_GLOCK;
15461550
if (!res ) {
15471551
delete_glock();
15481552
}

0 commit comments

Comments
 (0)