mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-08 22:57:52 +00:00
Merge pull request #778 from majestrate/datagram-fix-2017-01-13
use std::shared_from_this for DatagramSession
This commit is contained in:
commit
c70817b21a
@ -182,7 +182,8 @@ namespace datagram
|
|||||||
// we used this session
|
// we used this session
|
||||||
m_LastUse = i2p::util::GetMillisecondsSinceEpoch();
|
m_LastUse = i2p::util::GetMillisecondsSinceEpoch();
|
||||||
// schedule send
|
// schedule send
|
||||||
m_LocalDestination->GetService().post(std::bind(&DatagramSession::HandleSend, this, msg));
|
auto self = shared_from_this();
|
||||||
|
m_LocalDestination->GetService().post(std::bind(&DatagramSession::HandleSend, self, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
DatagramSession::Info DatagramSession::GetSessionInfo() const
|
DatagramSession::Info DatagramSession::GetSessionInfo() const
|
||||||
@ -334,7 +335,8 @@ namespace datagram
|
|||||||
{
|
{
|
||||||
boost::posix_time::milliseconds dlt(100);
|
boost::posix_time::milliseconds dlt(100);
|
||||||
m_SendQueueTimer.expires_from_now(dlt);
|
m_SendQueueTimer.expires_from_now(dlt);
|
||||||
m_SendQueueTimer.async_wait([this](const boost::system::error_code & ec) { if(ec) return; FlushSendQueue(); });
|
auto self = shared_from_this();
|
||||||
|
m_SendQueueTimer.async_wait([self](const boost::system::error_code & ec) { if(ec) return; self->FlushSendQueue(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace datagram
|
|||||||
// 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;
|
||||||
|
|
||||||
class DatagramSession
|
class DatagramSession : public std::enable_shared_from_this<DatagramSession>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DatagramSession(i2p::client::ClientDestination * localDestination,
|
DatagramSession(i2p::client::ClientDestination * localDestination,
|
||||||
@ -91,6 +91,8 @@ namespace datagram
|
|||||||
bool m_RequestingLS;
|
bool m_RequestingLS;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::shared_ptr<DatagramSession> DatagramSession_ptr;
|
||||||
|
|
||||||
const size_t MAX_DATAGRAM_SIZE = 32768;
|
const size_t MAX_DATAGRAM_SIZE = 32768;
|
||||||
class DatagramDestination
|
class DatagramDestination
|
||||||
{
|
{
|
||||||
@ -132,7 +134,7 @@ namespace datagram
|
|||||||
i2p::data::IdentityEx m_Identity;
|
i2p::data::IdentityEx m_Identity;
|
||||||
Receiver m_Receiver; // default
|
Receiver m_Receiver; // default
|
||||||
std::mutex m_SessionsMutex;
|
std::mutex m_SessionsMutex;
|
||||||
std::map<i2p::data::IdentHash, std::shared_ptr<DatagramSession> > m_Sessions;
|
std::map<i2p::data::IdentHash, DatagramSession_ptr > m_Sessions;
|
||||||
std::mutex m_ReceiversMutex;
|
std::mutex m_ReceiversMutex;
|
||||||
std::map<uint16_t, Receiver> m_ReceiversByPorts;
|
std::map<uint16_t, Receiver> m_ReceiversByPorts;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user