added thread safety for websockets

This was submitted by Morgan McGuire via proxy.

Hereis his comment...
The actual diff against civetweb is pretty small--I added thread safety
for websockets and rewrote and commented a very confusing function that
 was previously buggy.  The thread safety is critical since there is no
other way for the application to synchronize civet's receipt of a websocket
packet with its own desire to send one. All of this was tested pretty
thoroughly in my own apps and I had a pull request to Sergey that he never
got to before the fork.
Fixed missing mg_lock reference