Fix the enqueue race condition.

There was a race condition which allowed for queuing of the messages to happen outside of a receive block. This pull request fixes it.