Browse Source

fixed shared_ptr error

pull/781/head
orignal 8 years ago
parent
commit
2cbdb0bc17
  1. 13
      Datagram.cpp
  2. 6
      Datagram.h

13
Datagram.cpp

@ -99,6 +99,8 @@ namespace datagram @@ -99,6 +99,8 @@ namespace datagram
size_t uncompressedLen = m_Inflator.Inflate (buf, len, uncompressed, MAX_DATAGRAM_SIZE);
if (uncompressedLen)
HandleDatagram (fromPort, toPort, uncompressed, uncompressedLen);
else
LogPrint (eLogWarning, "Datagram: decompression failed");
}
std::shared_ptr<I2NPMessage> DatagramDestination::CreateDataMessage (const uint8_t * payload, size_t len, uint16_t fromPort, uint16_t toPort)
@ -134,6 +136,7 @@ namespace datagram @@ -134,6 +136,7 @@ namespace datagram
if (now - it->second->LastActivity() >= DATAGRAM_SESSION_MAX_IDLE)
{
LogPrint(eLogInfo, "DatagramDestination: expiring idle session with ", it->first.ToBase32());
it->second->Stop ();
it = m_Sessions.erase (it); // we are expired
}
else
@ -149,6 +152,7 @@ namespace datagram @@ -149,6 +152,7 @@ namespace datagram
if (itr == m_Sessions.end()) {
// not found, create new session
session = std::make_shared<DatagramSession>(m_Owner, identity);
session->Start ();
m_Sessions[identity] = session;
} else {
session = itr->second;
@ -172,11 +176,20 @@ namespace datagram @@ -172,11 +176,20 @@ namespace datagram
m_RemoteIdent(remoteIdent),
m_SendQueueTimer(localDestination->GetService()),
m_RequestingLS(false)
{
}
void DatagramSession::Start ()
{
m_LastUse = i2p::util::GetMillisecondsSinceEpoch ();
ScheduleFlushSendQueue();
}
void DatagramSession::Stop ()
{
m_SendQueueTimer.cancel ();
}
void DatagramSession::SendMsg(std::shared_ptr<I2NPMessage> msg)
{
// we used this session

6
Datagram.h

@ -37,8 +37,10 @@ namespace datagram @@ -37,8 +37,10 @@ namespace datagram
class DatagramSession : public std::enable_shared_from_this<DatagramSession>
{
public:
DatagramSession(i2p::client::ClientDestination * localDestination,
const i2p::data::IdentHash & remoteIdent);
DatagramSession(i2p::client::ClientDestination * localDestination, const i2p::data::IdentHash & remoteIdent);
void Start ();
void Stop ();
/** @brief ack the garlic routing path */

Loading…
Cancel
Save