mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
max flush interval
This commit is contained in:
parent
fa218d3cf5
commit
02c52f59cb
@ -288,8 +288,8 @@ namespace datagram
|
|||||||
|
|
||||||
DatagramSession::DatagramSession(std::shared_ptr<i2p::client::ClientDestination> localDestination,
|
DatagramSession::DatagramSession(std::shared_ptr<i2p::client::ClientDestination> localDestination,
|
||||||
const i2p::data::IdentHash & remoteIdent) :
|
const i2p::data::IdentHash & remoteIdent) :
|
||||||
m_LocalDestination(localDestination),
|
m_LocalDestination(localDestination), m_RemoteIdent(remoteIdent),
|
||||||
m_RemoteIdent(remoteIdent),
|
m_LastUse (0), m_LastFlush (0),
|
||||||
m_RequestingLS(false)
|
m_RequestingLS(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -310,8 +310,12 @@ namespace datagram
|
|||||||
if (msg || m_SendQueue.empty ())
|
if (msg || m_SendQueue.empty ())
|
||||||
m_SendQueue.push_back(msg);
|
m_SendQueue.push_back(msg);
|
||||||
// flush queue right away if full
|
// flush queue right away if full
|
||||||
if (!msg || m_SendQueue.size() >= DATAGRAM_SEND_QUEUE_MAX_SIZE)
|
if (!msg || m_SendQueue.size() >= DATAGRAM_SEND_QUEUE_MAX_SIZE ||
|
||||||
|
m_LastUse > m_LastFlush + DATAGRAM_MAX_FLUSH_INTERVAL)
|
||||||
|
{
|
||||||
FlushSendQueue();
|
FlushSendQueue();
|
||||||
|
m_LastFlush = ts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DatagramSession::Info DatagramSession::GetSessionInfo() const
|
DatagramSession::Info DatagramSession::GetSessionInfo() const
|
||||||
@ -344,7 +348,7 @@ namespace datagram
|
|||||||
if(path)
|
if(path)
|
||||||
path->updateTime = i2p::util::GetSecondsSinceEpoch ();
|
path->updateTime = i2p::util::GetSecondsSinceEpoch ();
|
||||||
if (IsRatchets ())
|
if (IsRatchets ())
|
||||||
SendMsg (nullptr); // send empty message in case if we have some data to send
|
SendMsg (nullptr); // send empty message in case if we don't have some data to send
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<i2p::garlic::GarlicRoutingPath> DatagramSession::GetSharedRoutingPath ()
|
std::shared_ptr<i2p::garlic::GarlicRoutingPath> DatagramSession::GetSharedRoutingPath ()
|
||||||
|
@ -43,6 +43,7 @@ namespace datagram
|
|||||||
const uint64_t DATAGRAM_SESSION_PATH_MIN_LIFETIME = 5 * 1000;
|
const uint64_t DATAGRAM_SESSION_PATH_MIN_LIFETIME = 5 * 1000;
|
||||||
// max 64 messages buffered in send queue for each datagram session
|
// max 64 messages buffered in send queue for each datagram session
|
||||||
const size_t DATAGRAM_SEND_QUEUE_MAX_SIZE = 64;
|
const size_t DATAGRAM_SEND_QUEUE_MAX_SIZE = 64;
|
||||||
|
const uint64_t DATAGRAM_MAX_FLUSH_INTERVAL = 5; // in milliseconds
|
||||||
|
|
||||||
class DatagramSession : public std::enable_shared_from_this<DatagramSession>
|
class DatagramSession : public std::enable_shared_from_this<DatagramSession>
|
||||||
{
|
{
|
||||||
@ -98,7 +99,7 @@ namespace datagram
|
|||||||
std::shared_ptr<i2p::garlic::GarlicRoutingSession> m_RoutingSession;
|
std::shared_ptr<i2p::garlic::GarlicRoutingSession> m_RoutingSession;
|
||||||
std::vector<std::shared_ptr<i2p::garlic::GarlicRoutingSession> > m_PendingRoutingSessions;
|
std::vector<std::shared_ptr<i2p::garlic::GarlicRoutingSession> > m_PendingRoutingSessions;
|
||||||
std::vector<std::shared_ptr<I2NPMessage> > m_SendQueue;
|
std::vector<std::shared_ptr<I2NPMessage> > m_SendQueue;
|
||||||
uint64_t m_LastUse;
|
uint64_t m_LastUse, m_LastFlush; // milliseconds
|
||||||
bool m_RequestingLS;
|
bool m_RequestingLS;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user