MINOR: list: make the delete and pop operations idempotent
These operations previously used to return a "locked" element, which is a constraint when multiple threads try to delete the same element, because the second one will block indefinitely. Instead, let's make sure that both LIST_DEL_LOCKED() and LIST_POP_LOCKED() always reinitialize the element after deleting it. This ensures that the second thread will immediately unblock and succeed with the removal. It also secures the pop vs delete competition that may happen when trying to remove an element that's about to be dequeued.
This commit is contained in:
parent
690d2ad4d2
commit
4c747e86cd
|
@ -261,6 +261,9 @@ struct cond_wordlist {
|
|||
n->p = p; \
|
||||
p->n = n; \
|
||||
__ha_barrier_store(); \
|
||||
(el)->p = (el); \
|
||||
(el)->n = (el); \
|
||||
__ha_barrier_store(); \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -308,6 +311,9 @@ struct cond_wordlist {
|
|||
(lh)->n = n2; \
|
||||
(n2)->p = (lh); \
|
||||
__ha_barrier_store(); \
|
||||
(n)->p = (n); \
|
||||
(n)->n = (n); \
|
||||
__ha_barrier_store(); \
|
||||
_ret = LIST_ELEM(n, pt, el); \
|
||||
break; \
|
||||
} \
|
||||
|
|
Loading…
Reference in New Issue