Luanti 5.16.0-dev
Loading...
Searching...
No Matches
con::ConnectionSendThread Class Reference

#include <threads.h>

Inheritance diagram for con::ConnectionSendThread:
Collaboration diagram for con::ConnectionSendThread:

Public Member Functions

 ConnectionSendThread (unsigned int max_packet_size, float timeout)
void * run ()
void Trigger ()
void setParent (Connection *parent)
void setPeerTimeout (float peer_timeout)
Public Member Functions inherited from Thread
 Thread (const std::string &name="")
virtual ~Thread ()
bool start ()
bool stop ()
bool wait ()
bool isCurrentThread () const
bool isRunning () const
bool stopRequested () const
std::thread::id getThreadId () const
bool getReturnValue (void **ret) const
bool bindToProcessor (unsigned int proc_number)
bool setPriority (int prio)

Private Member Functions

void runTimeouts (float dtime, u32 peer_packet_quota)
void resendReliable (Channel &channel, const BufferedPacket *k, float resend_timeout)
void rawSend (const BufferedPacket *p)
bool rawSendAsPacket (session_t peer_id, u8 channelnum, const SharedBuffer< u8 > &data, bool reliable)
void processReliableCommand (ConnectionCommandPtr &c)
void processNonReliableCommand (ConnectionCommandPtr &c)
void serve (Address bind_address)
void connect (Address address)
void disconnect ()
void disconnect_peer (session_t peer_id)
void fix_peer_id (session_t own_peer_id)
void send (session_t peer_id, u8 channelnum, const SharedBuffer< u8 > &data)
void sendReliable (ConnectionCommandPtr &c)
void sendToAll (u8 channelnum, const SharedBuffer< u8 > &data)
void sendToAllReliable (ConnectionCommandPtr &c)
void sendPackets (float dtime, u32 peer_packet_quota)
void sendAsPacket (session_t peer_id, u8 channelnum, const SharedBuffer< u8 > &data, bool ack=false)
void sendAsPacketReliable (BufferedPacketPtr &p, Channel *channel)
bool packetsQueued ()

Private Attributes

Connectionm_connection = nullptr
unsigned int m_max_packet_size
float m_timeout
std::queue< OutgoingPacketm_outgoing_queue
Semaphore m_send_sleep_semaphore
unsigned int m_iteration_packets_avaialble
unsigned int m_max_data_packets_per_iteration
unsigned int m_max_packets_requeued = 256

Friends

class UDPPeer

Additional Inherited Members

Static Public Member Functions inherited from Thread
static ThreadgetCurrentThread ()
static void setName (const std::string &name)
static unsigned int getNumberOfProcessors ()
Protected Attributes inherited from Thread
std::string m_name

Constructor & Destructor Documentation

◆ ConnectionSendThread()

con::ConnectionSendThread::ConnectionSendThread ( unsigned int max_packet_size,
float timeout )

References Thread::Thread(), g_settings, Settings::getLayer(), m_max_data_packets_per_iteration, m_max_packet_size, m_timeout, MPPI_SETTING, MYMAX, SL_DEFAULTS, and warningstream.

Here is the call graph for this function:

Member Function Documentation

◆ connect()

void con::ConnectionSendThread::connect ( Address address)
private

References con::Peer::address, dout_con, con::IPeer::id, Address::isIPv6(), m_connection, PEER_ID_INEXISTENT, PEER_ID_SERVER, con::ConnectionEvent::peerAdded(), Address::print(), Address::setAddress(), and UDPPeer.

Referenced by processNonReliableCommand().

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

◆ disconnect()

void con::ConnectionSendThread::disconnect ( )
private

References con::CONTROLTYPE_DISCO, dout_con, LOG, m_connection, con::PACKET_TYPE_CONTROL, sendAsPacket(), and writeU8().

Referenced by processNonReliableCommand().

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

◆ disconnect_peer()

void con::ConnectionSendThread::disconnect_peer ( session_t peer_id)
private

References con::CONTROLTYPE_DISCO, dout_con, LOG, m_connection, con::PACKET_TYPE_CONTROL, sendAsPacket(), UDPPeer, and writeU8().

Referenced by processNonReliableCommand().

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

◆ fix_peer_id()

void con::ConnectionSendThread::fix_peer_id ( session_t own_peer_id)
private

References CHANNEL_COUNT, m_connection, and UDPPeer.

Referenced by processNonReliableCommand().

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

◆ packetsQueued()

bool con::ConnectionSendThread::packetsQueued ( )
private

References m_connection, m_outgoing_queue, and UDPPeer.

Referenced by run().

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

◆ processNonReliableCommand()

void con::ConnectionSendThread::processNonReliableCommand ( ConnectionCommandPtr & c)
private

◆ processReliableCommand()

void con::ConnectionSendThread::processReliableCommand ( ConnectionCommandPtr & c)
private

References con::CONCMD_ACK, con::CONCMD_CREATE_PEER, con::CONNCMD_CONNECT, con::CONNCMD_DISCONNECT, con::CONNCMD_NONE, con::CONNCMD_RESEND_ONE, con::CONNCMD_SEND, con::CONNCMD_SEND_TO_ALL, con::CONNCMD_SERVE, dout_con, FATAL_ERROR, con::ReliablePacketBuffer::getResend(), LOG, m_connection, con::Channel::outgoing_reliables_sent, rawSendAsPacket(), resendReliable(), sendReliable(), sendToAllReliable(), and UDPPeer.

Referenced by run().

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

◆ rawSend()

void con::ConnectionSendThread::rawSend ( const BufferedPacket * p)
private

References derr_con, LOG, m_connection, p(), and BaseException::what().

Referenced by rawSendAsPacket(), resendReliable(), and sendAsPacketReliable().

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

◆ rawSendAsPacket()

bool con::ConnectionSendThread::rawSendAsPacket ( session_t peer_id,
u8 channelnum,
const SharedBuffer< u8 > & data,
bool reliable )
private

References dout_con, errorstream, con::IPeer::getAddress(), con::Channel::getOutgoingSequenceNumber(), con::Channel::getWindowSize(), LOG, m_connection, con::makePacket(), con::makeReliablePacket(), con::Channel::outgoing_reliables_sent, p(), con::Channel::queued_reliables, rawSend(), sendAsPacketReliable(), con::ReliablePacketBuffer::size(), and UDPPeer.

Referenced by processReliableCommand(), runTimeouts(), and sendPackets().

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

◆ resendReliable()

void con::ConnectionSendThread::resendReliable ( Channel & channel,
const BufferedPacket * k,
float resend_timeout )
private

References con::BufferedPacket::address, con::BufferedPacket::data, derr_con, con::BufferedPacket::getSeqnum(), m_connection, rawSend(), con::readChannel(), con::BufferedPacket::resend_count, Address::serializeString(), con::BufferedPacket::size(), and con::Channel::UpdateBytesLost().

Referenced by processReliableCommand(), and runTimeouts().

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

◆ run()

void * con::ConnectionSendThread::run ( )
virtual

◆ runTimeouts()

void con::ConnectionSendThread::runTimeouts ( float dtime,
u32 peer_packet_quota )
private

References CHANNEL_COUNT, con::UDPPeer::channels, dout_con, g_profiler, con::UDPPeer::getResendTimeout(), con::IPeer::id, con::Channel::incoming_splits, infostream, con::Peer::isHalfOpen(), con::Peer::isTimedOut(), LOG, m_connection, m_iteration_packets_avaialble, m_max_packet_size, m_max_packets_requeued, m_timeout, MYMAX, con::UDPPeer::Ping(), PROFILE, rawSendAsPacket(), con::IncomingSplitBuffer::removeUnreliableTimedOuts(), resendReliable(), con::UDPPeer::RunCommandQueues(), SPT_AVG, and UDPPeer.

