Skip to content

Commit ab3e4a2

Browse files
committed
argue why at_exit_imp is fine
1 parent 22457de commit ab3e4a2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libstd/sys_common/at_exit_imp.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub fn cleanup() {
6464
if !queue.is_null() {
6565
let queue: Box<Queue> = Box::from_raw(queue);
6666
for to_run in *queue {
67+
// We are not holding any lock, so reentrancy is fine.
6768
to_run();
6869
}
6970
}
@@ -75,9 +76,8 @@ pub fn push(f: Box<dyn FnBox()>) -> bool {
7576
unsafe {
7677
let _guard = LOCK.lock();
7778
if init() {
78-
// This could reentrantly call `push` again, which is a problem because
79-
// `LOCK` allows reentrancy!
80-
// FIXME: Add argument why this is okay.
79+
// We are just moving `f` around, not calling it.
80+
// There is no possibility of reentrancy here.
8181
(*QUEUE).push(f);
8282
true
8383
} else {

0 commit comments

Comments
 (0)