From f4a2dda94e9adc36b3078c6f0d2829df93102c37 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 25 Jan 2018 08:49:30 -0500 Subject: [PATCH] try streaming race condition fix --- libi2pd/Streaming.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libi2pd/Streaming.cpp b/libi2pd/Streaming.cpp index 9942d8e2..91acc9d0 100644 --- a/libi2pd/Streaming.cpp +++ b/libi2pd/Streaming.cpp @@ -578,7 +578,9 @@ namespace stream if (m_SentPackets.empty () && m_SendBuffer.IsEmpty ()) // nothing to send { m_Status = eStreamStatusClosed; - SendClose (); + // close could be called from another thread so do SendClose from the destination thread + // this is so m_LocalDestination.NewPacket () does not trigger a race condition + m_Service.post(std::bind(&Stream::SendClose, shared_from_this())); } break; case eStreamStatusClosed: