]> git.lizzy.rs Git - rust.git/commitdiff
argue why at_exit_imp is fine
authorRalf Jung <post@ralfj.de>
Mon, 6 Aug 2018 11:53:38 +0000 (13:53 +0200)
committerRalf Jung <post@ralfj.de>
Mon, 6 Aug 2018 11:53:38 +0000 (13:53 +0200)
src/libstd/sys_common/at_exit_imp.rs

index 633605039afdd9cb0148e07a74a91ece0b2df977..30019088eb689dc586ff01d63152373fed8a7eea 100644 (file)
@@ -64,6 +64,7 @@ pub fn cleanup() {
             if !queue.is_null() {
                 let queue: Box<Queue> = Box::from_raw(queue);
                 for to_run in *queue {
+                    // We are not holding any lock, so reentrancy is fine.
                     to_run();
                 }
             }
@@ -75,9 +76,8 @@ pub fn push(f: Box<dyn FnBox()>) -> bool {
     unsafe {
         let _guard = LOCK.lock();
         if init() {
-            // This could reentrantly call `push` again, which is a problem because
-            // `LOCK` allows reentrancy!
-            // FIXME: Add argument why this is okay.
+            // We are just moving `f` around, not calling it.
+            // There is no possibility of reentrancy here.
             (*QUEUE).push(f);
             true
         } else {