mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
preliminary work on various timeouts, adjusts the handler API to be more consistant
This commit is contained in:
@@ -48,8 +48,9 @@ public:
|
||||
|
||||
// an echo server is stateless.
|
||||
// The handler has no need to keep track of connected clients.
|
||||
void on_fail(session_ptr client) {}
|
||||
void on_open(session_ptr client) {}
|
||||
void on_close(session_ptr client,uint16_t status,const std::string &reason) {}
|
||||
void on_close(session_ptr client) {}
|
||||
|
||||
// both text and binary messages are echoed back to the sending client.
|
||||
void on_message(session_ptr client,const std::string &msg);
|
||||
|
||||
@@ -96,8 +96,8 @@ void server_session::read_handshake() {
|
||||
|
||||
m_timer.async_wait(
|
||||
boost::bind(
|
||||
&session::handle_timer_expired,
|
||||
this,
|
||||
&session::handle_handshake_expired,
|
||||
shared_from_this(),
|
||||
boost::asio::placeholders::error
|
||||
)
|
||||
);
|
||||
@@ -342,6 +342,9 @@ void server_session::handle_write_handshake(const boost::system::error_code& err
|
||||
|
||||
m_state = STATE_OPEN;
|
||||
|
||||
// stop the handshake timer
|
||||
m_timer.cancel();
|
||||
|
||||
if (m_local_interface) {
|
||||
m_local_interface->on_open(shared_from_this());
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ protected:
|
||||
std::size_t bytes_transferred);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
@@ -329,7 +329,8 @@ void session::handle_read_frame(const boost::system::error_code& error) {
|
||||
log_close_result();
|
||||
|
||||
if (m_local_interface) {
|
||||
m_local_interface->on_close(shared_from_this(),m_remote_close_code,m_remote_close_msg);
|
||||
// TODO: make sure close code/msg are properly set.
|
||||
m_local_interface->on_close(shared_from_this());
|
||||
}
|
||||
} else {
|
||||
log("handle_read_frame called in invalid state",LOG_ERROR);
|
||||
@@ -407,6 +408,21 @@ void session::handle_timer_expired (const boost::system::error_code& error) {
|
||||
|
||||
}
|
||||
|
||||
void session::handle_handshake_expired (const boost::system::error_code& error) {
|
||||
if (error) {
|
||||
if (error == boost::asio::error::operation_aborted) {
|
||||
log("timer was aborted",LOG_DEBUG);
|
||||
//drop_tcp(false);
|
||||
} else {
|
||||
log("Unexpected handshake timer error.",LOG_DEBUG);
|
||||
drop_tcp(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
log("Handshake timed out",LOG_DEBUG);
|
||||
drop_tcp(false);
|
||||
}
|
||||
|
||||
void session::process_ping() {
|
||||
access_log("Ping",ALOG_MISC_CONTROL);
|
||||
|
||||
@@ -205,6 +205,7 @@ protected:
|
||||
void handle_write_frame (const boost::system::error_code& error);
|
||||
|
||||
void handle_timer_expired(const boost::system::error_code& error);
|
||||
void handle_handshake_expired(const boost::system::error_code& error);
|
||||
|
||||
// helper functions for processing each opcode
|
||||
void process_frame();
|
||||
|
||||
Reference in New Issue
Block a user