dodo  0.0.1
A C++ library to create containerized Linux services
dodo::network::TCPListener Class Reference

The TCPListener listens, accepts connections and generates socket events to produce TCP work to a pool of TCPServer worker objects. More...

#include <tcplistener.hpp>

Inheritance diagram for dodo::network::TCPListener:
Collaboration diagram for dodo::network::TCPListener:

Data Structures

struct  Params
 Parameters affecting TCPListener behavior. More...
 
struct  SocketWork
 BaseSocket socket and state pair. More...
 
struct  Stats
 Load statisics. More...
 

Public Types

enum  SockState { SockState::None = 0, SockState::New = 1, SockState::Read = 2, SockState::Shut = 4 }
 BaseSocket lifecycle states. More...
 

Public Member Functions

 TCPListener (const Address &address, const Params &params)
 Constructor. More...
 
 TCPListener (const YAML::Node &yaml)
 Constructor, read Address and params from the YAML::Node. More...
 
void start (TCPServer *server)
 Start the TCPListener and initialize with a TCPServer implementation object. More...
 
void stop ()
 Request a stop on the TCPListener. More...
 
- Public Member Functions inherited from dodo::threads::Thread
 Thread ()
 Constructor. More...
 
virtual ~Thread ()
 Destructor. More...
 
double getAvgBlkInRate ()
 Get the average block in rate since thread start() More...
 
double getAvgBlkOutRate ()
 Get the average block out rate since thread start() More...
 
double getAvgICtx ()
 Get the average involuntary context switch rate since thread start() More...
 
double getAvgMajFltRate ()
 Get the average major fault rate since thread start() More...
 
double getAvgMinFltRate ()
 Get the average minor fault rate since thread start() More...
 
double getAvgSysCPU ()
 Get the average system mode cpu (cpu seconds/second) since thread start() More...
 
double getAvgUserCPU ()
 Get the average user mode cpu (cpu seconds/second) since thread start() More...
 
double getAvgVCtx ()
 Get the average voluntary context switch rate since thread start() More...
 
std::thread::id getId () const
 Get the thread id. More...
 
double getLastBlkInRate ()
 Get last block in rate since last sample. More...
 
double getLastBlkOutRate ()
 Get last block out rate since last sample. More...
 
double getLastICtx ()
 Get involuntary context switch rate since last sample. More...
 
double getLastMajFltRate ()
 Get the major fault rate since last sample. More...
 
double getLastMinFltRate ()
 Get the minor fault rate since last sample. More...
 
double getLastSysCPU ()
 Get the system mode cpu (cpu seconds/second) since last sample. More...
 
double getLastUserCPU ()
 Get the user mode cpu (cpu seconds/second) since last sample. More...
 
double getLastVCtx ()
 Get voluntary context switch rate since last sample. More...
 
long getMaxRSS ()
 Get the maximum resident set size seen on the thread. More...
 
double getRunTime ()
 Time, in seconds, since thread start. More...
 
double getSnapDiffTime ()
 Time, in seconds, since last statistic update. More...
 
pid_t getTID () const
 Return the tid. More...
 
void snapRUsage ()
 Take a snapshot of the thread's resource usage. More...
 
void start ()
 Start the thread. More...
 
void wait ()
 Wait for the thread to join the current thread / wait for the thread to finish. More...
 

Private Member Functions

void addReceivedSentBytes (ssize_t r, ssize_t s)
 Add received bytes. More...
 
void addServers ()
 Add a server if work_q_sz_ exceeds servers.size() and servers_.size() < params_.maxservers. More...
 
void cleanStoppedServers ()
 Cleanup stopped TCPServers. More...
 
void closeSocket (BaseSocket *socket)
 Tell the listener to close the socket. More...
 
void construct (const Address &address, const Params &params)
 Common constructor code. More...
 
void logStats ()
 Log TCPListener statistics to Logger::getLogger(). More...
 
void pollAdd (const BaseSocket *s, uint32_t events)
 Add an epoll event for the BaseSocket. More...
 
void pollDel (const BaseSocket *s)
 Delete the epoll event for the BaseSocket. More...
 
void pollMod (const BaseSocket *s, uint32_t events)
 Modify an epoll event for the BaseSocket. More...
 
SocketWorkpopWork ()
 Pop work. More...
 
void pushWork (const SocketWork &work)
 Push work. More...
 
void pushWork (int fd, SockState state)
 Push work. More...
 
void releaseWork (const SocketWork &work)
 Called by a TCPServer to signal that the work has been handled and event detection on it can resume. More...
 
virtual void run ()
 Entrypoint, override of Thread::run() More...
 
void throttle ()
 Throttle the listener when work_q_sz_ exceeds params_.maxqdepth. More...
 
bool waitForActivity (TCPServer *server)
 Called by the TCPServer, enters wait state until woken up by either a timeout or a notify by TCPListener that there are 1 or more requests to be handled. More...
 

Private Attributes

int backlog_
 The backlog (incoming connection queue before accept calls clearing it) used by listen. More...
 
threads::Mutex clientmutex_
 Protects both client_ and workload_. More...
 
std::map< int, SocketWorkclients_
 Map of file descriptors to SocketWork for all connected clients. More...
 
std::condition_variable cv_signal_
 Condition variable used to wakeup TCPServer threads with mutex mt_signal_. More...
 
int epoll_fd_
 The epoll interface file descriptor. More...
 
size_t event_maxconnections_reached_
 The number of times a connection was closed after accept because params_.maxconnectctions was reached. More...
 
uint32_t hangup_event_mask_
 The event mask for hangup events. More...
 
TCPServerinit_server_
 The initial TCPServer, which will live as long as the TCPListener runs, and is sued to create new TCPServers under load. More...
 
Stats last_stats_
 The last Stats. More...
 
Address listen_address_
 The listening address. More...
 
BaseSocketlisten_socket_
 The listening BaseSocket. More...
 
std::mutex mt_signal_
 Mutex used to wakeup TCPServer threads with condition variable cv_signal_. More...
 
struct timeval now_
 Frequently updated by a TCPListenerTimer with enough precision for its use. More...
 
threads::Mutex now_mutex_
 Synchronize access to now_. More...
 
Params params_
 TCPListener parameters. More...
 
struct timeval prev_stat_time_
 Time of previous statistics. More...
 
Stats prev_stats_
 The previous Stats. More...
 
uint32_t read_event_mask_
 The event mask for read events. More...
 
struct timeval server_stopped_check_time_
 Time of last check for stopped servers. More...
 
std::list< TCPServer * > servers_
 List of TCPServers. More...
 
struct timeval stat_time_
 Time of last statistics. More...
 
threads::Mutex stats_mutex_
 Protects prev_stats_, last_stats_. More...
 
bool stop_server_
 If true, the TCPListener will gracefully stop and finish. More...
 
struct timeval warn_queue_time_
 Time of last queueing warning. More...
 
std::atomic< unsigned long long > work_q_sz_
 The number of queued work items. More...
 
std::deque< SocketWork * > workload_
 Queue of sockets with work for TCPServer instances. More...
 

Friends

bool operator& (const TCPListener::SockState &, const TCPListener::SockState &)
 Bitwise & on SocketWork. More...
 
const friend dodo::common::Putsoperator<< (const dodo::common::Puts &, TCPListener::SockState)
 Nice-write to a Puts. More...
 
TCPListener::SockStateoperator^= (TCPListener::SockState &, TCPListener::SockState)
 Bitwise ^= on SocketWork. More...
 
TCPListener::SockStateoperator|= (TCPListener::SockState &, TCPListener::SockState)
 Bitwise |= on SocketWork. More...
 
class TCPListenerTimer
 TCPListenerTimer needs access to now_ and now_mutex_. More...
 
class TCPServer
 TCPServer needs access to several private definitions, data and methods. More...
 

Additional Inherited Members

- Protected Attributes inherited from dodo::threads::Thread
struct rusage prev_rusage_
 Previous statistics. More...
 
struct timeval prev_snap_time_
 Time of previous statistics snapshot. More...
 
struct rusage rusage_
 Last statistics. More...
 
struct timeval snap_time_
 Time of last statistics snapshot. More...
 
struct timeval start_time_
 Time Thread started. More...
 
std::thread * thread_
 The std::tread object. More...
 

Detailed Description

The TCPListener listens, accepts connections and generates socket events to produce TCP work to a pool of TCPServer worker objects.

Developers must implement a protocol by subclassing TCPServer. The produced by a TCPListener is either

  • handling new connections (and optionally perform a protocol handShake).
  • reading data from sockets and sending responses
  • closing down connections on hangups or errors.

