forked from premiere/premiere-libtorrent
make sure the cork destructor doesn't leak exceptions
This commit is contained in:
parent
0378ae47f4
commit
521587c026
|
@ -680,6 +680,8 @@ namespace aux {
|
|||
|
||||
std::shared_ptr<peer_connection> self()
|
||||
{
|
||||
TORRENT_ASSERT(!m_destructed);
|
||||
TORRENT_ASSERT(m_in_use == 1337);
|
||||
TORRENT_ASSERT(!m_in_constructor);
|
||||
return shared_from_this();
|
||||
}
|
||||
|
@ -1202,9 +1204,22 @@ namespace aux {
|
|||
~cork()
|
||||
{
|
||||
if (!m_need_uncork) return;
|
||||
try {
|
||||
m_pc.m_channel_state[peer_connection::upload_channel] &= ~peer_info::bw_network;
|
||||
m_pc.setup_send();
|
||||
}
|
||||
catch (std::bad_alloc const&) {
|
||||
m_pc.disconnect(make_error_code(boost::system::errc::not_enough_memory)
|
||||
, operation_t::sock_write);
|
||||
}
|
||||
catch (boost::system::system_error const& err) {
|
||||
m_pc.disconnect(err.code(), operation_t::sock_write);
|
||||
}
|
||||
catch (...) {
|
||||
m_pc.disconnect(make_error_code(boost::system::errc::not_enough_memory)
|
||||
, operation_t::sock_write);
|
||||
}
|
||||
}
|
||||
private:
|
||||
peer_connection& m_pc;
|
||||
bool m_need_uncork = false;
|
||||
|
|
|
@ -4104,7 +4104,7 @@ namespace libtorrent {
|
|||
torrent_peer* self_peer = peer_info_struct();
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (should_log(peer_log_alert::info))
|
||||
if (should_log(peer_log_alert::info)) try
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
|
@ -4130,6 +4130,11 @@ namespace libtorrent {
|
|||
peer_log(peer_log_alert::info, "SHORT_LIVED_DISCONNECT", "");
|
||||
}
|
||||
}
|
||||
catch (std::exception const& err)
|
||||
{
|
||||
peer_log(peer_log_alert::info, "PEER_ERROR" ,"op: %d error: unknown error (failed with exception) %s"
|
||||
, static_cast<int>(op), err.what());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(m_channel_state[upload_channel] & peer_info::bw_network))
|
||||
|
|
Loading…
Reference in New Issue