Minetest  5.4.0
con::ConnectionSendThread Class Reference

#include <connectionthreads.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 ()
 
bool isRunning ()
 
bool stopRequested ()
 
std::thread::id getThreadId ()
 
bool getReturnValue (void **ret)
 
bool bindToProcessor (unsigned int proc_number)
 
bool setPriority (int prio)
 

Private Member Functions

void runTimeouts (float dtime)
 
void rawSend (const BufferedPacket &packet)
 
bool rawSendAsPacket (session_t peer_id, u8 channelnum, const SharedBuffer< u8 > &data, bool reliable)
 
void processReliableCommand (ConnectionCommand &c)
 
void processNonReliableCommand (ConnectionCommand &c)
 
void serve (Address bind_address)
 
void connect (Address address)
 
void disconnect ()
 
void disconnect_peer (session_t peer_id)
 
void send (session_t peer_id, u8 channelnum, const SharedBuffer< u8 > &data)
 
void sendReliable (ConnectionCommand &c)
 
void sendToAll (u8 channelnum, const SharedBuffer< u8 > &data)
 
void sendToAllReliable (ConnectionCommand &c)
 
void sendPackets (float dtime)
 
void sendAsPacket (session_t peer_id, u8 channelnum, const SharedBuffer< u8 > &data, bool ack=false)
 
void sendAsPacketReliable (BufferedPacket &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_commands_per_iteration = 1
 
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 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 
)

Member Function Documentation

◆ connect()

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

References con::Peer::address, UDPSocket::Bind(), con::Connection::createServerPeer(), dout_con, con::Connection::getDesc(), Address::getPort(), con::Peer::id, Address::isIPv6(), LOG, m_connection, con::Connection::m_udpSocket, PEER_ID_INEXISTENT, PEER_ID_SERVER, con::ConnectionEvent::peerAdded(), con::Connection::putEvent(), con::Connection::Send(), Address::serializeString(), Address::setAddress(), and con::Connection::SetPeerID().

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 CONTROLTYPE_DISCO, dout_con, con::Connection::getDesc(), con::Connection::getPeerIDs(), 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 CONTROLTYPE_DISCO, dout_con, con::Connection::getDesc(), con::Connection::getPeerNoEx(), 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:

◆ packetsQueued()

bool con::ConnectionSendThread::packetsQueued ( )
private

References con::Connection::getPeerIDs(), con::Connection::getPeerNoEx(), m_connection, and m_outgoing_queue.

Referenced by run().

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

◆ processNonReliableCommand()

void con::ConnectionSendThread::processNonReliableCommand ( ConnectionCommand c)
private

References con::ConnectionCommand::address, con::ConnectionCommand::channelnum, con::CONCMD_ACK, con::CONCMD_CREATE_PEER, con::CONNCMD_CONNECT, con::CONNCMD_DISCONNECT, con::CONNCMD_DISCONNECT_PEER, con::CONNCMD_NONE, con::CONNCMD_SEND, con::CONNCMD_SEND_TO_ALL, con::CONNCMD_SERVE, connect(), con::ConnectionCommand::data, disconnect(), disconnect_peer(), dout_con, FATAL_ERROR, con::Connection::getDesc(), LOG, m_connection, con::ConnectionCommand::peer_id, con::ConnectionCommand::reliable, send(), sendAsPacket(), sendToAll(), Address::serializeString(), serve(), and con::ConnectionCommand::type.

Referenced by run().

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

◆ processReliableCommand()

void con::ConnectionSendThread::processReliableCommand ( ConnectionCommand c)
private

References con::ConnectionCommand::channelnum, con::CONCMD_ACK, con::CONCMD_CREATE_PEER, con::CONNCMD_CONNECT, con::CONNCMD_DISCONNECT, con::CONNCMD_NONE, con::CONNCMD_SEND, con::CONNCMD_SEND_TO_ALL, con::CONNCMD_SERVE, con::ConnectionCommand::data, dout_con, FATAL_ERROR, con::Connection::getDesc(), LOG, m_connection, con::ConnectionCommand::peer_id, rawSendAsPacket(), con::ConnectionCommand::reliable, sendReliable(), sendToAllReliable(), and con::ConnectionCommand::type.

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 packet)
private

References con::BufferedPacket::address, con::BufferedPacket::data, derr_con, dout_con, con::Connection::getDesc(), Buffer< T >::getSize(), LOG, m_connection, con::Connection::m_udpSocket, UDPSocket::Send(), and Address::serializeString().

Referenced by rawSendAsPacket(), runTimeouts(), 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::Peer::getAddress(), con::Connection::getDesc(), con::Channel::getOutgoingSequenceNumber(), con::Connection::GetPeerID(), con::Connection::getPeerNoEx(), con::Connection::GetProtocolID(), con::Channel::getWindowSize(), LOG, m_connection, con::makePacket(), con::makeReliablePacket(), con::MTP_MINETEST_RELIABLE_UDP, con::MTP_UDP, con::Channel::outgoing_reliables_sent, p(), con::Channel::queued_reliables, rawSend(), sendAsPacketReliable(), and con::ReliablePacketBuffer::size().

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

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

◆ run()

◆ runTimeouts()

◆ 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::Connection::getDesc(), con::Peer::getNextSplitSequenceNumber(), con::Connection::getPeerNoEx(), 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 ( BufferedPacket p,
Channel channel 
)
private

References derr_con, con::Connection::getDesc(), 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()

◆ sendReliable()

void con::ConnectionSendThread::sendReliable ( ConnectionCommand c)
private

References con::Connection::getPeerNoEx(), m_connection, m_max_packet_size, con::ConnectionCommand::peer_id, 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 con::Connection::getPeerIDs(), 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 ( ConnectionCommand c)
private

References con::Connection::getPeerIDs(), con::Connection::getPeerNoEx(), 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 UDPSocket::Bind(), con::ConnectionEvent::bindFailed(), dout_con, con::Connection::getDesc(), LOG, m_connection, con::Connection::m_udpSocket, PEER_ID_SERVER, con::Connection::putEvent(), Address::serializeString(), and con::Connection::SetPeerID().

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 ( )

References m_send_sleep_semaphore, and Semaphore::post().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ UDPPeer

friend class UDPPeer
friend

Member Data Documentation

◆ m_connection

◆ m_iteration_packets_avaialble

unsigned int con::ConnectionSendThread::m_iteration_packets_avaialble
private

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

◆ m_max_commands_per_iteration

unsigned int con::ConnectionSendThread::m_max_commands_per_iteration = 1
private

Referenced by runTimeouts().

◆ m_max_data_packets_per_iteration

unsigned int con::ConnectionSendThread::m_max_data_packets_per_iteration
private

◆ 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

Referenced by runTimeouts(), and setPeerTimeout().


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