fixed deadlock in piece_manager

This commit is contained in:
Arvid Norberg 2009-12-25 16:02:45 +00:00
parent ef6c143e74
commit ac8f64f5fe
2 changed files with 5 additions and 5 deletions

View File

@ -303,7 +303,7 @@ namespace libtorrent
std::string name() const { return m_info->name(); }
#endif
bool allocate_slots(int num_slots, bool abort_on_disk = false);
bool allocate_slots_impl(int num_slots, mutex::scoped_lock& l, bool abort_on_disk = false);
// updates the ph.h hasher object with the data at the given slot
// and optionally a 'small hash' as well, the hash for

View File

@ -2715,7 +2715,7 @@ ret:
if (m_free_slots.empty())
{
allocate_slots(1);
allocate_slots_impl(1, lock);
TORRENT_ASSERT(!m_free_slots.empty());
}
@ -2736,7 +2736,7 @@ ret:
if (*iter == m_files.num_pieces() - 1 && piece_index != *iter)
{
if (m_free_slots.size() == 1)
allocate_slots(1);
allocate_slots_impl(1, lock);
TORRENT_ASSERT(m_free_slots.size() > 1);
// assumes that all allocated slots
// are put at the end of the free_slots vector
@ -2807,9 +2807,9 @@ ret:
return slot_index;
}
bool piece_manager::allocate_slots(int num_slots, bool abort_on_disk)
bool piece_manager::allocate_slots_impl(int num_slots, mutex::scoped_lock& l
, bool abort_on_disk)
{
mutex::scoped_lock lock(m_mutex);
TORRENT_ASSERT(num_slots > 0);
INVARIANT_CHECK;