Fix some deadlocking problems in message_queue.c