Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ac4e021333 |
+1
-1
@@ -55,7 +55,7 @@ If you handle errors from methods like send, ping, close, etc correctly then you
|
||||
|
||||
Normally, for security purposes, operating systems prevent programs from listening on sockets created by other programs. When your program crashes and restarts, the new instance is a different program from the perspective of the operating system. As such it can’t listen on the socket address/port that the previous program was using until after a timeout occurs to make sure the old program was done with it.
|
||||
|
||||
The first step for handling this is to make sure that you provide a method (signal handler, admin websocket message, etc) to perform a clean server shutdown. There is a question elsewhere in this FAQ that describes the steps necessary for this.
|
||||
The the first step for handling this is to make sure that you provide a method (signal handler, admin websocket message, etc) to perform a clean server shutdown. There is a question elsewhere in this FAQ that describes the steps necessary for this.
|
||||
|
||||
The clean close strategy won't help in the case of crashes or other abnormal closures. An option to consider for these cases is the use of the SO_REUSEADDR socket option. This instructs the OS to not request an exclusive lock on the socket. This means that after your program crashes the replacement you start can immediately listen on that address/port combo again.
|
||||
|
||||
|
||||
@@ -2177,7 +2177,7 @@ connection<config>::get_processor(int version) const {
|
||||
transport_con_type::is_secure(),
|
||||
m_is_server,
|
||||
m_msg_manager,
|
||||
lib::ref(m_rng)
|
||||
m_rng
|
||||
);
|
||||
break;
|
||||
case 8:
|
||||
@@ -2185,7 +2185,7 @@ connection<config>::get_processor(int version) const {
|
||||
transport_con_type::is_secure(),
|
||||
m_is_server,
|
||||
m_msg_manager,
|
||||
lib::ref(m_rng)
|
||||
m_rng
|
||||
);
|
||||
break;
|
||||
case 13:
|
||||
@@ -2193,7 +2193,7 @@ connection<config>::get_processor(int version) const {
|
||||
transport_con_type::is_secure(),
|
||||
m_is_server,
|
||||
m_msg_manager,
|
||||
lib::ref(m_rng)
|
||||
m_rng
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -45,7 +45,7 @@ endpoint<connection,config>::create_connection() {
|
||||
//scoped_lock_type guard(m_mutex);
|
||||
// Create a connection on the heap and manage it using a shared pointer
|
||||
connection_ptr con = lib::make_shared<connection_type>(m_is_server,
|
||||
m_user_agent, m_alog, m_elog, lib::ref(m_rng));
|
||||
m_user_agent, m_alog, m_elog, m_rng);
|
||||
|
||||
connection_weak_ptr w(con);
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ public:
|
||||
*/
|
||||
timer_ptr set_timer(long duration, timer_handler callback) {
|
||||
timer_ptr new_timer = lib::make_shared<lib::asio::steady_timer>(
|
||||
lib::ref(*m_io_service),
|
||||
*m_io_service,
|
||||
lib::asio::milliseconds(duration)
|
||||
);
|
||||
|
||||
@@ -462,7 +462,7 @@ protected:
|
||||
|
||||
if (config::enable_multithreading) {
|
||||
m_strand = lib::make_shared<lib::asio::io_service::strand>(
|
||||
lib::ref(*io_service));
|
||||
*io_service);
|
||||
}
|
||||
|
||||
lib::error_code ec = socket_con_type::init_asio(io_service, m_strand,
|
||||
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
m_io_service = ptr;
|
||||
m_external_io_service = true;
|
||||
m_acceptor = lib::make_shared<lib::asio::ip::tcp::acceptor>(
|
||||
lib::ref(*m_io_service));
|
||||
*m_io_service);
|
||||
|
||||
m_state = READY;
|
||||
ec = lib::error_code();
|
||||
@@ -689,7 +689,7 @@ public:
|
||||
*/
|
||||
void start_perpetual() {
|
||||
m_work = lib::make_shared<lib::asio::io_service::work>(
|
||||
lib::ref(*m_io_service)
|
||||
*m_io_service
|
||||
);
|
||||
}
|
||||
|
||||
@@ -855,7 +855,7 @@ protected:
|
||||
// Create a resolver
|
||||
if (!m_resolver) {
|
||||
m_resolver = lib::make_shared<lib::asio::ip::tcp::resolver>(
|
||||
lib::ref(*m_io_service));
|
||||
*m_io_service);
|
||||
}
|
||||
|
||||
tcon->set_uri(u);
|
||||
|
||||
@@ -169,7 +169,7 @@ protected:
|
||||
}
|
||||
|
||||
m_socket = lib::make_shared<lib::asio::ip::tcp::socket>(
|
||||
lib::ref(*service));
|
||||
*service);
|
||||
|
||||
if (m_socket_init_handler) {
|
||||
m_socket_init_handler(m_hdl, *m_socket);
|
||||
|
||||
@@ -194,7 +194,7 @@ protected:
|
||||
return socket::make_error_code(socket::error::invalid_tls_context);
|
||||
}
|
||||
m_socket = lib::make_shared<socket_type>(
|
||||
_WEBSOCKETPP_REF(*service),lib::ref(*m_context));
|
||||
_WEBSOCKETPP_REF(*service),*m_context);
|
||||
|
||||
if (m_socket_init_handler) {
|
||||
m_socket_init_handler(m_hdl, get_socket());
|
||||
|
||||
Reference in New Issue
Block a user