Browse Source

cleanup acceptor for AcceptOnce

pull/839/head
orignal 8 years ago
parent
commit
1f76dc78d8
  1. 14
      Streaming.cpp
  2. 4
      Streaming.h

14
Streaming.cpp

@ -1091,16 +1091,18 @@ namespace stream
} }
else // we must save old acceptor and set it back else // we must save old acceptor and set it back
{ {
auto oldAcceptor = m_Acceptor; m_Acceptor = std::bind (&StreamingDestination::AcceptOnceAcceptor, this,
m_Acceptor = [acceptor, oldAcceptor, this](std::shared_ptr<Stream> stream) std::placeholders::_1, acceptor, m_Acceptor);
{
acceptor (stream); // m_Acceptor might be set after
m_Acceptor = oldAcceptor; // so we must restore old one before
};
} }
}); });
} }
void StreamingDestination::AcceptOnceAcceptor (std::shared_ptr<Stream> stream, Acceptor acceptor, Acceptor prev)
{
m_Acceptor = prev;
acceptor (stream);
}
void StreamingDestination::HandlePendingIncomingTimer (const boost::system::error_code& ecode) void StreamingDestination::HandlePendingIncomingTimer (const boost::system::error_code& ecode)
{ {
if (ecode != boost::asio::error::operation_aborted) if (ecode != boost::asio::error::operation_aborted)

4
Streaming.h

@ -280,7 +280,9 @@ namespace stream
void DeletePacket (Packet * p) { if (p) m_PacketsPool.Release (p); }; void DeletePacket (Packet * p) { if (p) m_PacketsPool.Release (p); };
private: private:
void AcceptOnceAcceptor (std::shared_ptr<Stream> stream, Acceptor acceptor, Acceptor prev);
void HandleNextPacket (Packet * packet); void HandleNextPacket (Packet * packet);
std::shared_ptr<Stream> CreateNewIncomingStream (); std::shared_ptr<Stream> CreateNewIncomingStream ();
void HandlePendingIncomingTimer (const boost::system::error_code& ecode); void HandlePendingIncomingTimer (const boost::system::error_code& ecode);

Loading…
Cancel
Save