diff --git a/src/core/download.h b/src/core/download.h index 0c9a6422..59ef0964 100644 --- a/src/core/download.h +++ b/src/core/download.h @@ -59,7 +59,7 @@ public: torrent::Download& get_download() { return m_download; } const torrent::Download& get_download() const { return m_download; } std::string get_hash() { return m_download.get_hash(); } - torrent::Bencode& get_bencode() { return torrent::download_bencode(m_download.get_hash()); } + torrent::Bencode& get_bencode() { return m_download.get_bencode(); } const std::string& get_message() { return m_message; } diff --git a/src/core/download_store.cc b/src/core/download_store.cc index 248fd7a5..a0bd5e05 100644 --- a/src/core/download_store.cc +++ b/src/core/download_store.cc @@ -67,7 +67,7 @@ DownloadStore::save(Download* d) { if (!f.is_open()) throw std::runtime_error("core::DownloadStore::save(...) could not open file"); - f << torrent::download_bencode(d->get_hash()); + f << d->get_bencode(); if (f.fail()) throw std::runtime_error("core::DownloadStore::save(...) could not write torrent"); diff --git a/src/core/manager.cc b/src/core/manager.cc index 05612a14..a6037244 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include #include @@ -70,6 +72,16 @@ Manager::initialize() { CurlStack::init(); listen_open(); + if (torrent::get_max_open_files() + torrent::get_max_open_sockets() + 32 > FD_SETSIZE) { + m_logImportant.push_front("Warning: Max open sockets and files exceeds FD_SETSIZE"); + m_logComplete.push_front("Warning: Max open sockets and files exceeds FD_SETSIZE"); + } + + if (torrent::get_max_open_files() + torrent::get_max_open_sockets() + 32 > (unsigned int)sysconf(_SC_OPEN_MAX)) { + m_logImportant.push_front("Warning: Max open sockets and files exceeds _SC_OPEN_MAX"); + m_logComplete.push_front("Warning: Max open sockets and files exceeds _SC_OPEN_MAX"); + } + // Register slots to be called when a download is inserted/erased, // opened or closed. m_downloadList.slot_map_insert()["0_initialize_bencode"] = sigc::mem_fun(*this, &Manager::initialize_bencode); diff --git a/src/core/poll.cc b/src/core/poll.cc index b169e748..f221aac3 100644 --- a/src/core/poll.cc +++ b/src/core/poll.cc @@ -71,19 +71,21 @@ Poll::poll(utils::Timer timeout) { timeval t = std::min(timeout, utils::Timer(torrent::get_next_timeout())).tval(); + if (m_maxFd >= FD_SETSIZE) + throw std::runtime_error("Poll::work(): max fd >= FD_SETSIZE"); + errno = 0; m_maxFd = select(m_maxFd + 1, m_readSet, m_writeSet, m_exceptSet, &t); - if (m_maxFd >= 0) { - work(); + if (m_maxFd >= 0) + return work(); - } else if (errno == EINTR) { + if (errno == EINTR) { m_slotSelectInterrupted(); - work_input(); - - } else if (errno < 0) { - throw std::runtime_error("Poll::work(): select error"); + return work_input(); } + + throw std::runtime_error("Poll::work(): select error"); } void diff --git a/src/display/window_statusbar.cc b/src/display/window_statusbar.cc index 253011ad..75f20c3b 100644 --- a/src/display/window_statusbar.cc +++ b/src/display/window_statusbar.cc @@ -76,9 +76,9 @@ WindowStatusbar::redraw() { buf, (double)torrent::get_write_rate().rate() / 1024.0, (double)torrent::get_read_rate().rate() / 1024.0, - !torrent::get_ip().empty() ? torrent::get_ip().c_str() : "", + !torrent::get_address().empty() ? torrent::get_address().c_str() : "", (int)torrent::get_listen_port(), - !torrent::get_bind().empty() ? (" Bind: " + torrent::get_bind()).c_str() : ""); + !torrent::get_bind_address().empty() ? (" Bind: " + torrent::get_bind_address()).c_str() : ""); pos = snprintf(buf, 128, "[%3i/%3i/%3i]", torrent::get_total_handshakes(), diff --git a/src/display/window_tracker_list.cc b/src/display/window_tracker_list.cc index be9555d1..ffe2fefb 100644 --- a/src/display/window_tracker_list.cc +++ b/src/display/window_tracker_list.cc @@ -84,11 +84,12 @@ WindowTrackerList::redraw() { range.first == *m_focus ? '*' : ' ', t.get_url().c_str()); - m_canvas->print(0, pos++, "%c Group: %2i Id: %s Enabled: %s", + m_canvas->print(0, pos++, "%c Group: %2i Id: %s Enabled: %s Open: %s", range.first == *m_focus ? '*' : ' ', t.get_group(), utils::escape_string(t.get_tracker_id()).c_str(), - t.is_enabled() ? "yes" : "no"); + t.is_enabled() ? "yes" : "no", + t.is_open() ? "yes" : "no"); ++range.first; } diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index 4d86a90f..e5981424 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -189,12 +189,12 @@ apply_throttle_interval(ui::Control* m, int arg) { void apply_bind(ui::Control* m, const std::string& arg) { - torrent::set_bind(arg); + torrent::set_bind_address(arg); } void apply_ip(ui::Control* m, const std::string& arg) { - torrent::set_ip(arg); + torrent::set_address(arg); } // The arg string *must* have been checked with validate_port_range diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index d57f2cdd..5fbc1569 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -68,7 +68,7 @@ DownloadList::DownloadList(Control* c) : m_window(c->get_display().end()), - m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + torrent::get_version())), + m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + std::string(torrent::get_version()))), m_windowHttpQueue(new WHttp(&c->get_core().get_http_queue())), m_uiDownload(NULL),