Referenced by run().

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

◆ send()

void con::ConnectionSendThread::send ( session_t peer_id,
u8 channelnum,
const SharedBuffer< u8 > & data )
private

References BASE_HEADER_SIZE, CHANNEL_COUNT, dout_con, con::Peer::getNextSplitSequenceNumber(), SharedBuffer< T >::getSize(), LOG, m_connection, m_max_packet_size, con::makeAutoSplitPacket(), sendAsPacket(), and con::Peer::setNextSplitSequenceNumber().

Referenced by processNonReliableCommand(), and sendToAll().

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

◆ sendAsPacket()

void con::ConnectionSendThread::sendAsPacket ( session_t peer_id,
u8 channelnum,
const SharedBuffer< u8 > & data,
bool ack = false )
private

References m_outgoing_queue.

Referenced by disconnect(), disconnect_peer(), processNonReliableCommand(), and send().

Here is the caller graph for this function:

◆ sendAsPacketReliable()

void con::ConnectionSendThread::sendAsPacketReliable ( BufferedPacketPtr & p,
Channel * channel )
private

References derr_con, porting::getTimeMs(), con::ReliablePacketBuffer::insert(), LOG, m_connection, MAX_RELIABLE_WINDOW_SIZE, con::Channel::outgoing_reliables_sent, p(), rawSend(), and con::Channel::readOutgoingSequenceNumber().

Referenced by rawSendAsPacket(), and sendPackets().

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

◆ sendPackets()

void con::ConnectionSendThread::sendPackets ( float dtime,
u32 peer_packet_quota )
private

◆ sendReliable()

void con::ConnectionSendThread::sendReliable ( ConnectionCommandPtr & c)
private

References m_connection, m_max_packet_size, and con::Peer::PutReliableSendCommand().

Referenced by processReliableCommand().

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

◆ sendToAll()

void con::ConnectionSendThread::sendToAll ( u8 channelnum,
const SharedBuffer< u8 > & data )
private

References m_connection, and send().

Referenced by processNonReliableCommand().

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

◆ sendToAllReliable()

void con::ConnectionSendThread::sendToAllReliable ( ConnectionCommandPtr & c)
private

References m_connection, m_max_packet_size, and con::Peer::PutReliableSendCommand().

Referenced by processReliableCommand().

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

◆ serve()

void con::ConnectionSendThread::serve ( Address bind_address)
private

References con::ConnectionEvent::bindFailed(), dout_con, LOG, m_connection, PEER_ID_SERVER, and Address::serializeString().

Referenced by processNonReliableCommand().

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

◆ setParent()

void con::ConnectionSendThread::setParent ( Connection * parent)
inline

References m_connection.

◆ setPeerTimeout()

void con::ConnectionSendThread::setPeerTimeout ( float peer_timeout)
inline

References m_timeout.

◆ Trigger()

void con::ConnectionSendThread::Trigger ( )

◆ UDPPeer

Member Data Documentation

◆ m_connection

◆ m_iteration_packets_avaialble

unsigned int con::ConnectionSendThread::m_iteration_packets_avaialble
private

Referenced by run(), and runTimeouts().

◆ m_max_data_packets_per_iteration

unsigned int con::ConnectionSendThread::m_max_data_packets_per_iteration
private

Referenced by ConnectionSendThread(), and run().

◆ m_max_packet_size

unsigned int con::ConnectionSendThread::m_max_packet_size
private

◆ m_max_packets_requeued

unsigned int con::ConnectionSendThread::m_max_packets_requeued = 256
private

Referenced by runTimeouts().

◆ m_outgoing_queue

std::queue<OutgoingPacket> con::ConnectionSendThread::m_outgoing_queue
private

◆ m_send_sleep_semaphore

Semaphore con::ConnectionSendThread::m_send_sleep_semaphore
private

Referenced by run(), and Trigger().

◆ m_timeout

float con::ConnectionSendThread::m_timeout
private

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