fix: webseed assertion failures (#2735)

This commit is contained in:
Charles Kerr 2022-03-04 12:00:42 -08:00 committed by GitHub
parent 377c335d0f
commit 0cd3eb26ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -706,6 +706,8 @@ static void torrentInit(tr_torrent* tor, tr_ctor const* ctor)
tor->labels = tr_ctorGetLabels(ctor);
tor->uniqueId = session->torrents().add(tor);
tr_peerMgrAddTorrent(session->peerMgr, tor);
TR_ASSERT(tor->downloadedCur == 0);
@ -760,8 +762,6 @@ static void torrentInit(tr_torrent* tor, tr_ctor const* ctor)
tr_torrentSetIdleLimit(tor, tr_sessionGetIdleLimit(tor->session));
}
tor->uniqueId = session->torrents().add(tor);
// if we don't have a local .torrent or .magnet file already, assume the torrent is new
auto const filename = tor->hasMetadata() ? tor->torrentFile() : tor->magnetFile();

View File

@ -54,7 +54,7 @@ tr_torrents::tr_torrents()
tr_torrent const* tr_torrents::get(int id) const
{
TR_ASSERT(0 <= id);
TR_ASSERT(0 < id);
TR_ASSERT(static_cast<size_t>(id) < std::size(by_id_));
if (static_cast<size_t>(id) >= std::size(by_id_))
{
@ -69,7 +69,7 @@ tr_torrent const* tr_torrents::get(int id) const
tr_torrent* tr_torrents::get(int id)
{
TR_ASSERT(0 <= id);
TR_ASSERT(0 < id);
TR_ASSERT(static_cast<size_t>(id) < std::size(by_id_));
if (static_cast<size_t>(id) >= std::size(by_id_))
{

View File

@ -455,7 +455,7 @@ void onPartialDataFetched(tr_web::FetchResponse const& web_response)
return;
}
TR_ASSERT(evbuffer_get_length(task->content()) == 0);
TR_ASSERT(evbuffer_get_length(task->content()) < tr_block_info::BlockSize);
webseed->tasks.erase(task);
delete task;