xrpld
Loading...
Searching...
No Matches
xrpl::Door< Handler > Class Template Reference

A listening socket. More...

#include <Door.h>

Inheritance diagram for xrpl::Door< Handler >:
Collaboration diagram for xrpl::Door< Handler >:

Classes

class  Detector
struct  FDStats

Public Member Functions

 Door (Handler &handler, boost::asio::io_context &ioContext, Port const &port, beast::Journal j)
void run ()
void close () override
 Close the Door listening socket and connections.
endpoint_type getEndpoint () const
IOListios ()
 Return the IOList associated with the work.
shared_from_this (T... args)
weak_from_this (T... args)

Private Types

using clock_type = std::chrono::steady_clock
using timer_type = boost::asio::basic_waitable_timer<clock_type>
using error_code = boost::system::error_code
using yield_context = boost::asio::yield_context
using protocol_type = boost::asio::ip::tcp
using acceptor_type = protocol_type::acceptor
using endpoint_type = protocol_type::endpoint
using socket_type = boost::asio::ip::tcp::socket
using stream_type = boost::beast::tcp_stream

Private Member Functions

void reOpen ()
std::optional< FDStatsqueryFdStats () const
bool shouldThrottleForFds ()
template<class ConstBufferSequence>
void create (bool ssl, ConstBufferSequence const &buffers, stream_type &&stream, endpoint_type remoteAddress)
void doAccept (yield_context yield)
template<class = void>
void destroy ()

Private Attributes

beast::Journal const j_
Port const & port_
Handler & handler_
boost::asio::io_context & ioc_
acceptor_type acceptor_
boost::asio::strand< boost::asio::io_context::executor_type > strand_
bool ssl_
bool plain_
std::chrono::milliseconds acceptDelay_ {kInitialAcceptDelay}
boost::asio::steady_timer backoffTimer_
clock_type::time_point fdSampleAt_
bool cachedThrottle_ {false}
IOListios_ = nullptr

Static Private Attributes

static constexpr std::chrono::milliseconds kInitialAcceptDelay {50}
static constexpr std::chrono::milliseconds kMaxAcceptDelay {2000}
static constexpr std::uint64_t kMaxUsedFdPercent = 70
static constexpr std::chrono::milliseconds kFdSampleInterval {250}

Detailed Description

template<class Handler>
class xrpl::Door< Handler >

A listening socket.

Definition at line 41 of file Door.h.

Member Typedef Documentation

◆ clock_type

template<class Handler>
using xrpl::Door< Handler >::clock_type = std::chrono::steady_clock
private

Definition at line 44 of file Door.h.

◆ timer_type

template<class Handler>
using xrpl::Door< Handler >::timer_type = boost::asio::basic_waitable_timer<clock_type>
private

Definition at line 45 of file Door.h.

◆ error_code

template<class Handler>
using xrpl::Door< Handler >::error_code = boost::system::error_code
private

Definition at line 46 of file Door.h.

◆ yield_context

template<class Handler>
using xrpl::Door< Handler >::yield_context = boost::asio::yield_context
private

Definition at line 47 of file Door.h.

◆ protocol_type

template<class Handler>
using xrpl::Door< Handler >::protocol_type = boost::asio::ip::tcp
private

Definition at line 48 of file Door.h.

◆ acceptor_type

template<class Handler>
using xrpl::Door< Handler >::acceptor_type = protocol_type::acceptor
private

Definition at line 49 of file Door.h.

◆ endpoint_type

template<class Handler>
using xrpl::Door< Handler >::endpoint_type = protocol_type::endpoint
private

Definition at line 50 of file Door.h.

◆ socket_type

template<class Handler>
using xrpl::Door< Handler >::socket_type = boost::asio::ip::tcp::socket
private

Definition at line 51 of file Door.h.

◆ stream_type

template<class Handler>
using xrpl::Door< Handler >::stream_type = boost::beast::tcp_stream
private

Definition at line 52 of file Door.h.

Constructor & Destructor Documentation

◆ Door()

template<class Handler>
xrpl::Door< Handler >::Door ( Handler & handler,
boost::asio::io_context & ioContext,
Port const & port,
beast::Journal j )

Definition at line 273 of file Door.h.

Member Function Documentation

◆ reOpen()

template<class Handler>
void xrpl::Door< Handler >::reOpen ( )
private

Definition at line 223 of file Door.h.

◆ queryFdStats()

template<class Handler>
std::optional< typename Door< Handler >::FDStats > xrpl::Door< Handler >::queryFdStats ( ) const
private

Definition at line 401 of file Door.h.

◆ shouldThrottleForFds()

template<class Handler>
bool xrpl::Door< Handler >::shouldThrottleForFds ( )
private

