mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
use weak_ptr for transport session
Some checks failed
Build Debian packages / ${{ matrix.dist }} (bookworm) (push) Has been cancelled
Build Debian packages / ${{ matrix.dist }} (bullseye) (push) Has been cancelled
Build Debian packages / ${{ matrix.dist }} (buster) (push) Has been cancelled
Build on FreeBSD / with UPnP (push) Has been cancelled
Build on Windows / ${{ matrix.arch }} (i686, x86, gcc, MINGW32) (push) Has been cancelled
Build on OSX / With USE_UPNP=${{ matrix.with_upnp }} (no) (push) Has been cancelled
Build on OSX / With USE_UPNP=${{ matrix.with_upnp }} (yes) (push) Has been cancelled
Build on Windows / ${{ matrix.arch }} (clang-x86_64, x64-clang, clang, CLANG64) (push) Has been cancelled
Build on Windows / ${{ matrix.arch }} (ucrt-x86_64, x64-ucrt, gcc, UCRT64) (push) Has been cancelled
Build on Windows / ${{ matrix.arch }} (x86_64, x64, gcc, MINGW64) (push) Has been cancelled
Build on Windows / CMake ${{ matrix.arch }} (clang-x86_64, x64-clang, clang, CLANG64) (push) Has been cancelled
Build on Windows / CMake ${{ matrix.arch }} (i686, x86, gcc, MINGW32) (push) Has been cancelled
Build on Windows / CMake ${{ matrix.arch }} (ucrt-x86_64, x64-ucrt, gcc, UCRT64) (push) Has been cancelled
Build on Windows / CMake ${{ matrix.arch }} (x86_64, x64, gcc, MINGW64) (push) Has been cancelled
Build on Windows / XP (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=${{ matrix.with_upnp }} (no) (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=${{ matrix.with_upnp }} (yes) (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=${{ matrix.with_upnp }} (OFF) (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=${{ matrix.with_upnp }} (ON) (push) Has been cancelled
Build containers / Building container for ${{ matrix.platform }} (amd64, linux/amd64) (push) Has been cancelled
Build containers / Building container for ${{ matrix.platform }} (arm64, linux/arm64) (push) Has been cancelled
Build containers / Building container for ${{ matrix.platform }} (armv7, linux/arm/v7) (push) Has been cancelled
Build containers / Building container for ${{ matrix.platform }} (i386, linux/386) (push) Has been cancelled
Build containers / Pushing merged manifest (push) Has been cancelled
Some checks failed
Build Debian packages / ${{ matrix.dist }} (bookworm) (push) Has been cancelled
Build Debian packages / ${{ matrix.dist }} (bullseye) (push) Has been cancelled
Build Debian packages / ${{ matrix.dist }} (buster) (push) Has been cancelled
Build on FreeBSD / with UPnP (push) Has been cancelled
Build on Windows / ${{ matrix.arch }} (i686, x86, gcc, MINGW32) (push) Has been cancelled
Build on OSX / With USE_UPNP=${{ matrix.with_upnp }} (no) (push) Has been cancelled
Build on OSX / With USE_UPNP=${{ matrix.with_upnp }} (yes) (push) Has been cancelled
Build on Windows / ${{ matrix.arch }} (clang-x86_64, x64-clang, clang, CLANG64) (push) Has been cancelled
Build on Windows / ${{ matrix.arch }} (ucrt-x86_64, x64-ucrt, gcc, UCRT64) (push) Has been cancelled
Build on Windows / ${{ matrix.arch }} (x86_64, x64, gcc, MINGW64) (push) Has been cancelled
Build on Windows / CMake ${{ matrix.arch }} (clang-x86_64, x64-clang, clang, CLANG64) (push) Has been cancelled
Build on Windows / CMake ${{ matrix.arch }} (i686, x86, gcc, MINGW32) (push) Has been cancelled
Build on Windows / CMake ${{ matrix.arch }} (ucrt-x86_64, x64-ucrt, gcc, UCRT64) (push) Has been cancelled
Build on Windows / CMake ${{ matrix.arch }} (x86_64, x64, gcc, MINGW64) (push) Has been cancelled
Build on Windows / XP (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=${{ matrix.with_upnp }} (no) (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=${{ matrix.with_upnp }} (yes) (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=${{ matrix.with_upnp }} (OFF) (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=${{ matrix.with_upnp }} (ON) (push) Has been cancelled
Build containers / Building container for ${{ matrix.platform }} (amd64, linux/amd64) (push) Has been cancelled
Build containers / Building container for ${{ matrix.platform }} (arm64, linux/arm64) (push) Has been cancelled
Build containers / Building container for ${{ matrix.platform }} (armv7, linux/arm/v7) (push) Has been cancelled
Build containers / Building container for ${{ matrix.platform }} (i386, linux/386) (push) Has been cancelled
Build containers / Pushing merged manifest (push) Has been cancelled
This commit is contained in:
parent
fcc70025fd
commit
31ff0ff1cb
|
@ -237,9 +237,8 @@ namespace tunnel
|
||||||
m_Buffer.ClearTunnelDataMsgs ();
|
m_Buffer.ClearTunnelDataMsgs ();
|
||||||
|
|
||||||
// send
|
// send
|
||||||
if (m_CurrentTransport && !m_CurrentTransport->IsEstablished ()) // check if session became invalid since last call
|
auto currentTransport = m_CurrentTransport.lock ();
|
||||||
m_CurrentTransport = nullptr;
|
if (!currentTransport)
|
||||||
if (!m_CurrentTransport)
|
|
||||||
{
|
{
|
||||||
// try to obtain transport from peding reequest or send thought transport is not complete
|
// try to obtain transport from peding reequest or send thought transport is not complete
|
||||||
if (m_PendingTransport.valid ()) // pending request?
|
if (m_PendingTransport.valid ()) // pending request?
|
||||||
|
@ -247,9 +246,14 @@ namespace tunnel
|
||||||
if (m_PendingTransport.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
if (m_PendingTransport.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||||
{
|
{
|
||||||
// pending request complete
|
// pending request complete
|
||||||
m_CurrentTransport = m_PendingTransport.get (); // take tarnsports used in pending request
|
currentTransport = m_PendingTransport.get (); // take tarnsports used in pending request
|
||||||
if (m_CurrentTransport && !m_CurrentTransport->IsEstablished ())
|
if (currentTransport)
|
||||||
m_CurrentTransport = nullptr;
|
{
|
||||||
|
if (currentTransport->IsEstablished ())
|
||||||
|
m_CurrentTransport = currentTransport;
|
||||||
|
else
|
||||||
|
currentTransport = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // still pending
|
else // still pending
|
||||||
{
|
{
|
||||||
|
@ -259,9 +263,9 @@ namespace tunnel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_CurrentTransport) // session is good
|
if (currentTransport) // session is good
|
||||||
// send to session directly
|
// send to session directly
|
||||||
m_CurrentTransport->SendI2NPMessages (newTunnelMsgs);
|
currentTransport->SendI2NPMessages (newTunnelMsgs);
|
||||||
else // no session yet
|
else // no session yet
|
||||||
// send through transports
|
// send through transports
|
||||||
m_PendingTransport = i2p::transport::transports.SendMessages (m_Tunnel.GetNextIdentHash (), std::move (newTunnelMsgs));
|
m_PendingTransport = i2p::transport::transports.SendMessages (m_Tunnel.GetNextIdentHash (), std::move (newTunnelMsgs));
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace tunnel
|
||||||
TunnelBase& m_Tunnel;
|
TunnelBase& m_Tunnel;
|
||||||
TunnelGatewayBuffer m_Buffer;
|
TunnelGatewayBuffer m_Buffer;
|
||||||
size_t m_NumSentBytes;
|
size_t m_NumSentBytes;
|
||||||
std::shared_ptr<i2p::transport::TransportSession> m_CurrentTransport;
|
std::weak_ptr<i2p::transport::TransportSession> m_CurrentTransport;
|
||||||
std::future<std::shared_ptr<i2p::transport::TransportSession> > m_PendingTransport;
|
std::future<std::shared_ptr<i2p::transport::TransportSession> > m_PendingTransport;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue