fixed assert in udp_socket
This commit is contained in:
parent
c6f4879e06
commit
4724051841
|
@ -121,6 +121,7 @@ namespace libtorrent
|
|||
bool m_abort;
|
||||
udp::endpoint m_proxy_addr;
|
||||
#ifdef TORRENT_DEBUG
|
||||
bool m_started;
|
||||
int m_magic;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -62,6 +62,7 @@ udp_socket::udp_socket(asio::io_service& ios, udp_socket::callback_t const& c
|
|||
{
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_magic = 0x1337;
|
||||
m_started = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -69,7 +70,7 @@ udp_socket::~udp_socket()
|
|||
{
|
||||
#ifdef TORRENT_DEBUG
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
TORRENT_ASSERT(!m_callback);
|
||||
TORRENT_ASSERT(!m_callback || !m_started);
|
||||
TORRENT_ASSERT(m_outstanding == 0);
|
||||
m_magic = 0;
|
||||
#endif
|
||||
|
@ -188,6 +189,9 @@ void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_
|
|||
#endif
|
||||
|
||||
++m_outstanding;
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_started = true;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -251,6 +255,9 @@ void udp_socket::on_read(udp::socket* s, error_code const& e, std::size_t bytes_
|
|||
}
|
||||
#endif
|
||||
++m_outstanding;
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_started = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void udp_socket::wrap(udp::endpoint const& ep, char const* p, int len, error_code& ec)
|
||||
|
@ -379,6 +386,9 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec)
|
|||
}
|
||||
#endif
|
||||
++m_outstanding;
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_started = true;
|
||||
#endif
|
||||
m_bind_port = ep.port();
|
||||
}
|
||||
|
||||
|
@ -401,6 +411,9 @@ void udp_socket::bind(int port)
|
|||
m_ipv4_sock.async_receive_from(asio::buffer(m_v4_buf, sizeof(m_v4_buf))
|
||||
, m_v4_ep, boost::bind(&udp_socket::on_read, this, &m_ipv4_sock, _1, _2));
|
||||
++m_outstanding;
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_started = true;
|
||||
#endif
|
||||
}
|
||||
#if TORRENT_USE_IPV6
|
||||
m_ipv6_sock.open(udp::v6(), ec);
|
||||
|
@ -411,6 +424,9 @@ void udp_socket::bind(int port)
|
|||
m_ipv6_sock.async_receive_from(asio::buffer(m_v6_buf, sizeof(m_v6_buf))
|
||||
, m_v6_ep, boost::bind(&udp_socket::on_read, this, &m_ipv6_sock, _1, _2));
|
||||
++m_outstanding;
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_started = true;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
m_bind_port = port;
|
||||
|
|
Loading…
Reference in New Issue