Backport raising of #9731 fixes.
Some changes done to connection_consider_empty_write_buckets
and connection_consider_empty_read_buckets
before the following commits are causing infinite loops in Shadow. The infinite loops are fixed by the following two commits.
The latest stable 0.2.4.21 still has infinite loops. I am requesting that those commits get backported to 0.2.4.x to be included in the next 0.2.4.x stable release. They are relatively trivial changes.
Shadow issue for reference: https://github.com/shadow/shadow/issues/201