*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-09-07 23:16:11 +00:00
parent c609faa879
commit 29cb9e8969
10 changed files with 124 additions and 75 deletions

View File

@ -53,66 +53,67 @@
<li><a class="reference" href="#set-ratio" id="id46" name="id46">set_ratio()</a></li>
<li><a class="reference" href="#set-upload-limit-set-download-limit" id="id47" name="id47">set_upload_limit() set_download_limit()</a></li>
<li><a class="reference" href="#pause-resume-is-paused" id="id48" name="id48">pause() resume() is_paused()</a></li>
<li><a class="reference" href="#set-tracker-login" id="id49" name="id49">set_tracker_login()</a></li>
<li><a class="reference" href="#use-interface" id="id50" name="id50">use_interface()</a></li>
<li><a class="reference" href="#info-hash" id="id51" name="id51">info_hash()</a></li>
<li><a class="reference" href="#set-max-uploads-set-max-connections" id="id52" name="id52">set_max_uploads() set_max_connections()</a></li>
<li><a class="reference" href="#write-resume-data" id="id53" name="id53">write_resume_data()</a></li>
<li><a class="reference" href="#id11" id="id54" name="id54">status()</a></li>
<li><a class="reference" href="#get-download-queue" id="id55" name="id55">get_download_queue()</a></li>
<li><a class="reference" href="#get-peer-info" id="id56" name="id56">get_peer_info()</a></li>
<li><a class="reference" href="#get-torrent-info" id="id57" name="id57">get_torrent_info()</a></li>
<li><a class="reference" href="#is-valid" id="id58" name="id58">is_valid()</a></li>
<li><a class="reference" href="#is-seed" id="id49" name="id49">is_seed()</a></li>
<li><a class="reference" href="#set-tracker-login" id="id50" name="id50">set_tracker_login()</a></li>
<li><a class="reference" href="#use-interface" id="id51" name="id51">use_interface()</a></li>
<li><a class="reference" href="#info-hash" id="id52" name="id52">info_hash()</a></li>
<li><a class="reference" href="#set-max-uploads-set-max-connections" id="id53" name="id53">set_max_uploads() set_max_connections()</a></li>
<li><a class="reference" href="#write-resume-data" id="id54" name="id54">write_resume_data()</a></li>
<li><a class="reference" href="#id11" id="id55" name="id55">status()</a></li>
<li><a class="reference" href="#get-download-queue" id="id56" name="id56">get_download_queue()</a></li>
<li><a class="reference" href="#get-peer-info" id="id57" name="id57">get_peer_info()</a></li>
<li><a class="reference" href="#get-torrent-info" id="id58" name="id58">get_torrent_info()</a></li>
<li><a class="reference" href="#is-valid" id="id59" name="id59">is_valid()</a></li>
</ul>
</li>
<li><a class="reference" href="#torrent-status" id="id59" name="id59">torrent_status</a></li>
<li><a class="reference" href="#peer-info" id="id60" name="id60">peer_info</a></li>
<li><a class="reference" href="#address" id="id61" name="id61">address</a></li>
<li><a class="reference" href="#http-settings" id="id62" name="id62">http_settings</a></li>
<li><a class="reference" href="#big-number" id="id63" name="id63">big_number</a></li>
<li><a class="reference" href="#hasher" id="id64" name="id64">hasher</a></li>
<li><a class="reference" href="#fingerprint" id="id65" name="id65">fingerprint</a></li>
<li><a class="reference" href="#free-functions" id="id66" name="id66">free functions</a><ul>
<li><a class="reference" href="#identify-client" id="id67" name="id67">identify_client()</a></li>
<li><a class="reference" href="#bdecode-bencode" id="id68" name="id68">bdecode() bencode()</a></li>
<li><a class="reference" href="#torrent-status" id="id60" name="id60">torrent_status</a></li>
<li><a class="reference" href="#peer-info" id="id61" name="id61">peer_info</a></li>
<li><a class="reference" href="#address" id="id62" name="id62">address</a></li>
<li><a class="reference" href="#http-settings" id="id63" name="id63">http_settings</a></li>
<li><a class="reference" href="#big-number" id="id64" name="id64">big_number</a></li>
<li><a class="reference" href="#hasher" id="id65" name="id65">hasher</a></li>
<li><a class="reference" href="#fingerprint" id="id66" name="id66">fingerprint</a></li>
<li><a class="reference" href="#free-functions" id="id67" name="id67">free functions</a><ul>
<li><a class="reference" href="#identify-client" id="id68" name="id68">identify_client()</a></li>
<li><a class="reference" href="#bdecode-bencode" id="id69" name="id69">bdecode() bencode()</a></li>
</ul>
</li>
<li><a class="reference" href="#alerts" id="id69" name="id69">alerts</a><ul>
<li><a class="reference" href="#listen-failed-alert" id="id70" name="id70">listen_failed_alert</a></li>
<li><a class="reference" href="#file-error-alert" id="id71" name="id71">file_error_alert</a></li>
<li><a class="reference" href="#tracker-alert" id="id72" name="id72">tracker_alert</a></li>
<li><a class="reference" href="#hash-failed-alert" id="id73" name="id73">hash_failed_alert</a></li>
<li><a class="reference" href="#peer-ban-alert" id="id74" name="id74">peer_ban_alert</a></li>
<li><a class="reference" href="#peer-error-alert" id="id75" name="id75">peer_error_alert</a></li>
<li><a class="reference" href="#invalid-request-alert" id="id76" name="id76">invalid_request_alert</a></li>
<li><a class="reference" href="#torrent-finished-alert" id="id77" name="id77">torrent_finished_alert</a></li>
<li><a class="reference" href="#dispatcher" id="id78" name="id78">dispatcher</a></li>
<li><a class="reference" href="#alerts" id="id70" name="id70">alerts</a><ul>
<li><a class="reference" href="#listen-failed-alert" id="id71" name="id71">listen_failed_alert</a></li>
<li><a class="reference" href="#file-error-alert" id="id72" name="id72">file_error_alert</a></li>
<li><a class="reference" href="#tracker-alert" id="id73" name="id73">tracker_alert</a></li>
<li><a class="reference" href="#hash-failed-alert" id="id74" name="id74">hash_failed_alert</a></li>
<li><a class="reference" href="#peer-ban-alert" id="id75" name="id75">peer_ban_alert</a></li>
<li><a class="reference" href="#peer-error-alert" id="id76" name="id76">peer_error_alert</a></li>
<li><a class="reference" href="#invalid-request-alert" id="id77" name="id77">invalid_request_alert</a></li>
<li><a class="reference" href="#torrent-finished-alert" id="id78" name="id78">torrent_finished_alert</a></li>
<li><a class="reference" href="#dispatcher" id="id79" name="id79">dispatcher</a></li>
</ul>
</li>
<li><a class="reference" href="#exceptions" id="id79" name="id79">exceptions</a><ul>
<li><a class="reference" href="#invalid-handle" id="id80" name="id80">invalid_handle</a></li>
<li><a class="reference" href="#duplicate-torrent" id="id81" name="id81">duplicate_torrent</a></li>
<li><a class="reference" href="#invalid-encoding" id="id82" name="id82">invalid_encoding</a></li>
<li><a class="reference" href="#type-error" id="id83" name="id83">type_error</a></li>
<li><a class="reference" href="#invalid-torrent-file" id="id84" name="id84">invalid_torrent_file</a></li>
<li><a class="reference" href="#exceptions" id="id80" name="id80">exceptions</a><ul>
<li><a class="reference" href="#invalid-handle" id="id81" name="id81">invalid_handle</a></li>
<li><a class="reference" href="#duplicate-torrent" id="id82" name="id82">duplicate_torrent</a></li>
<li><a class="reference" href="#invalid-encoding" id="id83" name="id83">invalid_encoding</a></li>
<li><a class="reference" href="#type-error" id="id84" name="id84">type_error</a></li>
<li><a class="reference" href="#invalid-torrent-file" id="id85" name="id85">invalid_torrent_file</a></li>
</ul>
</li>
<li><a class="reference" href="#examples" id="id85" name="id85">examples</a><ul>
<li><a class="reference" href="#dump-torrent" id="id86" name="id86">dump_torrent</a></li>
<li><a class="reference" href="#simple-client" id="id87" name="id87">simple client</a></li>
<li><a class="reference" href="#examples" id="id86" name="id86">examples</a><ul>
<li><a class="reference" href="#dump-torrent" id="id87" name="id87">dump_torrent</a></li>
<li><a class="reference" href="#simple-client" id="id88" name="id88">simple client</a></li>
</ul>
</li>
<li><a class="reference" href="#fast-resume" id="id88" name="id88">fast resume</a><ul>
<li><a class="reference" href="#file-format" id="id89" name="id89">file format</a></li>
<li><a class="reference" href="#fast-resume" id="id89" name="id89">fast resume</a><ul>
<li><a class="reference" href="#file-format" id="id90" name="id90">file format</a></li>
</ul>
</li>
<li><a class="reference" href="#extensions" id="id90" name="id90">extensions</a><ul>
<li><a class="reference" href="#chat-messages" id="id91" name="id91">chat messages</a></li>
<li><a class="reference" href="#metadata-from-peers" id="id92" name="id92">metadata from peers</a></li>
<li><a class="reference" href="#extensions" id="id91" name="id91">extensions</a><ul>
<li><a class="reference" href="#chat-messages" id="id92" name="id92">chat messages</a></li>
<li><a class="reference" href="#metadata-from-peers" id="id93" name="id93">metadata from peers</a></li>
</ul>
</li>
<li><a class="reference" href="#filename-checks" id="id93" name="id93">filename checks</a></li>
<li><a class="reference" href="#aknowledgements" id="id94" name="id94">aknowledgements</a></li>
<li><a class="reference" href="#filename-checks" id="id94" name="id94">filename checks</a></li>
<li><a class="reference" href="#aknowledgements" id="id95" name="id95">aknowledgements</a></li>
</ul>
</div>
<div class="section" id="introduction">
@ -819,6 +820,7 @@ struct torrent_handle
void pause();
void resume();
bool is_paused() const;
bool is_seed() const;
boost::filsystem::path save_path() const;
bool move_storage(boost::filesystem::path const&amp; save_path);
@ -925,6 +927,15 @@ all potential (not connected) peers. You can use <tt class="literal"><span class
is currently paused. Torrents may be paused automatically if there is a file error (eg. disk full)
or something similar. See <a class="reference" href="#file-error-alert">file_error_alert</a>.</p>
</div>
<div class="section" id="is-seed">
<h2><a name="is-seed">is_seed()</a></h2>
<blockquote>
<pre class="literal-block">
bool is_seed() const;
</pre>
</blockquote>
<p>Returns true if the torrent is in seed mode (i.e. if it has finished downloading).</p>
</div>
<div class="section" id="set-tracker-login">
<h2><a name="set-tracker-login">set_tracker_login()</a></h2>
<blockquote>

View File

@ -765,6 +765,7 @@ Its declaration looks like this::
void pause();
void resume();
bool is_paused() const;
bool is_seed() const;
boost::filsystem::path save_path() const;
bool move_storage(boost::filesystem::path const& save_path);
@ -879,6 +880,15 @@ all potential (not connected) peers. You can use ``is_paused()`` to determine if
is currently paused. Torrents may be paused automatically if there is a file error (eg. disk full)
or something similar. See file_error_alert_.
is_seed()
---------
::
bool is_seed() const;
Returns true if the torrent is in seed mode (i.e. if it has finished downloading).
set_tracker_login()
-------------------

View File

@ -282,7 +282,7 @@ int main(int argc, char* argv[])
std::vector<torrent_handle> handles;
session ses;
ses.listen_on(std::make_pair(6881, 6889));
ses.listen_on(std::make_pair(6880, 6889));
ses.set_upload_rate_limit(512 * 1024);
ses.set_http_settings(settings);
ses.set_severity_level(alert::debug);

View File

@ -54,6 +54,8 @@ namespace libtorrent
int left() const
{
assert(given <= max);
assert(given >= min);
assert(given >= used);
return given - used;
}

View File

@ -119,6 +119,7 @@ namespace libtorrent
std::vector<int> piece_map;
std::vector<piece_picker::downloading_piece> unfinished_pieces;
std::vector<address> peers;
entry resume_data;
// is filled in by storage::initialize_pieces()
// and represents the progress. It should be a

View File

@ -186,6 +186,7 @@ namespace libtorrent
const torrent_info& get_torrent_info() const;
bool is_valid() const;
bool is_seed() const;
bool is_paused() const;
void pause();
void resume();

View File

@ -125,7 +125,8 @@ namespace libtorrent
INVARIANT_CHECK;
m_ul_bandwidth_quota.min = 10;
m_ul_bandwidth_quota.max = 10;
m_ul_bandwidth_quota.max = 400;
m_ul_bandwidth_quota.given = 400;
m_dl_bandwidth_quota.min = 10;
m_dl_bandwidth_quota.max = std::numeric_limits<int>::max();
m_dl_bandwidth_quota.given = 400;
@ -1707,8 +1708,6 @@ namespace libtorrent
(int)ceil(statistics().upload_rate())
, m_ul_bandwidth_quota.given);
send_buffer_updated();
// If the client sends more data
// we send it data faster, otherwise, slower.
// It will also depend on how much data the
@ -1750,6 +1749,13 @@ namespace libtorrent
m_ul_bandwidth_quota.max
= std::max((int)upload_speed_limit, m_ul_bandwidth_quota.min);
}
if (m_ul_bandwidth_quota.given > m_ul_bandwidth_quota.max)
m_ul_bandwidth_quota.given = m_ul_bandwidth_quota.max;
if (m_ul_bandwidth_quota.used > m_ul_bandwidth_quota.given)
m_ul_bandwidth_quota.used = m_ul_bandwidth_quota.given;
send_buffer_updated();
/*
size_type diff = share_diff();
@ -2366,5 +2372,4 @@ namespace libtorrent
assert(m_writability_monitored);
assert(m_selector.is_writability_monitored(m_socket));
}
}

View File

@ -246,18 +246,24 @@ namespace libtorrent
}
}
#endif
#endif
float piece_picker::distributed_copies() const
{
for(int count=0;count<(int)m_piece_info.size();count++)
const float num_pieces = static_cast<float>(m_piece_map.size());
for (int i = 0; i < (int)m_piece_info.size(); ++i)
{
if(!m_piece_info[count].empty()) {
int p = (int)m_piece_info[i].size();
assert(float(p) / num_pieces <= 1.f);
if (p > 0)
{
float fraction_above_count =
1.f - float(m_piece_info[count].size())/float(m_piece_map.size());
return count+fraction_above_count;
1.f - float(p) / num_pieces;
return i + fraction_above_count;
}
}
return 0.f;
return 1.f;
}
void piece_picker::move(bool downloading, int peer_count, int elem_index)

View File

@ -117,6 +117,8 @@ namespace libtorrent { namespace detail
try
{
assert(t != 0);
t->parse_resume_data(t->resume_data, t->torrent_ptr->torrent_file());
t->resume_data = entry(); // clear the resume data now that it has been used
t->torrent_ptr->check_files(*t, m_mutex);
// lock the session to add the new torrent
@ -324,7 +326,10 @@ namespace libtorrent { namespace detail
{
#ifndef NDEBUG
check_invariant("loops_per_second++");
{
boost::mutex::scoped_lock l(m_mutex);
check_invariant("before SELECT");
}
loops_per_second++;
#endif
@ -334,6 +339,11 @@ namespace libtorrent { namespace detail
m_selector.wait(500000, readable_clients, writable_clients, error_clients);
#ifndef NDEBUG
{
boost::mutex::scoped_lock l(m_mutex);
check_invariant("after SELECT");
}
for (std::vector<boost::shared_ptr<libtorrent::socket> >::iterator i =
writable_clients.begin();
i != writable_clients.end();
@ -341,8 +351,19 @@ namespace libtorrent { namespace detail
{
assert((*i)->is_writable());
}
for (std::vector<boost::shared_ptr<libtorrent::socket> >::iterator i =
readable_clients.begin();
i != readable_clients.end();
++i)
{
assert((*i)->is_readable());
}
#endif
boost::mutex::scoped_lock l(m_mutex);
#ifndef NDEBUG
check_invariant("before abort");
#endif
if (m_abort)
{
@ -857,7 +878,7 @@ namespace libtorrent
d.torrent_ptr = torrent_ptr;
d.save_path = save_path;
d.info_hash = ti.info_hash();
d.parse_resume_data(resume_data, torrent_ptr->torrent_file());
d.resume_data = resume_data;
// add the torrent to the queue to be checked
m_checker_impl.m_torrents.push_back(d);
@ -1025,14 +1046,6 @@ namespace libtorrent
assert(bytes_per_second > 0 || bytes_per_second == -1);
boost::mutex::scoped_lock l(m_impl.m_mutex);
m_impl.m_upload_rate = bytes_per_second;
if (m_impl.m_upload_rate != -1) return;
for (detail::session_impl::connection_map::iterator i
= m_impl.m_connections.begin();
i != m_impl.m_connections.end(); ++i)
{
i->second->m_ul_bandwidth_quota.given = std::numeric_limits<int>::max();
}
}
void session::set_download_rate_limit(int bytes_per_second)
@ -1040,14 +1053,6 @@ namespace libtorrent
assert(bytes_per_second > 0 || bytes_per_second == -1);
boost::mutex::scoped_lock l(m_impl.m_mutex);
m_impl.m_download_rate = bytes_per_second;
if (m_impl.m_download_rate != -1) return;
for (detail::session_impl::connection_map::iterator i
= m_impl.m_connections.begin();
i != m_impl.m_connections.end(); ++i)
{
i->second->m_dl_bandwidth_quota.given = std::numeric_limits<int>::max();
}
}
std::auto_ptr<alert> session::pop_alert()

View File

@ -230,6 +230,14 @@ namespace libtorrent
, boost::bind(&torrent::move_storage, _1, save_path));
}
bool torrent_handle::is_seed() const
{
INVARIANT_CHECK;
return call_member<bool>(m_ses, m_chk, m_info_hash
, boost::bind(&torrent::is_seed, _1));
}
bool torrent_handle::is_paused() const
{
INVARIANT_CHECK;