regenerated html
This commit is contained in:
parent
94b3ef81c3
commit
ea535bca2b
|
@ -3100,7 +3100,7 @@ the entire file.</p>
|
||||||
closing down.</p>
|
closing down.</p>
|
||||||
<p>Example code to pause and save resume data for all torrents and wait for the alerts:</p>
|
<p>Example code to pause and save resume data for all torrents and wait for the alerts:</p>
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
int num_resume_data = 0;
|
extern int outstanding_resume_data; // global counter of outstanding resume data
|
||||||
std::vector<torrent_handle> handles = ses.get_torrents();
|
std::vector<torrent_handle> handles = ses.get_torrents();
|
||||||
ses.pause();
|
ses.pause();
|
||||||
for (std::vector<torrent_handle>::iterator i = handles.begin();
|
for (std::vector<torrent_handle>::iterator i = handles.begin();
|
||||||
|
@ -3110,12 +3110,13 @@ for (std::vector<torrent_handle>::iterator i = handles.begin();
|
||||||
if (!h.is_valid()) continue;
|
if (!h.is_valid()) continue;
|
||||||
torrent_status s = h.status();
|
torrent_status s = h.status();
|
||||||
if (!s.has_metadata) continue;
|
if (!s.has_metadata) continue;
|
||||||
|
if (!s.need_save_resume_data()) continue;
|
||||||
|
|
||||||
h.save_resume_data();
|
h.save_resume_data();
|
||||||
++num_resume_data;
|
++outstanding_resume_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (num_resume_data > 0)
|
while (outstanding_resume_data > 0)
|
||||||
{
|
{
|
||||||
alert const* a = ses.wait_for_alert(seconds(10));
|
alert const* a = ses.wait_for_alert(seconds(10));
|
||||||
|
|
||||||
|
@ -3127,7 +3128,7 @@ while (num_resume_data > 0)
|
||||||
if (alert_cast<save_resume_data_failed_alert>(a))
|
if (alert_cast<save_resume_data_failed_alert>(a))
|
||||||
{
|
{
|
||||||
process_alert(a);
|
process_alert(a);
|
||||||
--num_resume_data;
|
--outstanding_resume_data;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3143,9 +3144,18 @@ while (num_resume_data > 0)
|
||||||
/ (h.get_torrent_info().name() + ".fastresume"), std::ios_base::binary);
|
/ (h.get_torrent_info().name() + ".fastresume"), std::ios_base::binary);
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
||||||
--num_resume_data;
|
--outstanding_resume_data;
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
<div class="note">
|
||||||
|
<p class="first admonition-title">Note</p>
|
||||||
|
<p class="last">Note how <tt class="docutils literal"><span class="pre">outstanding_resume_data</span></tt> is a global counter in this example.
|
||||||
|
This is deliberate, otherwise there is a race condition for torrents that
|
||||||
|
was just asked to save their resume data, they posted the alert, but it has
|
||||||
|
not been received yet. Those torrents would report that they don't need to
|
||||||
|
save resume data again, and skipped by the initial loop, and thwart the counter
|
||||||
|
otherwise.</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="need-save-resume-data">
|
<div class="section" id="need-save-resume-data">
|
||||||
<h2>need_save_resume_data()</h2>
|
<h2>need_save_resume_data()</h2>
|
||||||
|
@ -3158,6 +3168,12 @@ bool need_save_resume_data() const;
|
||||||
torrent was first loaded or since the last time the resume data was saved. When
|
torrent was first loaded or since the last time the resume data was saved. When
|
||||||
saving resume data periodically, it makes sense to skip any torrent which hasn't
|
saving resume data periodically, it makes sense to skip any torrent which hasn't
|
||||||
downloaded anything since the last time.</p>
|
downloaded anything since the last time.</p>
|
||||||
|
<div class="note">
|
||||||
|
<p class="first admonition-title">Note</p>
|
||||||
|
<p class="last">A torrent's resume data is considered saved as soon as the alert
|
||||||
|
is posted. It is important to make sure this alert is received and handled
|
||||||
|
in order for this function to be meaningful.</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="id5">
|
<div class="section" id="id5">
|
||||||
<h2>status()</h2>
|
<h2>status()</h2>
|
||||||
|
@ -6303,7 +6319,7 @@ struct peer_disconnected_alert: peer_alert
|
||||||
<div class="section" id="invalid-request-alert">
|
<div class="section" id="invalid-request-alert">
|
||||||
<h2>invalid_request_alert</h2>
|
<h2>invalid_request_alert</h2>
|
||||||
<p>This is a debug alert that is generated by an incoming invalid piece request.
|
<p>This is a debug alert that is generated by an incoming invalid piece request.
|
||||||
<tt class="docutils literal"><span class="pre">ìp</span></tt> is the address of the peer and the <tt class="docutils literal"><span class="pre">request</span></tt> is the actual incoming
|
<tt class="docutils literal"><span class="pre">Ïp</span></tt> is the address of the peer and the <tt class="docutils literal"><span class="pre">request</span></tt> is the actual incoming
|
||||||
request from the peer.</p>
|
request from the peer.</p>
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
struct invalid_request_alert: peer_alert
|
struct invalid_request_alert: peer_alert
|
||||||
|
@ -7754,13 +7770,13 @@ std::string error_code_to_string(boost::system::error_code const& ec)
|
||||||
static const char const* swedish[] =
|
static const char const* swedish[] =
|
||||||
{
|
{
|
||||||
"inget fel",
|
"inget fel",
|
||||||
"en fil i torrenten kolliderar med en fil från en annan torrent",
|
"en fil i torrenten kolliderar med en fil frÂn en annan torrent",
|
||||||
"hash check misslyckades",
|
"hash check misslyckades",
|
||||||
"torrent filen är inte en dictionary",
|
"torrent filen ‰r inte en dictionary",
|
||||||
"'info'-nyckeln saknas eller är korrupt i torrentfilen",
|
"'info'-nyckeln saknas eller ‰r korrupt i torrentfilen",
|
||||||
"'info'-fältet är inte en dictionary",
|
"'info'-f‰ltet ‰r inte en dictionary",
|
||||||
"'piece length' fältet saknas eller är korrupt i torrentfilen",
|
"'piece length' f‰ltet saknas eller ‰r korrupt i torrentfilen",
|
||||||
"torrentfilen saknar namnfältet",
|
"torrentfilen saknar namnf‰ltet",
|
||||||
"ogiltigt namn i torrentfilen (kan vara en attack)",
|
"ogiltigt namn i torrentfilen (kan vara en attack)",
|
||||||
// ... more strings here
|
// ... more strings here
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue