forked from premiere/premiere-libtorrent
merge RC_1_1 into master
This commit is contained in:
commit
2a999e1ea7
|
@ -121,7 +121,7 @@ namespace
|
|||
int sett = setting_by_name(key);
|
||||
if (sett < 0)
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, ("unknown name in settings_pack: " + key).c_str());
|
||||
PyErr_SetString(PyExc_KeyError, ("unknown name in settings_pack: " + key).c_str());
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ class test_session(unittest.TestCase):
|
|||
try:
|
||||
s = lt.session({'unexpected-key-name': 42})
|
||||
self.assertFalse('should have thrown an exception')
|
||||
except Exception as e:
|
||||
except KeyError as e:
|
||||
print(e)
|
||||
|
||||
def test_apply_settings(self):
|
||||
|
|
|
@ -462,10 +462,6 @@ namespace libtorrent
|
|||
int pinned_blocks() const { return m_pinned_blocks; }
|
||||
int read_cache_size() const { return m_read_cache_size; }
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
void mark_deleted(file_storage const& fs);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
// returns number of bytes read on success, -1 on cache miss
|
||||
|
@ -530,10 +526,6 @@ namespace libtorrent
|
|||
// the number of blocks with a refcount > 0, i.e.
|
||||
// they may not be evicted
|
||||
int m_pinned_blocks;
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
std::vector<std::pair<std::string, void const*>> m_deleted_storages;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ lt::torrent_status get_status(lt::session& ses)
|
|||
{
|
||||
auto handles = ses.get_torrents();
|
||||
TEST_EQUAL(handles.size(), 1);
|
||||
if (handles.empty()) return lt::torrent_status();
|
||||
auto h = handles[0];
|
||||
return h.status();
|
||||
}
|
||||
|
@ -131,6 +132,7 @@ bool has_metadata(lt::session& ses)
|
|||
{
|
||||
auto handles = ses.get_torrents();
|
||||
TEST_EQUAL(handles.size(), 1);
|
||||
if (handles.empty()) return false;
|
||||
auto h = handles[0];
|
||||
return h.status().has_metadata;
|
||||
}
|
||||
|
@ -139,6 +141,7 @@ bool is_seed(lt::session& ses)
|
|||
{
|
||||
auto handles = ses.get_torrents();
|
||||
TEST_EQUAL(handles.size(), 1);
|
||||
if (handles.empty()) return false;
|
||||
auto h = handles[0];
|
||||
return h.status().is_seeding;
|
||||
}
|
||||
|
@ -147,6 +150,7 @@ int completed_pieces(lt::session& ses)
|
|||
{
|
||||
auto handles = ses.get_torrents();
|
||||
TEST_EQUAL(handles.size(), 1);
|
||||
if (handles.empty()) return 0;
|
||||
auto h = handles[0];
|
||||
return h.status().num_pieces;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,10 @@ enum flags_t
|
|||
utp = 8,
|
||||
|
||||
// upload-only mode
|
||||
upload_only = 16
|
||||
upload_only = 16,
|
||||
|
||||
// re-add the torrent after removing
|
||||
readd = 32
|
||||
};
|
||||
|
||||
void run_metadata_test(int flags)
|
||||
|
@ -108,10 +111,21 @@ void run_metadata_test(int flags)
|
|||
{
|
||||
metadata_alerts += 1;
|
||||
|
||||
auto ti = std::make_shared<torrent_info>(
|
||||
*ses.get_torrents()[0].torrent_file());
|
||||
|
||||
if (flags & disconnect)
|
||||
{
|
||||
ses.remove_torrent(ses.get_torrents()[0]);
|
||||
}
|
||||
|
||||
if (flags & readd)
|
||||
{
|
||||
add_torrent_params p = default_add_torrent;
|
||||
p.ti = ti;
|
||||
p.save_path = ".";
|
||||
ses.add_torrent(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
// terminate
|
||||
|
@ -127,6 +141,10 @@ void run_metadata_test(int flags)
|
|||
TEST_ERROR("timeout");
|
||||
return true;
|
||||
}
|
||||
if ((flags & disconnect) && metadata_alerts > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ((flags & upload_only) && has_metadata(ses))
|
||||
{
|
||||
// the other peer is in upload mode and should not have sent any
|
||||
|
@ -167,3 +185,18 @@ TORRENT_TEST(ut_metadata_upload_only)
|
|||
run_metadata_test(upload_only);
|
||||
}
|
||||
|
||||
TORRENT_TEST(ut_metadata_disconnect)
|
||||
{
|
||||
run_metadata_test(disconnect);
|
||||
}
|
||||
|
||||
TORRENT_TEST(ut_metadata_disconnect_readd)
|
||||
{
|
||||
run_metadata_test(disconnect | readd);
|
||||
}
|
||||
|
||||
TORRENT_TEST(ut_metadata_upload_only_disconnect_readd)
|
||||
{
|
||||
run_metadata_test(upload_only | disconnect | readd);
|
||||
}
|
||||
|
||||
|
|
|
@ -357,15 +357,6 @@ int block_cache::try_read(disk_io_job* j, bool expect_no_fail)
|
|||
|
||||
TORRENT_ASSERT(j->buffer.disk_block == nullptr);
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
// we're not allowed to add dirty blocks
|
||||
// for a deleted storage!
|
||||
TORRENT_ASSERT(std::find(m_deleted_storages.begin(), m_deleted_storages.end()
|
||||
, std::make_pair(j->storage->files()->name()
|
||||
, reinterpret_cast<void const*>(j->storage->files())))
|
||||
== m_deleted_storages.end());
|
||||
#endif
|
||||
|
||||
cached_piece_entry* p = find_piece(j);
|
||||
|
||||
int ret = 0;
|
||||
|
@ -714,16 +705,6 @@ cached_piece_entry* block_cache::allocate_piece(disk_io_job const* j, int const
|
|||
return p;
|
||||
}
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
void block_cache::mark_deleted(file_storage const& fs)
|
||||
{
|
||||
m_deleted_storages.push_back(std::make_pair(fs.name()
|
||||
, reinterpret_cast<void const*>(&fs)));
|
||||
if (m_deleted_storages.size() > 100)
|
||||
m_deleted_storages.erase(m_deleted_storages.begin());
|
||||
}
|
||||
#endif
|
||||
|
||||
cached_piece_entry* block_cache::add_dirty_block(disk_io_job* j)
|
||||
{
|
||||
#if !defined TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
|
@ -733,15 +714,6 @@ cached_piece_entry* block_cache::add_dirty_block(disk_io_job* j)
|
|||
INVARIANT_CHECK;
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
// we're not allowed to add dirty blocks
|
||||
// for a deleted storage!
|
||||
TORRENT_ASSERT(std::find(m_deleted_storages.begin(), m_deleted_storages.end()
|
||||
, std::make_pair(j->storage->files()->name()
|
||||
, static_cast<void const*>(j->storage->files())))
|
||||
== m_deleted_storages.end());
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(j->buffer.disk_block);
|
||||
TORRENT_ASSERT(m_write_cache_size + m_read_cache_size + 1 <= in_use());
|
||||
|
||||
|
@ -1297,14 +1269,6 @@ void block_cache::insert_blocks(cached_piece_entry* pe, int block, span<file::io
|
|||
TORRENT_ASSERT(pe->in_use);
|
||||
TORRENT_PIECE_ASSERT(iov.size() > 0, pe);
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
// we're not allowed to add dirty blocks
|
||||
// for a deleted storage!
|
||||
TORRENT_ASSERT(std::find(m_deleted_storages.begin(), m_deleted_storages.end()
|
||||
, std::make_pair(j->storage->files()->name(), static_cast<void const*>(j->storage->files())))
|
||||
== m_deleted_storages.end());
|
||||
#endif
|
||||
|
||||
cache_hit(pe, j->requester, (j->flags & disk_io_job::volatile_read) != 0);
|
||||
|
||||
TORRENT_ASSERT(pe->in_use);
|
||||
|
|
|
@ -2445,9 +2445,6 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(j->storage->num_outstanding_jobs() == 1);
|
||||
|
||||
std::unique_lock<std::mutex> l(m_cache_mutex);
|
||||
#if TORRENT_USE_ASSERTS
|
||||
m_disk_cache.mark_deleted(*j->storage->files());
|
||||
#endif
|
||||
|
||||
flush_cache(j->storage.get(), flush_delete_cache | flush_expect_clear
|
||||
, completed_jobs, l);
|
||||
|
|
Loading…
Reference in New Issue