We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9c68b61 commit 5a6a7d9Copy full SHA for 5a6a7d9
kotlinx-coroutines-core/jvm/src/internal/LockFreeLinkedList.kt
@@ -267,7 +267,16 @@ public actual open class LockFreeLinkedListNode {
267
// Helps with removal of nodes that are previous to this
268
@PublishedApi
269
internal fun helpRemovePrev() {
270
- correctPrev(null)
+ // We need to call correctPrev on a non-removed node to ensure progress, since correctPrev bails out when
271
+ // called on a removed node. There's always at least one non-removed node (list head).
272
+ var node = this
273
+ while (true) {
274
+ val next = node.next
275
+ if (next !is Removed) break
276
+ node = next.ref
277
+ }
278
+ // Found a non-removed node
279
+ node.correctPrev(null)
280
}
281
282
public actual fun removeFirstOrNull(): Node? {
0 commit comments