Remove isc_rwlock_downgrade usage in rbtdb.c [1/3]

Merged Ondřej Surý requested to merge ondrej-rework-pthread-rwlock-1 into main

The only place where isc_rwlock_downgrade was being used was the decrement_reference() where the code tries either relocks the node rwlock to write and then tries to upgrade the tree lock. When returning from the function it tries to restore the locks into a previous state which is nice, but kind of moot, because at every use of decrement_reference() the node locks is immediately or almost immeditately unlocked, and same holds for the tree lock.

Instead of trying to restore the node and tree lock into the initial state, the decrement_reference now returns the state of the locks, so the caller can then use the right unlock operation (read or write). Only when the tree lock was originally unlocked, the decrement_reference unlocks the tree lock before returning to the caller.

Edited by Ondřej Surý

Merge request reports