Node deletion in aio_set_fd_handler
Paolo, is this else branch dead code (or bug?):
/* If the lock is held, just mark the node as deleted */
if (qemu_lockcnt_count(&ctx->list_lock)) {
node->deleted = 1;
node->pfd.revents = 0;
} else {
/* Otherwise, delete it for real. We can't just mark it as
* deleted because deleted nodes are only cleaned up while
* no one is walking the handlers list.
*/
QLIST_REMOVE(node, node);
deleted = true;
}Since we are in a qemu_lockcnt_lock/unlock section?
Fam
Quoted 15 lines · Fam Zheng
Paolo, is this else branch dead code (or bug?):
/* If the lock is held, just mark the node as deleted */ if (qemu_lockcnt_count(&ctx->list_lock)) { node->deleted = 1; node->pfd.revents = 0; } else { /* Otherwise, delete it for real. We can't just mark it as * deleted because deleted nodes are only cleaned up while * no one is walking the handlers list. */ QLIST_REMOVE(node, node); deleted = true; }
Quoted 1 line
Since we are in a qemu_lockcnt_lock/unlock section?
No, qemu_lockcnt_count returns the number of nested qemu_lockcnt_inc/dec (read-side) sections. lock/unlock is for the write side.
The comment should be improved (e.g. "if a read is in progress, just mark the node as deleted").
Paolo
Quoted 16 lines · Paolo Bonzini
Quoted 15 lines · Fam Zheng
Paolo, is this else branch dead code (or bug?):
/* If the lock is held, just mark the node as deleted */ if (qemu_lockcnt_count(&ctx->list_lock)) { node->deleted = 1; node->pfd.revents = 0; } else { /* Otherwise, delete it for real. We can't just mark it as * deleted because deleted nodes are only cleaned up while * no one is walking the handlers list. */ QLIST_REMOVE(node, node); deleted = true; }
Quoted 7 lines
Quoted 1 line
Since we are in a qemu_lockcnt_lock/unlock section?
No,
qemu_lockcnt_countreturns the number of nested qemu_lockcnt_inc/dec (read-side) sections. lock/unlock is for the write side.The comment should be improved (e.g. "if a read is in progress, just mark the node as deleted").
Yeah, that explains! Agree about the comment, I'll send a patch then. Thanks.
Fam