lt sync 2397
This commit is contained in:
parent
45dd1e37c3
commit
fe7dead2df
|
@ -271,4 +271,8 @@ void bind_alert()
|
||||||
)
|
)
|
||||||
.def_readonly("name", &file_renamed_alert::name)
|
.def_readonly("name", &file_renamed_alert::name)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
class_<torrent_resumed_alert, bases<torrent_alert>, noncopyable>(
|
||||||
|
"torrent_resumed_alert", no_init
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,8 +236,8 @@ void bind_session()
|
||||||
|
|
||||||
enum_<storage_mode_t>("storage_mode_t")
|
enum_<storage_mode_t>("storage_mode_t")
|
||||||
.value("storage_mode_allocate", storage_mode_allocate)
|
.value("storage_mode_allocate", storage_mode_allocate)
|
||||||
.value("storage_mode_compact", storage_mode_compact)
|
|
||||||
.value("storage_mode_sparse", storage_mode_sparse)
|
.value("storage_mode_sparse", storage_mode_sparse)
|
||||||
|
.value("storage_mode_compact", storage_mode_compact)
|
||||||
;
|
;
|
||||||
|
|
||||||
enum_<session::options_t>("options_t")
|
enum_<session::options_t>("options_t")
|
||||||
|
|
|
@ -34,6 +34,13 @@ void bind_session_settings()
|
||||||
.def_readwrite("lazy_bitfields", &session_settings::lazy_bitfields)
|
.def_readwrite("lazy_bitfields", &session_settings::lazy_bitfields)
|
||||||
.def_readwrite("inactivity_timeout", &session_settings::inactivity_timeout)
|
.def_readwrite("inactivity_timeout", &session_settings::inactivity_timeout)
|
||||||
.def_readwrite("unchoke_interval", &session_settings::unchoke_interval)
|
.def_readwrite("unchoke_interval", &session_settings::unchoke_interval)
|
||||||
|
.def_readwrite("active_downloads", &session_settings::active_downloads)
|
||||||
|
.def_readwrite("active_seeds", &session_settings::active_seeds)
|
||||||
|
.def_readwrite("auto_manage_interval", &session_settings::auto_manage_interval)
|
||||||
|
.def_readwrite("share_ratio_limit", &session_settings::share_ratio_limit)
|
||||||
|
.def_readwrite("seed_time_ratio_limit", &session_settings::seed_time_ratio_limit)
|
||||||
|
.def_readwrite("seed_time_limit", &session_settings::seed_time_limit)
|
||||||
|
.def_readwrite("auto_scraped_interval", &session_settings::auto_scrape_interval)
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
.def_readwrite("use_dht_as_fallback", &session_settings::use_dht_as_fallback)
|
.def_readwrite("use_dht_as_fallback", &session_settings::use_dht_as_fallback)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -544,6 +544,15 @@ namespace libtorrent
|
||||||
{ return std::auto_ptr<alert>(new peer_blocked_alert(*this)); }
|
{ return std::auto_ptr<alert>(new peer_blocked_alert(*this)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TORRENT_EXPORT torrent_resumed_alert: torrent_alert
|
||||||
|
{
|
||||||
|
torrent_resumed_alert(torrent_handle const& h, std::string const& msg)
|
||||||
|
: torrent_alert(h, alert::warning, msg)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual std::auto_ptr<alert> clone() const
|
||||||
|
{ return std::auto_ptr<alert>(new torrent_resumed_alert(*this)); }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ namespace libtorrent
|
||||||
, check_files
|
, check_files
|
||||||
, save_resume_data
|
, save_resume_data
|
||||||
, rename_file
|
, rename_file
|
||||||
|
, abort_thread
|
||||||
};
|
};
|
||||||
|
|
||||||
action_t action;
|
action_t action;
|
||||||
|
@ -206,6 +207,12 @@ namespace libtorrent
|
||||||
int num_blocks;
|
int num_blocks;
|
||||||
// the pointers to the block data
|
// the pointers to the block data
|
||||||
boost::shared_array<char*> blocks;
|
boost::shared_array<char*> blocks;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
~cached_piece_entry()
|
||||||
|
{
|
||||||
|
TORRENT_ASSERT(storage == 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef boost::recursive_mutex mutex_t;
|
typedef boost::recursive_mutex mutex_t;
|
||||||
|
|
|
@ -129,7 +129,7 @@ namespace libtorrent
|
||||||
, resume_data(0)
|
, resume_data(0)
|
||||||
, storage_mode(storage_mode_sparse)
|
, storage_mode(storage_mode_sparse)
|
||||||
, paused(true)
|
, paused(true)
|
||||||
, auto_managed(true)
|
, auto_managed(false)
|
||||||
, duplicate_is_error(false)
|
, duplicate_is_error(false)
|
||||||
, storage(sc)
|
, storage(sc)
|
||||||
, userdata(0)
|
, userdata(0)
|
||||||
|
|
|
@ -252,6 +252,7 @@ namespace libtorrent
|
||||||
no_error = 0,
|
no_error = 0,
|
||||||
need_full_check = -1,
|
need_full_check = -1,
|
||||||
fatal_disk_error = -2,
|
fatal_disk_error = -2,
|
||||||
|
disk_check_aborted = -3
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -79,7 +79,9 @@ namespace libtorrent
|
||||||
void disk_io_thread::join()
|
void disk_io_thread::join()
|
||||||
{
|
{
|
||||||
mutex_t::scoped_lock l(m_mutex);
|
mutex_t::scoped_lock l(m_mutex);
|
||||||
m_abort = true;
|
disk_io_job j;
|
||||||
|
j.action = disk_io_job::abort_thread;
|
||||||
|
m_jobs.insert(m_jobs.begin(), j);
|
||||||
m_signal.notify_all();
|
m_signal.notify_all();
|
||||||
l.unlock();
|
l.unlock();
|
||||||
|
|
||||||
|
@ -146,6 +148,13 @@ namespace libtorrent
|
||||||
m_jobs.erase(i++);
|
m_jobs.erase(i++);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (i->action == disk_io_job::check_files)
|
||||||
|
{
|
||||||
|
if (i->callback) m_ios.post(bind(i->callback
|
||||||
|
, piece_manager::disk_check_aborted, *i));
|
||||||
|
m_jobs.erase(i++);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
m_signal.notify_all();
|
m_signal.notify_all();
|
||||||
|
@ -223,6 +232,9 @@ namespace libtorrent
|
||||||
--m_cache_stats.cache_size;
|
--m_cache_stats.cache_size;
|
||||||
--m_cache_stats.read_cache_size;
|
--m_cache_stats.read_cache_size;
|
||||||
}
|
}
|
||||||
|
l.unlock();
|
||||||
|
p.storage = 0;
|
||||||
|
l.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool disk_io_thread::clear_oldest_read_piece(
|
bool disk_io_thread::clear_oldest_read_piece(
|
||||||
|
@ -331,6 +343,9 @@ namespace libtorrent
|
||||||
for (int i = 0; i < blocks_in_piece; ++i)
|
for (int i = 0; i < blocks_in_piece; ++i)
|
||||||
TORRENT_ASSERT(p.blocks[i] == 0);
|
TORRENT_ASSERT(p.blocks[i] == 0);
|
||||||
#endif
|
#endif
|
||||||
|
l.unlock();
|
||||||
|
p.storage = 0;
|
||||||
|
l.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void disk_io_thread::cache_block(disk_io_job& j, mutex_t::scoped_lock& l)
|
void disk_io_thread::cache_block(disk_io_job& j, mutex_t::scoped_lock& l)
|
||||||
|
@ -353,6 +368,9 @@ namespace libtorrent
|
||||||
p.blocks[block] = j.buffer;
|
p.blocks[block] = j.buffer;
|
||||||
++m_cache_stats.cache_size;
|
++m_cache_stats.cache_size;
|
||||||
m_pieces.push_back(p);
|
m_pieces.push_back(p);
|
||||||
|
#ifndef NDEBUG
|
||||||
|
p.storage = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// fills a piece with data from disk, returns the total number of bytes
|
// fills a piece with data from disk, returns the total number of bytes
|
||||||
|
@ -466,6 +484,9 @@ namespace libtorrent
|
||||||
else
|
else
|
||||||
m_read_pieces.push_back(p);
|
m_read_pieces.push_back(p);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
p.storage = 0;
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,6 +500,7 @@ namespace libtorrent
|
||||||
cached_piece_entry const& p = *i;
|
cached_piece_entry const& p = *i;
|
||||||
TORRENT_ASSERT(p.blocks);
|
TORRENT_ASSERT(p.blocks);
|
||||||
|
|
||||||
|
if (!p.storage) continue;
|
||||||
int piece_size = p.storage->info()->piece_size(p.piece);
|
int piece_size = p.storage->info()->piece_size(p.piece);
|
||||||
int blocks_in_piece = (piece_size + m_block_size - 1) / m_block_size;
|
int blocks_in_piece = (piece_size + m_block_size - 1) / m_block_size;
|
||||||
int blocks = 0;
|
int blocks = 0;
|
||||||
|
@ -727,7 +749,21 @@ namespace libtorrent
|
||||||
|
|
||||||
while (m_jobs.empty() && !m_abort)
|
while (m_jobs.empty() && !m_abort)
|
||||||
m_signal.wait(l);
|
m_signal.wait(l);
|
||||||
if (m_abort && m_jobs.empty()) return;
|
if (m_abort && m_jobs.empty())
|
||||||
|
{
|
||||||
|
// flush all disk caches
|
||||||
|
for (cache_t::iterator i = m_pieces.begin()
|
||||||
|
, end(m_pieces.end()); i != end; ++i)
|
||||||
|
flush(i, l);
|
||||||
|
for (cache_t::iterator i = m_read_pieces.begin()
|
||||||
|
, end(m_read_pieces.end()); i != end; ++i)
|
||||||
|
free_piece(*i, l);
|
||||||
|
l.unlock();
|
||||||
|
m_pieces.clear();
|
||||||
|
m_read_pieces.clear();
|
||||||
|
l.lock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if there's a buffer in this job, it will be freed
|
// if there's a buffer in this job, it will be freed
|
||||||
// when this holder is destructed, unless it has been
|
// when this holder is destructed, unless it has been
|
||||||
|
@ -741,6 +777,32 @@ namespace libtorrent
|
||||||
|
|
||||||
disk_io_job j = m_jobs.front();
|
disk_io_job j = m_jobs.front();
|
||||||
m_jobs.pop_front();
|
m_jobs.pop_front();
|
||||||
|
|
||||||
|
if (j.action == disk_io_job::abort_thread)
|
||||||
|
{
|
||||||
|
m_abort = true;
|
||||||
|
|
||||||
|
for (std::list<disk_io_job>::iterator i = m_jobs.begin();
|
||||||
|
i != m_jobs.end();)
|
||||||
|
{
|
||||||
|
if (i->action == disk_io_job::read)
|
||||||
|
{
|
||||||
|
if (i->callback) m_ios.post(bind(i->callback, -1, *i));
|
||||||
|
m_jobs.erase(i++);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i->action == disk_io_job::check_files)
|
||||||
|
{
|
||||||
|
if (i->callback) m_ios.post(bind(i->callback
|
||||||
|
, piece_manager::disk_check_aborted, *i));
|
||||||
|
m_jobs.erase(i++);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
m_queue_buffer_size -= j.buffer_size;
|
m_queue_buffer_size -= j.buffer_size;
|
||||||
|
|
||||||
flush_expired_pieces(l);
|
flush_expired_pieces(l);
|
||||||
|
|
|
@ -675,6 +675,12 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||||
|
|
||||||
|
if (ret == piece_manager::disk_check_aborted)
|
||||||
|
{
|
||||||
|
m_error = "aborted";
|
||||||
|
m_ses.done_checking(shared_from_this());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ret == piece_manager::fatal_disk_error)
|
if (ret == piece_manager::fatal_disk_error)
|
||||||
{
|
{
|
||||||
if (m_ses.m_alerts.should_post(alert::fatal))
|
if (m_ses.m_alerts.should_post(alert::fatal))
|
||||||
|
@ -3049,6 +3055,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
TORRENT_ASSERT(!is_finished());
|
||||||
m_state = torrent_status::downloading;
|
m_state = torrent_status::downloading;
|
||||||
set_queue_position((std::numeric_limits<int>::max)());
|
set_queue_position((std::numeric_limits<int>::max)());
|
||||||
}
|
}
|
||||||
|
@ -3385,6 +3392,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void torrent::set_queue_position(int p)
|
void torrent::set_queue_position(int p)
|
||||||
{
|
{
|
||||||
|
if (is_finished() && p != -1) return;
|
||||||
if (p == m_sequence_number) return;
|
if (p == m_sequence_number) return;
|
||||||
|
|
||||||
session_impl::torrent_map& torrents = m_ses.m_torrents;
|
session_impl::torrent_map& torrents = m_ses.m_torrents;
|
||||||
|
@ -3686,6 +3694,11 @@ namespace libtorrent
|
||||||
m_started = time_now();
|
m_started = time_now();
|
||||||
m_error.clear();
|
m_error.clear();
|
||||||
|
|
||||||
|
if (alerts().should_post(alert::warning))
|
||||||
|
{
|
||||||
|
alerts().post_alert(torrent_resumed_alert(get_handle(), "torrent resumed"));
|
||||||
|
}
|
||||||
|
|
||||||
// tell the tracker that we're back
|
// tell the tracker that we're back
|
||||||
m_event = tracker_request::started;
|
m_event = tracker_request::started;
|
||||||
force_tracker_request();
|
force_tracker_request();
|
||||||
|
|
Loading…
Reference in New Issue