mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-15 22:52:31 +00:00
* Using SocketAddress instead of std::string/uint16_t for peer
addresses. * Tracker key is now an uint32_t instead of std::string. * Added client address to UDP tracker requests. * Added a check for FD_SETSIZE and _SC_OPEN_MAX in the client. A warning is issued if max open files and sockets exceed either of these. * Cleaned up the API, propably quite close to what will be in the slush'ed API. * Swapped emit and close order in TrackerHttp. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@499 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+1
-1
@@ -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; }
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <istream>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/hide.h>
|
||||
#include <torrent/bencode.h>
|
||||
@@ -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);
|
||||
|
||||
+9
-7
@@ -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
|
||||
|
||||
@@ -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() : "<default>",
|
||||
!torrent::get_address().empty() ? torrent::get_address().c_str() : "<default>",
|
||||
(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(),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user