* Fixed an overflow in rak::partial_queue, and added some exceptions.

* Changed to configure script so --disable-mincore must be called
explicitly to disable it.

* API and core::Download cleanup.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@660 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-03-31 23:02:39 +00:00
parent 59a23ea9ed
commit d9d27139d1
26 changed files with 266 additions and 254 deletions
+22 -22
View File
@@ -108,29 +108,29 @@ print_address(char* first, char* last, const sockaddr* sa) {
char*
print_download_title(char* first, char* last, core::Download* d) {
return print_buffer(first, last, " %s", d->get_download().name().c_str());
return print_buffer(first, last, " %s", d->download()->name().c_str());
}
char*
print_download_info(char* first, char* last, core::Download* d) {
first = print_buffer(first, last, "Torrent: ");
if (!d->get_download().is_open())
if (!d->download()->is_open())
first = print_buffer(first, last, "closed ");
else if (d->is_done())
first = print_buffer(first, last, "done %10.1f MB", (double)d->get_download().bytes_total() / (double)(1 << 20));
first = print_buffer(first, last, "done %10.1f MB", (double)d->download()->bytes_total() / (double)(1 << 20));
else
first = print_buffer(first, last, "%6.1f / %6.1f MB",
(double)d->get_download().bytes_done() / (double)(1 << 20),
(double)d->get_download().bytes_total() / (double)(1 << 20));
(double)d->download()->bytes_done() / (double)(1 << 20),
(double)d->download()->bytes_total() / (double)(1 << 20));
first = print_buffer(first, last, " Rate: %5.1f / %5.1f KB Uploaded: %7.1f MB",
(double)d->get_download().up_rate()->rate() / (1 << 10),
(double)d->get_download().down_rate()->rate() / (1 << 10),
(double)d->get_download().up_rate()->total() / (1 << 20));
(double)d->download()->up_rate()->rate() / (1 << 10),
(double)d->download()->down_rate()->rate() / (1 << 10),
(double)d->download()->up_rate()->total() / (1 << 20));
if (d->get_download().is_active() && !d->is_done()) {
if (d->download()->is_active() && !d->is_done()) {
first = print_buffer(first, last, " ");
first = print_download_percentage_done(first, last, d);
@@ -151,25 +151,25 @@ print_download_info(char* first, char* last, core::Download* d) {
char*
print_download_status(char* first, char* last, core::Download* d) {
if (!d->get_download().is_active())
if (!d->download()->is_active())
first = print_buffer(first, last, "Inactive: ");
if (d->get_download().is_hash_checking())
if (d->download()->is_hash_checking()) {
first = print_buffer(first, last, "Checking hash [%2i%%]",
(d->get_download().chunks_hashed() * 100) / d->get_download().chunks_total());
(d->download()->chunks_hashed() * 100) / d->download()->chunks_total());
else if (d->get_download().is_tracker_busy() &&
d->get_download().tracker_list().focus() < d->get_download().tracker_list().size()) {
torrent::TrackerList tl = d->get_download().tracker_list();
} else if (d->tracker_list()->is_busy() && d->tracker_list()->focus() < d->tracker_list()->size()) {
torrent::TrackerList* tl = d->tracker_list();
first = print_buffer(first, last, "Tracker[%i:%i]: Connecting to %s",
tl.get(tl.focus()).group(), tl.focus(), tl.get(tl.focus()).url().c_str());
tl->get(tl->focus()).group(), tl->focus(), tl->get(tl->focus()).url().c_str());
} else if (!d->get_message().empty())
first = print_buffer(first, last, "%s", d->get_message().c_str());
} else if (!d->message().empty()) {
first = print_buffer(first, last, "%s", d->message().c_str());
else
} else {
*first = '\0';
}
if (first > last)
throw torrent::internal_error("print_download_status(...) wrote past end of the buffer.");
@@ -179,12 +179,12 @@ print_download_status(char* first, char* last, core::Download* d) {
char*
print_download_time_left(char* first, char* last, core::Download* d) {
uint32_t rate = d->get_download().down_rate()->rate();
uint32_t rate = d->download()->down_rate()->rate();
if (rate < 512)
return print_buffer(first, last, "--:--:--");
time_t remaining = (d->get_download().bytes_total() - d->get_download().bytes_done()) / (rate & ~(uint32_t)(512 - 1));
time_t remaining = (d->download()->bytes_total() - d->download()->bytes_done()) / (rate & ~(uint32_t)(512 - 1));
return print_ddhhmm(first, last, remaining);
}
@@ -195,7 +195,7 @@ print_download_percentage_done(char* first, char* last, core::Download* d) {
//return print_buffer(first, last, "[--%%]");
return print_buffer(first, last, " ");
else
return print_buffer(first, last, "[%2u%%]", (d->get_download().chunks_done() * 100) / d->get_download().chunks_total());
return print_buffer(first, last, "[%2u%%]", (d->download()->chunks_done() * 100) / d->download()->chunks_total());
}
char*
+4 -4
View File
@@ -61,11 +61,11 @@ WindowDownloadChunksSeen::redraw() {
return;
m_canvas->print(2, 0, "Chunks seen: [C/A/D %i/%i/%.2f]",
(int)m_download->get_download().peers_complete(),
(int)m_download->get_download().peers_accounted(),
(int)m_download->download()->peers_complete(),
(int)m_download->download()->peers_accounted(),
std::floor(m_download->distributed_copies() * 100.0f) / 100.0f);
const uint8_t* seen = m_download->get_download().chunks_seen();
const uint8_t* seen = m_download->download()->chunks_seen();
if (seen == NULL) {
m_canvas->print(2, 2, "Not available.");
@@ -77,7 +77,7 @@ WindowDownloadChunksSeen::redraw() {
char* end = buffer + m_canvas->get_width() - 2;
const uint8_t* chunk = seen;
const uint8_t* last = seen + m_download->get_download().chunks_total();
const uint8_t* last = seen + m_download->download()->chunks_total();
for (int y = 1; y < m_canvas->get_height() && chunk < last; ++y) {
position = buffer + std::max(snprintf(buffer, end - buffer, "%5d", chunk - seen), 0);
+12 -12
View File
@@ -67,26 +67,26 @@ WindowDownloadStatusbar::redraw() {
m_canvas->print(0, 0, "%s", buffer);
position = buffer + std::max(snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I/C/A: %i/%i/%i/%i Failed: %i",
(int)m_download->get_download().peers_connected(),
(int)m_download->get_download().peers_not_connected(),
(int)m_download->get_download().peers_min(),
(int)m_download->get_download().peers_max(),
(int)m_download->get_download().uploads_max(),
(int)m_download->get_download().peers_currently_unchoked(),
(int)m_download->get_download().peers_currently_interested(),
(int)m_download->get_download().peers_complete(),
(int)m_download->get_download().peers_accounted(),
(int)m_download->download()->peers_connected(),
(int)m_download->download()->peers_not_connected(),
(int)m_download->download()->peers_min(),
(int)m_download->download()->peers_max(),
(int)m_download->download()->uploads_max(),
(int)m_download->download()->peers_currently_unchoked(),
(int)m_download->download()->peers_currently_interested(),
(int)m_download->download()->peers_complete(),
(int)m_download->download()->peers_accounted(),
(int)m_download->chunks_failed()),
0);
// position = buffer + std::max(snprintf(position, last - buffer, " Priority: %s",
// core::Download::priority_to_string(m_download->variables()->get("priority").as_value())),
// core::Download::priority_to_string(m_download->variable()->get("priority").as_value())),
// 0);
m_canvas->print(0, 1, "%s", buffer);
position = print_download_status(buffer, last, m_download);
m_canvas->print(0, 2, "[%c:%i] %s",
m_download->get_download().is_tracker_busy() ? 'C' : ' ',
(int)(m_download->get_download().tracker_list().timeout() / 1000000),
m_download->tracker_list()->is_busy() ? 'C' : ' ',
(int)(m_download->download()->tracker_list().timeout() / 1000000),
buffer);
}
+1 -1
View File
@@ -76,7 +76,7 @@ WindowFileList::redraw() {
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
m_canvas->erase();
torrent::FileList fl = m_download->get_download().file_list();
torrent::FileList fl = m_download->download()->file_list();
if (fl.size() == 0 || m_canvas->get_height() < 2)
return;
+13 -13
View File
@@ -66,29 +66,29 @@ WindowPeerInfo::redraw() {
m_canvas->erase();
int y = 0;
torrent::Download d = m_download->get_download();
torrent::Download* d = m_download->download();
m_canvas->print(0, y++, "Hash: %s", rak::transform_hex(d.info_hash()).c_str());
m_canvas->print(0, y++, "Id: %s", rak::copy_escape_html(d.local_id()).c_str());
m_canvas->print(0, y++, "Hash: %s", rak::transform_hex(d->info_hash()).c_str());
m_canvas->print(0, y++, "Id: %s", rak::copy_escape_html(d->local_id()).c_str());
m_canvas->print(0, y++, "Chunks: %u / %u * %u",
d.chunks_done(),
d.chunks_total(),
d.chunks_size());
d->chunks_done(),
d->chunks_total(),
d->chunks_size());
char buffer[32], *position;
position = print_ddmmyyyy(buffer, buffer + 32, static_cast<time_t>(d.creation_date()));
position = print_ddmmyyyy(buffer, buffer + 32, static_cast<time_t>(d->creation_date()));
position = print_string(position, buffer + 32, " ");
position = print_hhmmss(position, buffer + 32, static_cast<time_t>(d.creation_date()));
position = print_hhmmss(position, buffer + 32, static_cast<time_t>(d->creation_date()));
m_canvas->print(0, y++, "Created: %s", buffer);
y++;
m_canvas->print(0, y++, "Connection Type: %s ( %s / %s )",
m_download->variables()->get("connection_current").as_string().c_str(),
m_download->variables()->get("connection_seed").as_string().c_str(),
m_download->variables()->get("connection_leech").as_string().c_str());
m_canvas->print(0, y++, "Priority: %u", torrent::download_priority(m_download->get_download()));
m_download->variable()->get("connection_current").as_string().c_str(),
m_download->variable()->get("connection_seed").as_string().c_str(),
m_download->variable()->get("connection_leech").as_string().c_str());
m_canvas->print(0, y++, "Priority: %u", torrent::download_priority(*m_download->download()));
m_canvas->print(0, y++, "Directory: %s", m_download->variable_string("directory").c_str());
m_canvas->print(0, y++, "Tied to file: %s", m_download->variable_string("tied_to_file").c_str());
@@ -135,7 +135,7 @@ WindowPeerInfo::redraw() {
int
WindowPeerInfo::done_percentage(torrent::Peer& p) {
int chunks = m_download->get_download().chunks_total();
int chunks = m_download->download()->chunks_total();
return chunks ? (100 * p.chunks_done()) / chunks : 0;
}
+2 -2
View File
@@ -86,7 +86,7 @@ WindowPeerList::redraw() {
m_list->end(),
m_canvas->get_height() - y);
if (m_download->get_download().chunks_total() <= 0)
if (m_download->download()->chunks_total() <= 0)
throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value");
while (range.first != range.second) {
@@ -141,7 +141,7 @@ WindowPeerList::redraw() {
int
WindowPeerList::done_percentage(torrent::Peer& p) {
int chunks = m_download->get_download().chunks_total();
int chunks = m_download->download()->chunks_total();
return chunks ? (100 * p.chunks_done()) / chunks : 0;
}
+1 -1
View File
@@ -66,7 +66,7 @@ WindowTrackerList::redraw() {
++pos;
torrent::TrackerList tl = m_download->get_download().tracker_list();
torrent::TrackerList tl = m_download->download()->tracker_list();
if (tl.size() == 0)
return;