lt sync 3259

This commit is contained in:
Andrew Resch 2009-02-13 17:41:09 +00:00
parent 847ad95fd3
commit b73e26344c
3 changed files with 14 additions and 5 deletions

View File

@ -634,6 +634,7 @@ namespace libtorrent
encrypt_pending_buffer(); encrypt_pending_buffer();
#ifndef TORRENT_DISABLE_ENCRYPTION
if (m_encrypted && m_rc4_encrypted) if (m_encrypted && m_rc4_encrypted)
{ {
TORRENT_ASSERT(send_buffer_size() == m_encrypted_bytes); TORRENT_ASSERT(send_buffer_size() == m_encrypted_bytes);
@ -642,12 +643,14 @@ namespace libtorrent
m_encrypted_bytes += size; m_encrypted_bytes += size;
#endif #endif
} }
#endif
peer_connection::send_buffer(buf, size, flags); peer_connection::send_buffer(buf, size, flags);
} }
buffer::interval bt_peer_connection::allocate_send_buffer(int size) buffer::interval bt_peer_connection::allocate_send_buffer(int size)
{ {
#ifndef TORRENT_DISABLE_ENCRYPTION
encrypt_pending_buffer(); encrypt_pending_buffer();
if (m_encrypted && m_rc4_encrypted) if (m_encrypted && m_rc4_encrypted)
{ {
@ -656,12 +659,14 @@ namespace libtorrent
return m_enc_send_buffer; return m_enc_send_buffer;
} }
else else
#endif
{ {
buffer::interval i = peer_connection::allocate_send_buffer(size); buffer::interval i = peer_connection::allocate_send_buffer(size);
return i; return i;
} }
} }
#ifndef TORRENT_DISABLE_ENCRYPTION
void bt_peer_connection::encrypt_pending_buffer() void bt_peer_connection::encrypt_pending_buffer()
{ {
if (m_encrypted && m_rc4_encrypted && m_enc_send_buffer.left()) if (m_encrypted && m_rc4_encrypted && m_enc_send_buffer.left())
@ -679,11 +684,14 @@ namespace libtorrent
m_enc_send_buffer.end = m_enc_send_buffer.begin; m_enc_send_buffer.end = m_enc_send_buffer.begin;
} }
} }
#endif
void bt_peer_connection::setup_send() void bt_peer_connection::setup_send()
{ {
#ifndef TORRENT_DISABLE_ENCRYPTION
encrypt_pending_buffer(); encrypt_pending_buffer();
TORRENT_ASSERT(!m_encrypted || !m_rc4_encrypted || m_encrypted_bytes == send_buffer_size()); TORRENT_ASSERT(!m_encrypted || !m_rc4_encrypted || m_encrypted_bytes == send_buffer_size());
#endif
peer_connection::setup_send(); peer_connection::setup_send();
} }
@ -2676,7 +2684,7 @@ namespace libtorrent
std::remove_if(m_payloads.begin(), m_payloads.end(), range_below_zero) std::remove_if(m_payloads.begin(), m_payloads.end(), range_below_zero)
, m_payloads.end()); , m_payloads.end());
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_ENCRYPTION
if (m_encrypted_bytes > 0) if (m_encrypted_bytes > 0)
{ {
if (m_rc4_encrypted) if (m_rc4_encrypted)

View File

@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/http_tracker_connection.hpp" #include "libtorrent/http_tracker_connection.hpp"
#include "libtorrent/buffer.hpp" #include "libtorrent/buffer.hpp"
#include "libtorrent/http_parser.hpp" #include "libtorrent/http_parser.hpp"
#include "libtorrent/escape_string.hpp"
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/ref.hpp> #include <boost/ref.hpp>
@ -85,7 +86,7 @@ void lsd::announce(sha1_hash const& ih, int listen_port)
std::stringstream btsearch; std::stringstream btsearch;
btsearch << "BT-SEARCH * HTTP/1.1\r\n" btsearch << "BT-SEARCH * HTTP/1.1\r\n"
"Host: 239.192.152.143:6771\r\n" "Host: 239.192.152.143:6771\r\n"
"Port: " << listen_port << "\r\n" "Port: " << to_string(listen_port).elems << "\r\n"
"Infohash: " << ih << "\r\n" "Infohash: " << ih << "\r\n"
"\r\n\r\n"; "\r\n\r\n";
std::string const& msg = btsearch.str(); std::string const& msg = btsearch.str();
@ -101,7 +102,7 @@ void lsd::announce(sha1_hash const& ih, int listen_port)
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING) #if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << time_now_string() m_log << time_now_string()
<< " ==> announce: ih: " << ih << " port: " << listen_port << std::endl; << " ==> announce: ih: " << ih << " port: " << to_string(listen_port).elems << std::endl;
#endif #endif
m_broadcast_timer.expires_from_now(milliseconds(250 * m_retry_count), ec); m_broadcast_timer.expires_from_now(milliseconds(250 * m_retry_count), ec);
@ -182,7 +183,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING) #if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
m_log << time_now_string() m_log << time_now_string()
<< " *** incoming local announce " << from.address() << " *** incoming local announce " << from.address()
<< ":" << port << " ih: " << ih << std::endl; << ":" << to_string(port).elems << " ih: " << ih << std::endl;
#endif #endif
// we got an announce, pass it on through the callback // we got an announce, pass it on through the callback
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS

View File

@ -1715,7 +1715,7 @@ namespace aux {
{ {
TORRENT_ASSERT(!params.save_path.empty()); TORRENT_ASSERT(!params.save_path.empty());
if (params.ti && params.ti->files().num_files() == 0) if (params.ti && params.ti->num_files() == 0)
{ {
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
throw std::runtime_error("no files in torrent"); throw std::runtime_error("no files in torrent");