diff --git a/src/upnp.cpp b/src/upnp.cpp index 40d7482d2..39478fc89 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -247,6 +247,8 @@ void upnp::resend_request(error_code const& e) { if (e) return; + boost::intrusive_ptr me(self()); + mutex_t::scoped_lock l(m_mutex); if (m_closing) return; @@ -303,6 +305,8 @@ void upnp::resend_request(error_code const& e) void upnp::on_reply(udp::endpoint const& from, char* buffer , std::size_t bytes_transferred) { + boost::intrusive_ptr me(self()); + mutex_t::scoped_lock l(m_mutex); using namespace libtorrent::detail; @@ -653,6 +657,8 @@ void upnp::update_map(rootdevice& d, int i, mutex_t::scoped_lock& l) if (d.upnp_connection) return; + boost::intrusive_ptr me(self()); + mapping_t& m = d.mapping[i]; if (m.action == mapping_t::action_none @@ -825,6 +831,8 @@ void upnp::on_upnp_xml(error_code const& e , libtorrent::http_parser const& p, rootdevice& d , http_connection& c) { + boost::intrusive_ptr me(self()); + mutex_t::scoped_lock l(m_mutex); TORRENT_ASSERT(d.magic == 1337); @@ -1056,6 +1064,8 @@ void upnp::on_upnp_map_response(error_code const& e , libtorrent::http_parser const& p, rootdevice& d, int mapping , http_connection& c) { + boost::intrusive_ptr me(self()); + mutex_t::scoped_lock l(m_mutex); TORRENT_ASSERT(d.magic == 1337); @@ -1212,6 +1222,8 @@ void upnp::on_upnp_unmap_response(error_code const& e , libtorrent::http_parser const& p, rootdevice& d, int mapping , http_connection& c) { + boost::intrusive_ptr me(self()); + mutex_t::scoped_lock l(m_mutex); TORRENT_ASSERT(d.magic == 1337);