In #1739 I noticed that every block updates needs to lock the inventory mutex, since it needs to be locked when breaking a chest to remove the inventory.
Generally it would be nicer if this was less coupled, particularly it is problematic that we even get into the situation that the inventory mutex leaks into the update block function, this has a big risk of causing severe deadlocks in the future.
I'm not sure how this could be prevented though, since otherwise there is a risk that the inventory gets changed while breaking/placing a block (e.g. maybe the player collects something) which in turn changes the eligibility of breaking a block.
I think the right solution may be to avoid having a global mutex at all, maybe a per inventory mutex suffices? This does however make it more likely to deadlock for operations on multiple inventories.
In #1739 I noticed that every block updates needs to lock the inventory mutex, since it needs to be locked when breaking a chest to remove the inventory.
Generally it would be nicer if this was less coupled, particularly it is problematic that we even get into the situation that the inventory mutex leaks into the update block function, this has a big risk of causing severe deadlocks in the future.
I'm not sure how this could be prevented though, since otherwise there is a risk that the inventory gets changed while breaking/placing a block (e.g. maybe the player collects something) which in turn changes the eligibility of breaking a block.
I think the right solution may be to avoid having a global mutex at all, maybe a per inventory mutex suffices? This does however make it more likely to deadlock for operations on multiple inventories.