The developer sub-classes TCPServer to implement a request-response protocol.

TCPListener uses the Linux epoll_wait interface to pick up socket events and distribute the work to TCPServers.

The TCPListener is started start( TCPServer *server ) with an initial TCPServer object. The TCPServer::addServer() method is used to spawn additional TCPServer objects up to Params.minservers when TCPListener::run() is invoked. The TCPListener will spawn TCPServer worker threads if the amount of pending work exceeds the number of existing TCPServer objects, up to Params.maxservers.

The TCPServer descendant class implements the details of handShake, readSocket and shutDown, and are each passed a SocketWork that needs to be serviced -a SocketWork specifies the socket and the event state it is in.

Sockets are set to non-blocking mode, and TCPServer::readSocket is not guaranteed to see a full request, data might arrive in multiple chunks.

For a given connection, a TCPServer descendant will cycle through

  • a handShake call
  • zero or more readSocket calls
  • a shutDown call

On connection errors and hangups call to shutDown will follow - the BaseSocket object passed to shutDown() is not destroyed yet, allowing TCPServer implementations to clean up failed connections.

Definition at line 126 of file tcplistener.hpp.

Member Enumeration Documentation

◆ SockState

BaseSocket lifecycle states.

Enumerator
None 

Undefined / initial.

New 

New connection, TCPServer::handShake() will be called.

Read 

Data is ready to be read, TCPServer::readSocket() will be called.

Shut 

BaseSocket is hung up or in error, TCPServer::shutDown() will be called.

Definition at line 260 of file tcplistener.hpp.

Constructor & Destructor Documentation

◆ TCPListener() [1/2]

dodo::network::TCPListener::TCPListener ( const Address address,
const Params params 
)

Constructor.

Parameters
addressThe address to listen on.
paramsThe Params to use.
See also
listen()

Definition at line 157 of file tcplistener.cpp.

References construct().

Here is the call graph for this function:

◆ TCPListener() [2/2]

dodo::network::TCPListener::TCPListener ( const YAML::Node &  yaml)

Constructor, read Address and params from the YAML::Node.

Parameters
yamlThe YAML::NOde to read the configuration from.

Definition at line 215 of file tcplistener.cpp.

References construct(), dodo::network::Address::isValid(), and throw_Exception.

Here is the call graph for this function:

Member Function Documentation

◆ addReceivedSentBytes()

void dodo::network::TCPListener::addReceivedSentBytes ( ssize_t  r,
ssize_t  s 
)
inlineprivate

Add received bytes.

Parameters
rThe received bytes to add.
sThe sent bytes to add

Definition at line 408 of file tcplistener.hpp.

References last_stats_, dodo::network::TCPListener::Stats::received, dodo::network::TCPListener::Stats::sent, and stats_mutex_.

Referenced by dodo::network::TCPServer::run().

Here is the caller graph for this function:

◆ addServers()

void dodo::network::TCPListener::addServers ( )
private

Add a server if work_q_sz_ exceeds servers.size() and servers_.size() < params_.maxservers.

Definition at line 488 of file tcplistener.cpp.

References dodo::network::TCPServer::addServer(), init_server_, log_Debug, dodo::network::TCPListener::Params::maxservers, params_, servers_, dodo::threads::Thread::start(), and work_q_sz_.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanStoppedServers()

void dodo::network::TCPListener::cleanStoppedServers ( )
private

◆ closeSocket()

void dodo::network::TCPListener::closeSocket ( BaseSocket socket)
private

Tell the listener to close the socket.

Parameters
socketThe socket to close.

Definition at line 448 of file tcplistener.cpp.

References clientmutex_, clients_, dodo::network::BaseSocket::close(), dodo::network::BaseSocket::getFD(), and log_Debug.

