diff --git a/docs/manual.html b/docs/manual.html
index d31fdccf4..2d1e5d2b9 100755
--- a/docs/manual.html
+++ b/docs/manual.html
@@ -135,13 +135,13 @@ boost.filesystem, boost.date_time and various other boost libraries as well as z
Windows 2000 vc7.1
Linux x86 (debian) GCC 3.0.4, GCC 3.2.3
Windows 2000, msvc6 sp5 (does not support 64-bit values due to problems with operator<<(ostream&, __int64))
+Cygwin GCC 3.3.1
Fails on:
-- Linux x86 (Debian) GCC 2.95.4 (std::ios_base is missing)
-- Cygwin GCC 3.3.1 (compiles but crashes)
+- GCC 2.95.4 (std::ios_base is missing)
libtorrent is released under the BSD-license.
@@ -166,6 +166,14 @@ bjam <toolset>
"force conformance in for loop scope" and "treat wchar_t as built-in type" to Yes.
If you're building in developer studio 6, you will probably have to use the previous
version of boost, boost 1.30.2.
+There are two versions of the socket code, one that works with unix systems (and bsd-sockets) and
+one that uses winsock. If you're building in windows, the file socket_win.cpp is supposed to
+be included in the build while socket_bsd.cpp is supposed to be excluded.
+The file abstraction has the same kind of separation. There's one file_win.cpp which
+relies on windows file API that supports files larger than 2 Gigabytes. This does not work
+in vc6 for some reason, possibly because it may require windows NT and above. The other file,
+file.cpp is the default implementation that simply relies on the standard library's fstream,
+and as a result does not support files larger than 2 Gigabytes.
The Jamfile can build both a release and debug version of libtorrent. In debug mode,
diff --git a/docs/manual.rst b/docs/manual.rst
index 519071302..0b3595455 100755
--- a/docs/manual.rst
+++ b/docs/manual.rst
@@ -116,6 +116,16 @@ version of boost, `boost 1.30.2`__.
__ http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041&release_id=178835
+There are two versions of the socket code, one that works with unix systems (and bsd-sockets) and
+one that uses winsock. If you're building in windows, the file ``socket_win.cpp`` is supposed to
+be included in the build while ``socket_bsd.cpp`` is supposed to be excluded.
+
+The file abstraction has the same kind of separation. There's one ``file_win.cpp`` which
+relies on windows file API that supports files larger than 2 Gigabytes. This does not work
+in vc6 for some reason, possibly because it may require windows NT and above. The other file,
+``file.cpp`` is the default implementation that simply relies on the standard library's fstream,
+and as a result does not support files larger than 2 Gigabytes.
+
release and debug builds
------------------------
diff --git a/examples/client_test.cpp b/examples/client_test.cpp
index 13d9cff65..906aff20b 100755
--- a/examples/client_test.cpp
+++ b/examples/client_test.cpp
@@ -401,7 +401,7 @@ int main(int argc, char* argv[])
// << static_cast((i->flags & peer_info::supports_extensions)?"e":"_")
// << static_cast((i->flags & peer_info::local_connection)?"l":"r")
<< "\n";
-/*
+
if (i->downloading_piece_index >= 0)
{
out.width(5);
@@ -413,9 +413,9 @@ int main(int argc, char* argv[])
, 50);
out << "\n";
}
-*/
+
}
-/*
+
out << "___________________________________\n";
i->get_download_queue(queue);
@@ -436,7 +436,7 @@ int main(int argc, char* argv[])
}
out << "___________________________________\n";
-*/
+
}
for (std::deque::iterator i = events.begin();
diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp
index 5ec8ac597..5d7458be3 100755
--- a/include/libtorrent/peer_connection.hpp
+++ b/include/libtorrent/peer_connection.hpp
@@ -187,6 +187,8 @@ namespace libtorrent
bool verify_piece(const peer_request& p) const;
const stat& statistics() const { return m_statistics; }
+ void add_stat(size_type downloaded, size_type uploaded)
+ { m_statistics.add_stat(downloaded, uploaded); }
// is called once every second by the main loop
void second_tick();
diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp
index 6f8c48906..6e22cda3d 100755
--- a/include/libtorrent/stat.hpp
+++ b/include/libtorrent/stat.hpp
@@ -124,6 +124,12 @@ namespace libtorrent
size_type total_protocol_upload() const { return m_total_upload_protocol; }
size_type total_protocol_download() const { return m_total_download_protocol; }
+ void add_stat(size_type downloaded, size_type uploaded)
+ {
+ m_total_download_payload += downloaded;
+ m_total_upload_payload += uploaded;
+ }
+
private:
#ifndef NDEBUG
diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp
index 43d4cd369..5446ef490 100755
--- a/include/libtorrent/torrent_handle.hpp
+++ b/include/libtorrent/torrent_handle.hpp
@@ -153,7 +153,13 @@ namespace libtorrent
// TODO: there must be a way to get resume data and
// shut down the torrent in one atomic operation
- entry write_resume_data();
+ entry write_resume_data() const;
+
+ // TODO: support pause/resume
+ // that will not delete the torrent or its
+ // policy. If those are deleted all share
+ // ratios to all clients are lost, we don't
+ // want that.
// forces this torrent to reannounce
// (make a rerequest from the tracker)
diff --git a/src/policy.cpp b/src/policy.cpp
index ec559eb27..29126784d 100755
--- a/src/policy.cpp
+++ b/src/policy.cpp
@@ -487,6 +487,9 @@ namespace libtorrent
{
using namespace boost::posix_time;
+ // TODO: we must also remove peers that
+ // we failed to connect to from this list
+ // to avoid being part of a DDOS-attack
// remove old disconnected peers from the list
m_peers.erase(
std::remove_if(m_peers.begin()
@@ -719,9 +722,12 @@ namespace libtorrent
}
assert(i->connection == 0);
+ c.add_stat(i->prev_amount_download, i->prev_amount_upload);
+ i->prev_amount_download = 0;
+ i->prev_amount_upload = 0;
i->connection = &c;
i->connected = boost::posix_time::second_clock::local_time();
- m_last_optimistic_disconnect=boost::posix_time::second_clock::local_time();
+ m_last_optimistic_disconnect = boost::posix_time::second_clock::local_time();
}
void policy::peer_from_tracker(const address& remote, const peer_id& id)
@@ -906,6 +912,9 @@ namespace libtorrent
assert(p->type==peer::connectable);
p->connection = &m_torrent->connect_to_peer(p->id);
+ p->connection->add_stat(p->prev_amount_download, p->prev_amount_upload);
+ p->prev_amount_download = 0;
+ p->prev_amount_upload = 0;
p->connected = boost::posix_time::second_clock::local_time();
return true;
}
@@ -1015,8 +1024,8 @@ namespace libtorrent
{
if (connection != 0)
{
- return connection->statistics().total_payload_download()
- + prev_amount_download;
+ assert(prev_amount_download == 0);
+ return connection->statistics().total_payload_download();
}
else
{
@@ -1028,8 +1037,8 @@ namespace libtorrent
{
if (connection != 0)
{
- return connection->statistics().total_payload_upload()
- + prev_amount_upload;
+ assert(prev_amount_upload == 0);
+ return connection->statistics().total_payload_upload();
}
else
{
diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp
index 297f2c673..29c528ee6 100755
--- a/src/torrent_handle.cpp
+++ b/src/torrent_handle.cpp
@@ -225,7 +225,7 @@ namespace libtorrent
return false;
}
- entry torrent_handle::write_resume_data()
+ entry torrent_handle::write_resume_data() const
{
std::vector piece_index;
if (m_ses == 0)