Skip to content

Commit

Permalink
Major overhaul to handshake internal state machine error checking ref…
Browse files Browse the repository at this point in the history
…erences #389 #361

This overhaul removes the use of exceptions in handling state errors
during handshake processing. All such errors are demoted to
rerror/recoverable error and will terminate the connection only rather
than the whole application. In addition, there are some cases where we
expect to see a state error due to non-deterministic interleaving of
timeout handlers and read/write handlers. In these expected cases state
errors are ignored entirely.
  • Loading branch information
zaphoyd committed Dec 11, 2014
1 parent 922f1c3 commit e1f1c88
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 208 deletions.
39 changes: 0 additions & 39 deletions websocketpp/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1251,45 +1251,6 @@ class connection
/// Perform WebSocket handshake validation of m_request using m_processor.
/// set m_response and return false on error.
bool process_handshake_request();

/// Atomically change the internal connection state.
/**
* @param req The required starting state. If the internal state does not
* match req an exception is thrown.
*
* @param dest The state to change to.
*
* @param msg The message to include in the exception thrown
*/
void atomic_state_change(istate_type req, istate_type dest,
std::string msg);

/// Atomically change the internal and external connection state.
/**
* @param ireq The required starting internal state. If the internal state
* does not match ireq an exception is thrown.
*
* @param idest The internal state to change to.
*
* @param ereq The required starting external state. If the external state
* does not match ereq an exception is thrown.
*
* @param edest The external state to change to.
*
* @param msg The message to include in the exception thrown
*/
void atomic_state_change(istate_type ireq, istate_type idest,
session::state::value ereq, session::state::value edest,
std::string msg);

/// Atomically read and compared the internal state.
/**
* @param req The state to test against. If the internal state does not
* match req an exception is thrown.
*
* @param msg The message to include in the exception thrown
*/
void atomic_state_check(istate_type req, std::string msg);
private:
/// Completes m_response, serializes it, and sends it out on the wire.
void send_http_response();
Expand Down
Loading

0 comments on commit e1f1c88

Please sign in to comment.