HORNETQ-1102 Take the locks in the right order.

Fixes 2 dead locks (there could be more, need to spend more time reading the code...)