fix sam crash on exit and datagram crash with no outbound tunnel

This commit is contained in:
Jeff Becker 2016-12-18 12:56:34 -05:00
parent d5f27ecb0e
commit 673b7a95b7
3 changed files with 13 additions and 18 deletions

View File

@ -310,7 +310,7 @@ namespace datagram
std::vector<i2p::tunnel::TunnelMessageBlock> send; std::vector<i2p::tunnel::TunnelMessageBlock> send;
auto routingPath = GetSharedRoutingPath(); auto routingPath = GetSharedRoutingPath();
// if we don't have a routing path we will drop all queued messages // if we don't have a routing path we will drop all queued messages
if(routingPath) if(routingPath && routingPath->outboundTunnel && routingPath->remoteLease)
{ {
for (const auto & msg : m_SendQueue) for (const auto & msg : m_SendQueue)
{ {

28
SAM.cpp
View File

@ -710,11 +710,6 @@ namespace client
{ {
PumpBacklog(); PumpBacklog();
} }
SAMSession::~SAMSession ()
{
i2p::client::context.DeleteLocalDestination (localDestination);
}
void SAMSession::AcceptI2P(std::shared_ptr<i2p::stream::Stream> stream) void SAMSession::AcceptI2P(std::shared_ptr<i2p::stream::Stream> stream)
{ {
@ -767,18 +762,19 @@ namespace client
void SAMSession::CloseStreams () void SAMSession::CloseStreams ()
{ {
m_BacklogPumper.cancel();
localDestination->GetService().post([&] () { localDestination->GetService().post([&] () {
std::lock_guard<std::mutex> lock(m_SocketsMutex); std::lock_guard<std::mutex> lock(m_SocketsMutex);
for (auto& sock : m_Sockets) { for (auto& sock : m_Sockets) {
sock->CloseStream(); sock->CloseStream();
} }
for(auto & stream : m_Backlog) { for(auto & stream : m_Backlog) {
stream->Close(); stream->Close();
} }
// XXX: should this be done inside locked parts? m_Sockets.clear();
m_Sockets.clear(); m_Backlog.clear();
m_Backlog.clear(); i2p::client::context.DeleteLocalDestination (localDestination);
}); });
} }
SAMBridge::SAMBridge (const std::string& address, int port): SAMBridge::SAMBridge (const std::string& address, int port):

1
SAM.h
View File

@ -165,7 +165,6 @@ namespace client
} }
SAMSession (std::shared_ptr<ClientDestination> dest); SAMSession (std::shared_ptr<ClientDestination> dest);
~SAMSession ();
void AcceptI2P(std::shared_ptr<i2p::stream::Stream> stream); void AcceptI2P(std::shared_ptr<i2p::stream::Stream> stream);