mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
don't drop destination's acceptor if inactive acceptor gets closed
This commit is contained in:
parent
382308c3fd
commit
29ceed74a2
2 changed files with 8 additions and 2 deletions
9
SAM.cpp
9
SAM.cpp
|
@ -18,7 +18,7 @@ namespace client
|
||||||
SAMSocket::SAMSocket (SAMBridge& owner):
|
SAMSocket::SAMSocket (SAMBridge& owner):
|
||||||
m_Owner (owner), m_Socket (m_Owner.GetService ()), m_Timer (m_Owner.GetService ()),
|
m_Owner (owner), m_Socket (m_Owner.GetService ()), m_Timer (m_Owner.GetService ()),
|
||||||
m_BufferOffset (0), m_SocketType (eSAMSocketTypeUnknown), m_IsSilent (false),
|
m_BufferOffset (0), m_SocketType (eSAMSocketTypeUnknown), m_IsSilent (false),
|
||||||
m_Stream (nullptr), m_Session (nullptr)
|
m_IsAccepting (false), m_Stream (nullptr), m_Session (nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ namespace client
|
||||||
if (m_Session)
|
if (m_Session)
|
||||||
{
|
{
|
||||||
m_Session->DelSocket (shared_from_this ());
|
m_Session->DelSocket (shared_from_this ());
|
||||||
if (m_Session->localDestination)
|
if (m_IsAccepting && m_Session->localDestination)
|
||||||
m_Session->localDestination->StopAcceptingStreams ();
|
m_Session->localDestination->StopAcceptingStreams ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -438,7 +438,10 @@ namespace client
|
||||||
m_SocketType = eSAMSocketTypeAcceptor;
|
m_SocketType = eSAMSocketTypeAcceptor;
|
||||||
m_Session->AddSocket (shared_from_this ());
|
m_Session->AddSocket (shared_from_this ());
|
||||||
if (!m_Session->localDestination->IsAcceptingStreams ())
|
if (!m_Session->localDestination->IsAcceptingStreams ())
|
||||||
|
{
|
||||||
|
m_IsAccepting = true;
|
||||||
m_Session->localDestination->AcceptOnce (std::bind (&SAMSocket::HandleI2PAccept, shared_from_this (), std::placeholders::_1));
|
m_Session->localDestination->AcceptOnce (std::bind (&SAMSocket::HandleI2PAccept, shared_from_this (), std::placeholders::_1));
|
||||||
|
}
|
||||||
SendMessageReply (SAM_STREAM_STATUS_OK, strlen(SAM_STREAM_STATUS_OK), false);
|
SendMessageReply (SAM_STREAM_STATUS_OK, strlen(SAM_STREAM_STATUS_OK), false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -701,6 +704,7 @@ namespace client
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SAM: incoming I2P connection for session ", m_ID);
|
LogPrint (eLogDebug, "SAM: incoming I2P connection for session ", m_ID);
|
||||||
m_SocketType = eSAMSocketTypeStream;
|
m_SocketType = eSAMSocketTypeStream;
|
||||||
|
m_IsAccepting = false;
|
||||||
m_Stream = stream;
|
m_Stream = stream;
|
||||||
context.GetAddressBook ().InsertAddress (stream->GetRemoteIdentity ());
|
context.GetAddressBook ().InsertAddress (stream->GetRemoteIdentity ());
|
||||||
auto session = m_Owner.FindSession (m_ID);
|
auto session = m_Owner.FindSession (m_ID);
|
||||||
|
@ -710,6 +714,7 @@ namespace client
|
||||||
for (auto it: session->ListSockets ())
|
for (auto it: session->ListSockets ())
|
||||||
if (it->m_SocketType == eSAMSocketTypeAcceptor)
|
if (it->m_SocketType == eSAMSocketTypeAcceptor)
|
||||||
{
|
{
|
||||||
|
it->m_IsAccepting = true;
|
||||||
session->localDestination->AcceptOnce (std::bind (&SAMSocket::HandleI2PAccept, it, std::placeholders::_1));
|
session->localDestination->AcceptOnce (std::bind (&SAMSocket::HandleI2PAccept, it, std::placeholders::_1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
1
SAM.h
1
SAM.h
|
@ -131,6 +131,7 @@ namespace client
|
||||||
SAMSocketType m_SocketType;
|
SAMSocketType m_SocketType;
|
||||||
std::string m_ID; // nickname
|
std::string m_ID; // nickname
|
||||||
bool m_IsSilent;
|
bool m_IsSilent;
|
||||||
|
bool m_IsAccepting; // for eSAMSocketTypeAcceptor only
|
||||||
std::shared_ptr<i2p::stream::Stream> m_Stream;
|
std::shared_ptr<i2p::stream::Stream> m_Stream;
|
||||||
std::shared_ptr<SAMSession> m_Session;
|
std::shared_ptr<SAMSession> m_Session;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue