avoid locking when message queue is empty in websocket
replace tabs with spaces.
Merge pull request #8922 from TimothyZhang/do-not-lock-when-no-message-in-websocket

avoid locking when message queue is empty in websocket