mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 06:39:23 +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
|
||||
|
||||
Reference in New Issue
Block a user