lt sync 1947
This commit is contained in:
parent
cc81e1073d
commit
790eda0f2c
|
@ -144,7 +144,7 @@ struct bandwidth_manager
|
|||
// this is used by web seeds
|
||||
void request_bandwidth(intrusive_ptr<PeerConnection> peer
|
||||
, int blk
|
||||
, bool non_prioritized) throw()
|
||||
, bool non_prioritized)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
INVARIANT_CHECK;
|
||||
|
@ -214,11 +214,9 @@ struct bandwidth_manager
|
|||
|
||||
private:
|
||||
|
||||
void add_history_entry(history_entry<PeerConnection, Torrent> const& e) throw()
|
||||
void add_history_entry(history_entry<PeerConnection, Torrent> const& e)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
try {
|
||||
#endif
|
||||
INVARIANT_CHECK;
|
||||
m_history.push_front(e);
|
||||
m_current_quota += e.amount;
|
||||
|
@ -230,17 +228,13 @@ private:
|
|||
|
||||
m_history_timer.expires_at(e.expires_at);
|
||||
m_history_timer.async_wait(bind(&bandwidth_manager::on_history_expire, this, _1));
|
||||
#ifndef NDEBUG
|
||||
}
|
||||
catch (std::exception&) { TORRENT_ASSERT(false); }
|
||||
#endif
|
||||
catch (std::exception&) {}
|
||||
}
|
||||
|
||||
void on_history_expire(asio::error_code const& e) throw()
|
||||
void on_history_expire(asio::error_code const& e)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
try {
|
||||
#endif
|
||||
if (e) return;
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
@ -273,13 +267,8 @@ private:
|
|||
// means we can hand out more (in case there
|
||||
// are still consumers in line)
|
||||
if (!m_queue.empty()) hand_out_bandwidth(l);
|
||||
#ifndef NDEBUG
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
#endif
|
||||
catch (std::exception&) {}
|
||||
}
|
||||
|
||||
void hand_out_bandwidth(boost::mutex::scoped_lock& l) throw()
|
||||
|
@ -289,9 +278,8 @@ private:
|
|||
// to the loop further down on the callstack
|
||||
if (m_in_hand_out_bandwidth) return;
|
||||
m_in_hand_out_bandwidth = true;
|
||||
#ifndef NDEBUG
|
||||
|
||||
try {
|
||||
#endif
|
||||
INVARIANT_CHECK;
|
||||
|
||||
ptime now(time_now());
|
||||
|
@ -406,11 +394,12 @@ private:
|
|||
}
|
||||
if (!q.empty()) m_queue.insert(m_queue.begin(), q.begin(), q.end());
|
||||
if (!tmp.empty()) m_queue.insert(m_queue.begin(), tmp.begin(), tmp.end());
|
||||
#ifndef NDEBUG
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{ TORRENT_ASSERT(false); };
|
||||
#endif
|
||||
{
|
||||
m_in_hand_out_bandwidth = false;
|
||||
throw;
|
||||
}
|
||||
m_in_hand_out_bandwidth = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace libtorrent
|
|||
void add_stat(size_type downloaded, size_type uploaded);
|
||||
|
||||
// is called once every second by the main loop
|
||||
void second_tick(float tick_interval) throw();
|
||||
void second_tick(float tick_interval);
|
||||
|
||||
boost::shared_ptr<socket_type> get_socket() const { return m_socket; }
|
||||
tcp::endpoint const& remote() const { return m_remote; }
|
||||
|
|
|
@ -333,7 +333,11 @@ namespace libtorrent
|
|||
catch (std::exception& e)
|
||||
{
|
||||
// std::cerr << "DISK THREAD: exception: " << e.what() << std::endl;
|
||||
try
|
||||
{
|
||||
j.str = e.what();
|
||||
}
|
||||
catch (std::exception&) {}
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
|
||||
Copyright (c) 2007, Un Shyam
|
||||
Copyright (c) 2007, Un Shyam & Arvid Norberg
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -40,23 +40,33 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pe_crypto.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
|
||||
namespace libtorrent {
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
// Set the prime P and the generator, generate local public key
|
||||
DH_key_exchange::DH_key_exchange()
|
||||
{
|
||||
m_DH = DH_new();
|
||||
if (m_DH == 0) throw std::bad_alloc();
|
||||
|
||||
m_DH->p = BN_bin2bn(m_dh_prime, sizeof(m_dh_prime), NULL);
|
||||
m_DH->g = BN_bin2bn(m_dh_generator, sizeof(m_dh_generator), NULL);
|
||||
if (m_DH->p == 0 || m_DH->g == 0)
|
||||
{
|
||||
DH_free(m_DH);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
m_DH->length = 160l;
|
||||
|
||||
TORRENT_ASSERT(sizeof(m_dh_prime) == DH_size(m_DH));
|
||||
|
||||
DH_generate_key (m_DH); // TODO Check != 0
|
||||
|
||||
TORRENT_ASSERT(m_DH->pub_key);
|
||||
DH_generate_key(m_DH);
|
||||
if (m_DH->pub_key == 0)
|
||||
{
|
||||
DH_free(m_DH);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
// DH can generate key sizes that are smaller than the size of
|
||||
// P with exponentially decreasing probability, in which case
|
||||
|
@ -93,10 +103,11 @@ namespace libtorrent {
|
|||
{
|
||||
TORRENT_ASSERT(remote_pubkey);
|
||||
BIGNUM* bn_remote_pubkey = BN_bin2bn ((unsigned char*)remote_pubkey, 96, NULL);
|
||||
if (bn_remote_pubkey == 0) throw std::bad_alloc();
|
||||
char dh_secret[96];
|
||||
|
||||
int secret_size = DH_compute_key ( (unsigned char*)dh_secret,
|
||||
bn_remote_pubkey, m_DH); // TODO Check for errors
|
||||
int secret_size = DH_compute_key((unsigned char*)dh_secret
|
||||
, bn_remote_pubkey, m_DH);
|
||||
|
||||
if (secret_size != 96)
|
||||
{
|
||||
|
@ -104,7 +115,6 @@ namespace libtorrent {
|
|||
std::fill(m_dh_secret, m_dh_secret + 96 - secret_size, 0);
|
||||
}
|
||||
std::copy(dh_secret, dh_secret + secret_size, m_dh_secret + 96 - secret_size);
|
||||
|
||||
BN_free(bn_remote_pubkey);
|
||||
}
|
||||
|
||||
|
|
|
@ -2182,7 +2182,7 @@ namespace libtorrent
|
|||
if (m_packet_size >= m_recv_pos) m_recv_buffer.resize(m_packet_size);
|
||||
}
|
||||
|
||||
void peer_connection::second_tick(float tick_interval) throw()
|
||||
void peer_connection::second_tick(float tick_interval)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -2359,8 +2359,7 @@ namespace libtorrent
|
|||
else if (buffer_size_watermark > 80 * 1024) buffer_size_watermark = 80 * 1024;
|
||||
|
||||
while (!m_requests.empty()
|
||||
&& (send_buffer_size() + m_reading_bytes < buffer_size_watermark)
|
||||
&& !m_choked)
|
||||
&& (send_buffer_size() + m_reading_bytes < buffer_size_watermark))
|
||||
{
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
peer_request& r = m_requests.front();
|
||||
|
|
|
@ -2250,6 +2250,7 @@ namespace libtorrent
|
|||
// skip forward in the queue until we find a prioritized peer
|
||||
// or hit the front of it.
|
||||
queue_t::reverse_iterator i = m_bandwidth_queue[channel].rbegin();
|
||||
if (!non_prioritized)
|
||||
while (i != m_bandwidth_queue[channel].rend() && i->non_prioritized) ++i;
|
||||
m_bandwidth_queue[channel].insert(i.base(), bw_queue_entry<peer_connection>(
|
||||
p, block_size, non_prioritized));
|
||||
|
|
Loading…
Reference in New Issue