Fix race with balance_pool() and next_in_queue()

Reported by:	mat