From 6de02f9895cb5169d242fc686b37ad191a4cd092 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 22 Sep 2009 04:01:01 +0000 Subject: [PATCH] fixed deadlock in natpmp implementation --- ChangeLog | 4 ++++ include/libtorrent/natpmp.hpp | 1 + src/natpmp.cpp | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6ee3a45b8..5dbeacfa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -72,6 +72,10 @@ * improved support for sparse files on windows * added ability to give seeding torrents preference to active slots +release 0.14.7 + + * fixed deadlock in natpmp + release 0.14.6 * various missing include fixes to be buildable with boost 1.40 diff --git a/include/libtorrent/natpmp.hpp b/include/libtorrent/natpmp.hpp index c568ae552..8c4ca5758 100644 --- a/include/libtorrent/natpmp.hpp +++ b/include/libtorrent/natpmp.hpp @@ -80,6 +80,7 @@ private: void try_next_mapping(int i, mutex_t::scoped_lock& l); void update_expiration_timer(); void mapping_expired(error_code const& e, int i); + void close_impl(mutex_t::scoped_lock& l); void log(char const* msg, mutex_t::scoped_lock& l); void disable(error_code const& ec, mutex_t::scoped_lock& l); diff --git a/src/natpmp.cpp b/src/natpmp.cpp index d5f79d229..ac50c4ac4 100644 --- a/src/natpmp.cpp +++ b/src/natpmp.cpp @@ -154,7 +154,7 @@ void natpmp::disable(error_code const& ec, mutex_t::scoped_lock& l) m_callback(index, 0, ec); l.lock(); } - close(); + close_impl(l); } void natpmp::delete_mapping(int index) @@ -550,6 +550,11 @@ void natpmp::mapping_expired(error_code const& e, int i) void natpmp::close() { mutex_t::scoped_lock l(m_mutex); + close_impl(l); +} + +void natpmp::close_impl(mutex_t::scoped_lock& l) +{ m_abort = true; log("closing", l); /*