*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-02-01 13:48:30 +00:00
parent 80fd484e4d
commit 2722e5803f
4 changed files with 52 additions and 8 deletions

View File

@ -22,7 +22,7 @@ SOURCES =
lib torrent
: src/$(SOURCES)
# <lib>zlib/zlib
zlib//zlib
# zlib//zlib
# <file>boost_filesystem.lib
# <file>boost_date_time.lib
# <file>boost_thread.dll

View File

@ -320,7 +320,9 @@ int main(int argc, char* argv[])
torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get());
if (p)
{
ses.set_upload_rate_limit(30 * 1024);
ses.set_upload_rate_limit(30000);
p->handle.set_max_connections(10);
p->handle.set_max_uploads(5);
}
if (events.size() >= 10) events.pop_front();
events.push_back(a->msg());

View File

@ -146,12 +146,7 @@ namespace libtorrent
bool is_seed() const;
bool has_timed_out() const
{
boost::posix_time::time_duration d;
d = boost::posix_time::second_clock::local_time() - m_last_receive;
return d > boost::posix_time::seconds(m_timeout);
}
bool has_timed_out() const;
// will send a keep-alive message to the peer
void keep_alive();
@ -532,7 +527,17 @@ namespace libtorrent
// message
boost::posix_time::time_duration m_last_piece_time;
// this is true if this connection has been added
// to the list of connections that will be closed.
bool m_disconnecting;
// the time when this peer sent us a not_interested message
// the last time.
boost::posix_time::ptime m_became_uninterested;
// the time when we sent a not_interested message to
// this peer the last time.
boost::posix_time::ptime m_became_uninteresting;
};
// this is called each time this peer generates some

View File

@ -108,6 +108,8 @@ namespace libtorrent
, m_last_piece(boost::posix_time::second_clock::local_time())
, m_last_piece_time(boost::posix_time::seconds(0))
, m_disconnecting(false)
, m_became_uninterested(boost::posix_time::second_clock::local_time())
, m_became_uninteresting(boost::posix_time::second_clock::local_time())
{
INVARIANT_CHECK;
@ -171,6 +173,8 @@ namespace libtorrent
, m_last_piece(boost::posix_time::second_clock::local_time())
, m_last_piece_time(boost::posix_time::seconds(0))
, m_disconnecting(false)
, m_became_uninterested(boost::posix_time::second_clock::local_time())
, m_became_uninteresting(boost::posix_time::second_clock::local_time())
{
INVARIANT_CHECK;
@ -413,6 +417,8 @@ namespace libtorrent
m_statistics.received_bytes(0, received);
if (m_recv_pos < m_packet_size) return;
m_became_uninterested = boost::posix_time::second_clock::local_time();
// clear the request queue if the client isn't interested
m_requests.clear();
@ -1187,6 +1193,9 @@ namespace libtorrent
char msg[] = {0,0,0,1,msg_not_interested};
m_send_buffer.insert(m_send_buffer.end(), msg, msg+sizeof(msg));
m_interesting = false;
m_became_uninteresting = boost::posix_time::second_clock::local_time();
#ifndef NDEBUG
(*m_logger) << " ==> NOT_INTERESTED\n";
#endif
@ -1720,6 +1729,34 @@ namespace libtorrent
}
#endif
bool peer_connection::has_timed_out() const
{
using namespace boost::posix_time;
// if the peer hasn't said a thing for a certain
// time, it is considered to have timed out
time_duration d;
d = second_clock::local_time() - m_last_receive;
if (d > seconds(m_timeout)) return true;
// if the peer hasn't become interested and we haven't
// become interested in the peer for 60 seconds, it
// has also timed out.
time_duration d1;
time_duration d2;
d1 = second_clock::local_time() - m_became_uninterested;
d2 = second_clock::local_time() - m_became_uninteresting;
if (!m_interesting
&& !m_peer_interested
&& d1 > seconds(60)
&& d2 > seconds(60))
{
return true;
}
return false;
}
void peer_connection::keep_alive()
{
INVARIANT_CHECK;