* Clear the download rate when finishing a torrent.

* Fixed torrent::set_{bind,local}_address(...) so they update
correctly.

* Tweaked the time left display, show minutes instead of seconds.

* Add earlier check on validity of the socket address of
incoming/outgoing connection.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@610 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-12-18 23:49:00 +00:00
parent e45f05ee98
commit 4e8e5a18df
6 changed files with 33 additions and 24 deletions
+8 -7
View File
@@ -24,7 +24,7 @@
# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
#session =
#session = ./session
# The ip address reported to the tracker.
#ip = 127.0.0.1
@@ -70,10 +70,11 @@
# Number of sockets to simultaneously keep open.
#max_open_sockets = <no default>
# Dump data received from trackers to the files
# "./tracker_dump.<time>".
#tracker_dump = no
# Change the interval between each throttle tick, in milliseconds. In
# the range 1-5000 ms.
#throttle_interval = 1000
# Example of scheduling commands: Switch between two ip's every 5
# seconds.
#schedule = "ip_tick1,5,10,ip=torretta"
#schedule = "ip_tick2,10,10,ip=lampedusa"
# Remove a scheduled event.
#schedule_remove = "ip_tick1"
+3 -3
View File
@@ -245,18 +245,18 @@ Manager::receive_download_done(Download* d) {
void
Manager::listen_open() {
if (m_portFirst > m_portLast)
throw std::runtime_error("Invalid port range for listening");
throw torrent::input_error("Invalid port range for listening");
if (m_portRandom) {
int boundary = m_portFirst + random() % (m_portLast - m_portFirst + 1);
if (!torrent::listen_open(boundary, m_portLast) &&
!torrent::listen_open(m_portFirst, boundary))
throw std::runtime_error("Could not open port for listening.");
throw torrent::input_error("Could not open/bind a port for listening.");
} else {
if (!torrent::listen_open(m_portFirst, m_portLast))
throw std::runtime_error("Could not open port for listening.");
throw torrent::input_error("Could not open/bind a port for listening.");
}
}
+2 -2
View File
@@ -79,6 +79,8 @@ public:
void initialize_second();
void cleanup();
void listen_open();
void shutdown(bool force);
DListItr insert(std::istream* s);
@@ -92,8 +94,6 @@ public:
void push_log(const std::string& msg) { m_logImportant.push_front(msg); m_logComplete.push_front(msg); }
private:
void listen_open();
void create_http(const std::string& uri);
void create_final(std::istream* s);
+11 -11
View File
@@ -66,20 +66,20 @@ print_hhmmss(char* buf, unsigned int length, time_t t) {
if (u == NULL)
return "inv_time";
unsigned int s = snprintf(buf, length, "%02u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
unsigned int s = snprintf(buf, length, "%2u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
return buf + std::min(s, length);
}
char*
print_hhhhmmss(char* buf, unsigned int length, time_t t) {
std::tm *u = std::localtime(&t);
print_ddhhmm(char* buf, unsigned int length, time_t t) {
unsigned int s;
if (t / (24 * 3600) < 100)
s = snprintf(buf, length, "%2li:%02li:%02li", t / (24 * 3600), (t / 3600) % 24, (t / 60) % 60);
else
s = snprintf(buf, length, "--:--:--");
if (u == NULL)
return "inv_time";
unsigned int s = snprintf(buf, length, "%2u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
return buf + std::min(s, length);
}
@@ -117,12 +117,12 @@ print_download_info(char* buf, unsigned int length, core::Download* d) {
(double)d->get_download().bytes_done() / (double)(1 << 20),
(double)d->get_download().bytes_total() / (double)(1 << 20)));
buf += std::max(0, snprintf(buf, last - buf, " Rate: %5.1f / %5.1f KB Uploaded: %.1f MB",
buf += std::max(0, snprintf(buf, last - buf, " 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)));
buf += std::max(0, snprintf(buf, length, " Left: "));
//buf += std::max(0, snprintf(buf, length, " Left: "));
buf = print_download_time_left(buf, length, d);
return buf;
@@ -165,7 +165,7 @@ print_download_time_left(char* buf, unsigned int length, core::Download* d) {
time_t remaining = (d->get_download().bytes_total() - d->get_download().bytes_done()) / (rate & ~(uint32_t)(512 - 1));
return print_hhhhmmss(buf, length, remaining);
return print_ddhhmm(buf, length, remaining);
}
// char*
+1 -1
View File
@@ -57,7 +57,7 @@ namespace display {
char* print_string(char* buf, unsigned int length, char* str);
char* print_hhmmss(char* buf, unsigned int length, time_t t);
char* print_hhhhmmss(char* buf, unsigned int length, time_t t);
char* print_ddhhmm(char* buf, unsigned int length, time_t t);
char* print_ddmmyyyy(char* buf, unsigned int length, time_t t);
char* print_download_title(char* buf, unsigned int length, core::Download* d);
+8
View File
@@ -158,7 +158,15 @@ apply_max_open_sockets(Control* m, int arg) {
void
apply_bind(Control* m, const std::string& arg) {
bool reopenListen = torrent::listen_port();
if (reopenListen)
torrent::listen_close();
torrent::set_bind_address(arg);
if (reopenListen)
m->core()->listen_open();
}
void