forked from premiere/premiere-libtorrent
fix race condition in destroyed uTP socket that was waiting for the underlying udp socket to become writable
This commit is contained in:
parent
6d730924b2
commit
e23e417ef9
|
@ -1120,8 +1120,13 @@ bool utp_socket_impl::should_delete() const
|
||||||
// closing the socket. Only delete the state if we're not
|
// closing the socket. Only delete the state if we're not
|
||||||
// attached and we're in a state where the other end doesn't
|
// attached and we're in a state where the other end doesn't
|
||||||
// expect the socket to still be alive
|
// expect the socket to still be alive
|
||||||
|
// when m_stalled is true, it means the socket manager has a
|
||||||
|
// pointer to this socket, waiting for the UDP socket to
|
||||||
|
// become writable again. We have to wait for that, so that
|
||||||
|
// the pointer is removed from that queue. Otherwise we would
|
||||||
|
// leave a dangling pointer in the socket manager
|
||||||
bool ret = (m_state >= UTP_STATE_ERROR_WAIT || m_state == UTP_STATE_NONE)
|
bool ret = (m_state >= UTP_STATE_ERROR_WAIT || m_state == UTP_STATE_NONE)
|
||||||
&& !m_attached;
|
&& !m_attached && !m_stalled;
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
|
@ -1301,6 +1306,8 @@ void utp_socket_impl::writable()
|
||||||
#if TORRENT_UTP_LOG
|
#if TORRENT_UTP_LOG
|
||||||
UTP_LOGV("%8p: writable\n", this);
|
UTP_LOGV("%8p: writable\n", this);
|
||||||
#endif
|
#endif
|
||||||
|
if (should_delete()) return;
|
||||||
|
|
||||||
while(send_pkt());
|
while(send_pkt());
|
||||||
|
|
||||||
maybe_trigger_send_callback(time_now_hires());
|
maybe_trigger_send_callback(time_now_hires());
|
||||||
|
|
Loading…
Reference in New Issue