Files
websocketpp/examples/echo_server
Peter Thorson 3c77ce3cc7 Fix race condition resulting in corruption of responses sent from non-blocking HTTP handers
The HTTP request processing code was expecting that the http response
state would be `deferred` after a call to an HTTP handler that deferred
the response. If, in addition to deferring, you also sent the response
the HTTP state advanced past `deferred` to `response_written`. This
doesn't easily show up in unit tests because the bug requires that the
async write still be in flight and the connection still be open when
the HTTP handler returns.

An asynchronous network transport (like Asio) combined with a
sufficiently large message that Asio yields control back to WebSocket++
before the response is fully written will trigger a second write on the
same connection while the first is in flight. This is not allowed per
the Asio spec and results in undefined behavior.

The HTTP request processing code now checks if the http state is init,
i.e. not deferred and no response has been started rather than just if
it was deferred.
2015-09-09 10:14:37 -04:00
..