Definition at line 432 of file Door.h.

◆ run()

template<class Handler>
void xrpl::Door< Handler >::run ( )

Definition at line 292 of file Door.h.

◆ close()

template<class Handler>
void xrpl::Door< Handler >::close ( )
overridevirtual

Close the Door listening socket and connections.

The listening socket is closed, and all open connections belonging to the Door are closed. Thread Safety: May be called concurrently

Implements xrpl::IOList::Work.

Definition at line 301 of file Door.h.

◆ getEndpoint()

template<class Handler>
endpoint_type xrpl::Door< Handler >::getEndpoint ( ) const
nodiscard

Definition at line 138 of file Door.h.

◆ create()

template<class Handler>
template<class ConstBufferSequence>
void xrpl::Door< Handler >::create ( bool ssl,
ConstBufferSequence const & buffers,
stream_type && stream,
endpoint_type remoteAddress )
private

Definition at line 318 of file Door.h.

◆ doAccept()

template<class Handler>
void xrpl::Door< Handler >::doAccept ( yield_context yield)
private

Definition at line 338 of file Door.h.

◆ destroy()

template<class = void>
void xrpl::IOList::Work::destroy ( )
privateinherited

Definition at line 162 of file io_list.h.

◆ ios()

IOList & xrpl::IOList::Work::ios ( )
inherited

Return the IOList associated with the work.

Requirements: The call to IOList::emplace to create the work has already returned.

Definition at line 40 of file io_list.h.

Member Data Documentation

◆ j_

template<class Handler>
beast::Journal const xrpl::Door< Handler >::j_
private

Definition at line 85 of file Door.h.

◆ port_

template<class Handler>
Port const& xrpl::Door< Handler >::port_
private

Definition at line 86 of file Door.h.

◆ handler_

template<class Handler>
Handler& xrpl::Door< Handler >::handler_
private

Definition at line 87 of file Door.h.

◆ ioc_

template<class Handler>
boost::asio::io_context& xrpl::Door< Handler >::ioc_
private

Definition at line 88 of file Door.h.

◆ acceptor_

template<class Handler>
acceptor_type xrpl::Door< Handler >::acceptor_
private

Definition at line 89 of file Door.h.

◆ strand_

template<class Handler>
boost::asio::strand<boost::asio::io_context::executor_type> xrpl::Door< Handler >::strand_
private

Definition at line 90 of file Door.h.

◆ ssl_

template<class Handler>
bool xrpl::Door< Handler >::ssl_
private
Initial value:
{
port_.protocol.contains("https") || port_.protocol.contains("wss") ||
port_.protocol.contains("wss2") || port_.protocol.contains("peer")}
Port const & port_
Definition Door.h:86

Definition at line 91 of file Door.h.

◆ plain_

template<class Handler>
bool xrpl::Door< Handler >::plain_
private
Initial value:
{
port_.protocol.contains("http") || port_.protocol.contains("ws") ||
(port_.protocol.contains("ws2"))}

Definition at line 94 of file Door.h.

◆ kInitialAcceptDelay

template<class Handler>
std::chrono::milliseconds xrpl::Door< Handler >::kInitialAcceptDelay {50}
staticconstexprprivate

Definition at line 97 of file Door.h.

◆ kMaxAcceptDelay

template<class Handler>
std::chrono::milliseconds xrpl::Door< Handler >::kMaxAcceptDelay {2000}
staticconstexprprivate

Definition at line 98 of file Door.h.

◆ acceptDelay_

template<class Handler>
std::chrono::milliseconds xrpl::Door< Handler >::acceptDelay_ {kInitialAcceptDelay}
private

Definition at line 99 of file Door.h.

◆ backoffTimer_

template<class Handler>
boost::asio::steady_timer xrpl::Door< Handler >::backoffTimer_
private

Definition at line 100 of file Door.h.

◆ kMaxUsedFdPercent

template<class Handler>
std::uint64_t xrpl::Door< Handler >::kMaxUsedFdPercent = 70
staticconstexprprivate

Definition at line 101 of file Door.h.

◆ kFdSampleInterval

template<class Handler>
std::chrono::milliseconds xrpl::Door< Handler >::kFdSampleInterval {250}
staticconstexprprivate

Definition at line 102 of file Door.h.

◆ fdSampleAt_

template<class Handler>
clock_type::time_point xrpl::Door< Handler >::fdSampleAt_
private

Definition at line 103 of file Door.h.

◆ cachedThrottle_

template<class Handler>
bool xrpl::Door< Handler >::cachedThrottle_ {false}
private

Definition at line 104 of file Door.h.

◆ ios_

IOList* xrpl::IOList::Work::ios_ = nullptr
privateinherited

Definition at line 25 of file io_list.h.