Referenced by releaseWork(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct()

void dodo::network::TCPListener::construct ( const Address address,
const Params params 
)
private

Common constructor code.

Parameters
addressThe address to listen on.
paramsThe Params to use.*
Todo:
This could also be a TLSSocket

Definition at line 166 of file tcplistener.cpp.

References dodo::network::Address::asString(), backlog_, dodo::network::TCPListener::Params::cycle_max_throttles, dodo::common::SystemError::ecOK, dodo::common::fileReadInt(), dodo::network::Address::getAddressFamily(), hangup_event_mask_, init_server_, dodo::network::Address::isValid(), dodo::network::BaseSocket::listen(), listen_address_, listen_socket_, dodo::network::TCPListener::Params::listener_sleep_ms, log_Statistics, dodo::network::TCPListener::Params::maxconnections, dodo::network::TCPListener::Params::maxqdepth, dodo::network::TCPListener::Params::maxservers, dodo::network::TCPListener::Params::minservers, params_, dodo::network::TCPListener::Params::pollbatch, read_event_mask_, dodo::network::TCPListener::Params::receive_timeout_seconds, dodo::network::TCPListener::Params::recvbufsz, dodo::network::TCPListener::Params::send_timeout_seconds, dodo::network::TCPListener::Params::sendbufsz, dodo::network::TCPListener::Params::server_idle_ttl_s, dodo::network::BaseSocket::setBlocking(), dodo::network::BaseSocket::setReceiveBufSize(), dodo::network::BaseSocket::setReceiveTimeout(), dodo::network::BaseSocket::setReUseAddress(), dodo::network::BaseSocket::setReUsePort(), dodo::network::BaseSocket::setSendBufSize(), dodo::network::BaseSocket::setSendTimeout(), stop_server_, dodo::network::TCPListener::Params::throttle_sleep_us, throw_Exception, throw_SystemException, work_q_sz_, dodo::network::yaml_cycle_max_throttles, dodo::network::yaml_listener_sleep_ms, dodo::network::yaml_maxconnections, dodo::network::yaml_maxqdepth, dodo::network::yaml_maxservers, dodo::network::yaml_minservers, dodo::network::yaml_pollbatch, dodo::network::yaml_receive_timeout_seconds, dodo::network::yaml_recvbufsz, dodo::network::yaml_send_timeout_seconds, dodo::network::yaml_sendbufsz, dodo::network::yaml_server_idle_ttl_s, and dodo::network::yaml_throttle_sleep_us.

Referenced by TCPListener().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logStats()

◆ pollAdd()

void dodo::network::TCPListener::pollAdd ( const BaseSocket s,
uint32_t  events 
)
private

Add an epoll event for the BaseSocket.

Parameters
sThe BaseSocket
eventsThe events to set (see man epoll_ctl).

Definition at line 461 of file tcplistener.cpp.

References dodo::common::DebugObject::debugString(), epoll_fd_, dodo::network::BaseSocket::getFD(), log_Debug, and throw_SystemException.

Referenced by releaseWork().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pollDel()

void dodo::network::TCPListener::pollDel ( const BaseSocket s)
private

Delete the epoll event for the BaseSocket.

Parameters
sThe BaseSocket

Definition at line 479 of file tcplistener.cpp.

References dodo::common::DebugObject::debugString(), epoll_fd_, dodo::network::BaseSocket::getFD(), log_Debug, and throw_SystemException.

Referenced by pushWork().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pollMod()

void dodo::network::TCPListener::pollMod ( const BaseSocket s,
uint32_t  events 
)
private

Modify an epoll event for the BaseSocket.

Parameters
sThe BaseSocket
eventsThe events to set (see man epoll_ctl).

Definition at line 470 of file tcplistener.cpp.

References dodo::common::DebugObject::debugString(), epoll_fd_, dodo::network::BaseSocket::getFD(), log_Debug, and throw_SystemException.

Here is the call graph for this function:

◆ popWork()

TCPListener::SocketWork * dodo::network::TCPListener::popWork ( )
private

Pop work.

Returns
A SocketWork* to handle, or NULL if there is no work to handle.

Definition at line 420 of file tcplistener.cpp.

References clientmutex_, clients_, dodo::common::DebugObject::debugString(), dodo::network::BaseSocket::getFD(), log_Debug, dodo::network::TCPListener::SocketWork::socket, dodo::network::TCPListener::SocketWork::state, and workload_.

Referenced by dodo::network::TCPServer::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushWork() [1/2]

void dodo::network::TCPListener::pushWork ( const SocketWork work)
private

Push work.

Parameters
workThe SocketWork to handle.
See also
SocketWork.

Definition at line 408 of file tcplistener.cpp.

References clientmutex_, clients_, dodo::common::DebugObject::debugString(), dodo::network::BaseSocket::getFD(), log_Debug, New, pollDel(), dodo::network::TCPListener::SocketWork::socket, dodo::network::TCPListener::SocketWork::state, work_q_sz_, and workload_.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushWork() [2/2]

void dodo::network::TCPListener::pushWork ( int  fd,
SockState  state 
)
private

Push work.

Parameters
fdThe BaseSocket fieldescriptor.
stateThe state the BaseSocket is in.
See also
SockState.

Definition at line 396 of file tcplistener.cpp.

References clientmutex_, clients_, log_Debug, New, pollDel(), work_q_sz_, and workload_.

Here is the call graph for this function:

◆ releaseWork()

void dodo::network::TCPListener::releaseWork ( const SocketWork work)
private

Called by a TCPServer to signal that the work has been handled and event detection on it can resume.

Parameters
workThe SocketWork.

Definition at line 435 of file tcplistener.cpp.

References clientmutex_, clients_, closeSocket(), dodo::common::DebugObject::debugString(), dodo::network::BaseSocket::getFD(), hangup_event_mask_, log_Debug, pollAdd(), read_event_mask_, Shut, dodo::network::TCPListener::SocketWork::socket, dodo::network::TCPListener::SocketWork::state, and work_q_sz_.

Referenced by dodo::network::TCPServer::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

void dodo::network::TCPListener::run ( )
privatevirtual

Entrypoint, override of Thread::run()

Implements dodo::threads::Thread.

Definition at line 236 of file tcplistener.cpp.

References dodo::network::BaseSocket::accept(), dodo::network::TCPServer::addServer(), addServers(), dodo::network::Address::asString(), cleanStoppedServers(), clientmutex_, clients_, dodo::network::BaseSocket::close(), closeSocket(), dodo::network::TCPListener::Stats::connections, cv_signal_, dodo::common::DebugObject::debugString(), epoll_fd_, event_maxconnections_reached_, dodo::network::BaseSocket::getFD(), dodo::network::BaseSocket::getPeerAddress(), init_server_, dodo::network::BaseSocket::isValid(), last_stats_, listen_socket_, dodo::network::TCPListener::Params::listener_sleep_ms, log_Debug, log_Error, log_Warning, logStats(), dodo::network::TCPListener::Params::maxconnections, dodo::network::TCPListener::Params::maxservers, dodo::network::TCPListener::Params::minservers, New, dodo::network::TCPServer::newConnectionData(), None, now_, now_mutex_, params_, dodo::network::TCPListener::Params::pollbatch, prev_stat_time_, pushWork(), Read, dodo::network::TCPListener::Params::receive_timeout_seconds, dodo::network::TCPListener::Stats::requests, dodo::network::TCPListener::Params::send_timeout_seconds, server_stopped_check_time_, servers_, dodo::network::BaseSocket::setBlocking(), dodo::network::BaseSocket::setReceiveTimeout(), dodo::network::BaseSocket::setSendTimeout(), dodo::network::BaseSocket::setTCPKeepAlive(), dodo::network::BaseSocket::setTCPNoDelay(), Shut, dodo::threads::Thread::start(), stat_time_, stats_mutex_, stop_server_, dodo::network::TCPListener::Params::tcp_keep_alive, throttle(), throw_SystemException, warn_queue_time_, dodo::common::Exception::what(), and work_q_sz_.

◆ start()

void dodo::network::TCPListener::start ( TCPServer server)

Start the TCPListener and initialize with a TCPServer implementation object.

Parameters
serverA TCPServer descendant as initial server.

Definition at line 231 of file tcplistener.cpp.

References init_server_.

◆ stop()

void dodo::network::TCPListener::stop ( )
inline

Request a stop on the TCPListener.

Call wait() to wait for the thread to actually be stopped.

Definition at line 305 of file tcplistener.hpp.

References stop_server_.

◆ throttle()

void dodo::network::TCPListener::throttle ( )
private

Throttle the listener when work_q_sz_ exceeds params_.maxqdepth.

Definition at line 497 of file tcplistener.cpp.

References dodo::network::TCPListener::Params::cycle_max_throttles, last_stats_, dodo::network::TCPListener::Params::maxqdepth, params_, stats_mutex_, dodo::network::TCPListener::Params::throttle_sleep_us, dodo::network::TCPListener::Stats::throttles, and work_q_sz_.

Referenced by run().

Here is the caller graph for this function:

◆ waitForActivity()

bool dodo::network::TCPListener::waitForActivity ( TCPServer server)
private

Called by the TCPServer, enters wait state until woken up by either a timeout or a notify by TCPListener that there are 1 or more requests to be handled.

Parameters
serverThe TCPServer calling this.
Returns
True if there are pending requests or request_stop_ is true.

Definition at line 224 of file tcplistener.cpp.

References cv_signal_, dodo::network::TCPListener::Params::listener_sleep_ms, mt_signal_, and params_.

Referenced by dodo::network::TCPServer::run().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator&

bool operator& ( const TCPListener::SockState self,
const TCPListener::SockState other 
)
friend

Bitwise & on SocketWork.

Parameters
selfthe lvalue
otherthe rvalue
Returns
the lvalue

Definition at line 595 of file tcplistener.hpp.

◆ operator<<

const friend dodo::common::Puts& operator<< ( const dodo::common::Puts os,
TCPListener::SockState  state 
)
friend

Nice-write to a Puts.

Parameters
osThe output Puts
stateThe TCPListener::SockState to write.
Returns
The output Puts

Definition at line 606 of file tcplistener.hpp.

◆ operator^=

TCPListener::SockState& operator^= ( TCPListener::SockState self,
TCPListener::SockState  other 
)
friend

Bitwise ^= on SocketWork.

Parameters
selfthe lvalue
otherthe rvalue
Returns
the lvalue

Definition at line 585 of file tcplistener.hpp.

◆ operator|=

TCPListener::SockState& operator|= ( TCPListener::SockState self,
TCPListener::SockState  other 
)
friend

Bitwise |= on SocketWork.

Parameters
selfthe lvalue
otherthe rvalue
Returns
the lvalue

Definition at line 575 of file tcplistener.hpp.

◆ TCPListenerTimer

friend class TCPListenerTimer
friend

TCPListenerTimer needs access to now_ and now_mutex_.

Definition at line 554 of file tcplistener.hpp.

◆ TCPServer

friend class TCPServer
friend

TCPServer needs access to several private definitions, data and methods.

Definition at line 559 of file tcplistener.hpp.

Field Documentation

◆ backlog_

int dodo::network::TCPListener::backlog_
private

The backlog (incoming connection queue before accept calls clearing it) used by listen.

See also
man 2 listen

Definition at line 439 of file tcplistener.hpp.

Referenced by construct().

◆ clientmutex_

threads::Mutex dodo::network::TCPListener::clientmutex_
private

Protects both client_ and workload_.

Definition at line 449 of file tcplistener.hpp.

Referenced by closeSocket(), popWork(), pushWork(), releaseWork(), and run().

◆ clients_

std::map<int,SocketWork> dodo::network::TCPListener::clients_
private

Map of file descriptors to SocketWork for all connected clients.

The work is either in progress or last completed state.

Definition at line 467 of file tcplistener.hpp.

Referenced by closeSocket(), logStats(), popWork(), pushWork(), releaseWork(), and run().

◆ cv_signal_

std::condition_variable dodo::network::TCPListener::cv_signal_
private

Condition variable used to wakeup TCPServer threads with mutex mt_signal_.

See also
mt_signal_.

Definition at line 461 of file tcplistener.hpp.

Referenced by cleanStoppedServers(), run(), and waitForActivity().

◆ epoll_fd_

int dodo::network::TCPListener::epoll_fd_
private

The epoll interface file descriptor.

Definition at line 487 of file tcplistener.hpp.

Referenced by pollAdd(), pollDel(), pollMod(), and run().

◆ event_maxconnections_reached_

size_t dodo::network::TCPListener::event_maxconnections_reached_
private

The number of times a connection was closed after accept because params_.maxconnectctions was reached.

Definition at line 549 of file tcplistener.hpp.

Referenced by logStats(), and run().

◆ hangup_event_mask_

uint32_t dodo::network::TCPListener::hangup_event_mask_
private

The event mask for hangup events.

This is the event mask for all error and hangup events, an event mode active whilst a read event for the socket is already queued for processing, so that errors may be caught without clearing any pending read events on the socket.

Definition at line 499 of file tcplistener.hpp.

Referenced by construct(), and releaseWork().

◆ init_server_

TCPServer* dodo::network::TCPListener::init_server_
private

The initial TCPServer, which will live as long as the TCPListener runs, and is sued to create new TCPServers under load.

Definition at line 428 of file tcplistener.hpp.

Referenced by addServers(), cleanStoppedServers(), construct(), run(), and start().

◆ last_stats_

Stats dodo::network::TCPListener::last_stats_
private

The last Stats.

Definition at line 509 of file tcplistener.hpp.

Referenced by addReceivedSentBytes(), logStats(), run(), and throttle().

◆ listen_address_

Address dodo::network::TCPListener::listen_address_
private

The listening address.

Definition at line 417 of file tcplistener.hpp.

Referenced by construct().

◆ listen_socket_

BaseSocket* dodo::network::TCPListener::listen_socket_
private

The listening BaseSocket.

Definition at line 433 of file tcplistener.hpp.

Referenced by construct(), and run().

◆ mt_signal_

std::mutex dodo::network::TCPListener::mt_signal_
private

Mutex used to wakeup TCPServer threads with condition variable cv_signal_.

See also
cv_signal_.

Definition at line 455 of file tcplistener.hpp.

Referenced by waitForActivity().

◆ now_

struct timeval dodo::network::TCPListener::now_
private

Frequently updated by a TCPListenerTimer with enough precision for its use.

Definition at line 544 of file tcplistener.hpp.

Referenced by cleanStoppedServers(), logStats(), and run().

◆ now_mutex_

threads::Mutex dodo::network::TCPListener::now_mutex_
private

Synchronize access to now_.

Definition at line 539 of file tcplistener.hpp.

Referenced by cleanStoppedServers(), logStats(), and run().

◆ params_

Params dodo::network::TCPListener::params_
private

◆ prev_stat_time_

struct timeval dodo::network::TCPListener::prev_stat_time_
private

Time of previous statistics.

Definition at line 524 of file tcplistener.hpp.

Referenced by logStats(), and run().

◆ prev_stats_

Stats dodo::network::TCPListener::prev_stats_
private

The previous Stats.

Definition at line 504 of file tcplistener.hpp.

Referenced by logStats().

◆ read_event_mask_

uint32_t dodo::network::TCPListener::read_event_mask_
private

The event mask for read events.

This is the one-shot event mask for incoming data.

Definition at line 492 of file tcplistener.hpp.

Referenced by construct(), and releaseWork().

◆ server_stopped_check_time_

struct timeval dodo::network::TCPListener::server_stopped_check_time_
private

Time of last check for stopped servers.

Definition at line 534 of file tcplistener.hpp.

Referenced by cleanStoppedServers(), and run().

◆ servers_

std::list<TCPServer*> dodo::network::TCPListener::servers_
private

List of TCPServers.

Definition at line 472 of file tcplistener.hpp.

Referenced by addServers(), cleanStoppedServers(), logStats(), and run().

◆ stat_time_

struct timeval dodo::network::TCPListener::stat_time_
private

Time of last statistics.

Definition at line 529 of file tcplistener.hpp.

Referenced by logStats(), and run().

◆ stats_mutex_

threads::Mutex dodo::network::TCPListener::stats_mutex_
private

Protects prev_stats_, last_stats_.

Definition at line 514 of file tcplistener.hpp.

Referenced by addReceivedSentBytes(), logStats(), run(), and throttle().

◆ stop_server_

bool dodo::network::TCPListener::stop_server_
private

If true, the TCPListener will gracefully stop and finish.

Definition at line 444 of file tcplistener.hpp.

Referenced by construct(), run(), and stop().

◆ warn_queue_time_

struct timeval dodo::network::TCPListener::warn_queue_time_
private

Time of last queueing warning.

Definition at line 519 of file tcplistener.hpp.

Referenced by run().

◆ work_q_sz_

std::atomic<unsigned long long> dodo::network::TCPListener::work_q_sz_
private

The number of queued work items.

Definition at line 482 of file tcplistener.hpp.

Referenced by addServers(), construct(), logStats(), pushWork(), releaseWork(), run(), and throttle().

◆ workload_

std::deque<SocketWork*> dodo::network::TCPListener::workload_
private

Queue of sockets with work for TCPServer instances.

Definition at line 477 of file tcplistener.hpp.

Referenced by popWork(), and pushWork().


The documentation for this class was generated from the following files: