Fix subtle bug with mapper queue write synchronization

Consider the following situation where mqueue has 1 entry:
1. Mapper thread 1 checks if mqueue is empty, returns false
2. Mapper thread 2 checks if mqueue is empty, returns false
3. Mapper thread 1 gets spinlock and pops entry off queue
4. Mapper thread 2 gets spinlock and pops entry off queue but...
   the entry is NULL!

This patch checks if the entry is NULL and if so, rechecks if
mqueue is empty.

Found by inspection.