From ddae4c106aef59c35e849b64f02449d65937324e Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 2 Feb 2020 19:56:46 +0800 Subject: [PATCH] Fix concurrent remove --- .../kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt index cd5bd161c..80b6c29cc 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt @@ -132,7 +132,10 @@ open class LockFreeLinkedList { if (toRemove.isRemoved()) { continue } - toRemove.removed.value = true // logically remove: all the operations will recognize this node invalid + if (!toRemove.removed.compareAndSet(false, true)) { + // logically remove: all the operations will recognize this node invalid + continue + } // physically remove: try to fix the link