@@ -157,7 +157,7 @@ impl Once {
157157 panic ! ( "Once instance has previously been poisoned" ) ;
158158 }
159159 _ => {
160- current = wait ( & self . state_and_queue , current) ;
160+ current = wait ( & self . state_and_queue , current, !ignore_poisoning ) ;
161161 }
162162 }
163163 }
@@ -220,14 +220,18 @@ impl Once {
220220 // All other values must be RUNNING with possibly a
221221 // pointer to the waiter queue in the more significant bits.
222222 assert ! ( state == RUNNING ) ;
223- current = wait ( & self . state_and_queue , current) ;
223+ current = wait ( & self . state_and_queue , current, true ) ;
224224 }
225225 }
226226 }
227227 }
228228}
229229
230- fn wait ( state_and_queue : & AtomicPtr < ( ) > , mut current : StateAndQueue ) -> StateAndQueue {
230+ fn wait (
231+ state_and_queue : & AtomicPtr < ( ) > ,
232+ mut current : StateAndQueue ,
233+ return_on_poisoned : bool ,
234+ ) -> StateAndQueue {
231235 let node = & Waiter {
232236 thread : Cell :: new ( Some ( thread:: current ( ) ) ) ,
233237 signaled : AtomicBool :: new ( false ) ,
@@ -239,7 +243,7 @@ fn wait(state_and_queue: &AtomicPtr<()>, mut current: StateAndQueue) -> StateAnd
239243 let queue = to_queue ( current) ;
240244
241245 // If initialization has finished, return.
242- if matches ! ( state, POISONED | COMPLETE ) {
246+ if state == COMPLETE || ( return_on_poisoned && state == POISONED ) {
243247 return current;
244248 }
245249
0 commit comments