forked from premiere/premiere-libtorrent
support for adjusting the socket buffer sizes through session_settings
This commit is contained in:
parent
6ca1c191b6
commit
84dda7b617
|
@ -1,3 +1,5 @@
|
|||
* added support for changing socket buffer sizes through
|
||||
session_settings
|
||||
* added support for merkle hash tree torrents (.merkle.torrent)
|
||||
* added 'seed mode', which assumes that all files are complete
|
||||
and checks hashes lazily, as blocks are requested
|
||||
|
|
|
@ -3357,6 +3357,9 @@ that will be sent to the tracker. The user-agent is a good way to identify your
|
|||
bool lock_disk_cache;
|
||||
|
||||
int max_rejects;
|
||||
|
||||
int recv_socket_buffer_size;
|
||||
int send_socket_buffer_size;
|
||||
};
|
||||
|
||||
``user_agent`` this is the client identification to the tracker.
|
||||
|
@ -3702,6 +3705,13 @@ while a peer is choked before the peer is considered abusive and is
|
|||
disconnected.
|
||||
|
||||
|
||||
``recv_socket_buffer_size`` and ``send_socket_buffer_size`` specifies
|
||||
the buffer sizes set on peer sockets. 0 (which is the default) means
|
||||
the OS default (i.e. don't change the buffer sizes). The socket buffer
|
||||
sizes are changed using setsockopt() with SOL_SOCKET/SO_RCVBUF and
|
||||
SO_SNDBUFFER.
|
||||
|
||||
|
||||
pe_settings
|
||||
===========
|
||||
|
||||
|
|
|
@ -346,6 +346,7 @@ namespace libtorrent
|
|||
void dht_state_callback(boost::condition& c
|
||||
, entry& e, bool& done) const;
|
||||
void on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih);
|
||||
void setup_socket_buffers(socket_type& s);
|
||||
|
||||
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
// this pool is used to allocate and recycle send
|
||||
|
|
|
@ -161,6 +161,8 @@ namespace libtorrent
|
|||
, lock_disk_cache(true)
|
||||
#endif
|
||||
, max_rejects(50)
|
||||
, recv_socket_buffer_size(0)
|
||||
, send_socket_buffer_size(0)
|
||||
{}
|
||||
|
||||
// this is the user agent that will be sent to the tracker
|
||||
|
@ -534,6 +536,11 @@ namespace libtorrent
|
|||
// the number of times to reject requests while being
|
||||
// choked before disconnecting a peer for being malicious
|
||||
int max_rejects;
|
||||
|
||||
// sets the socket send and receive buffer sizes
|
||||
// 0 means OS default
|
||||
int recv_socket_buffer_size;
|
||||
int send_socket_buffer_size;
|
||||
};
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
|
|
@ -1006,6 +1006,8 @@ namespace aux {
|
|||
return;
|
||||
}
|
||||
|
||||
setup_socket_buffers(*s);
|
||||
|
||||
boost::intrusive_ptr<peer_connection> c(
|
||||
new bt_peer_connection(*this, s, endp, 0));
|
||||
#ifdef TORRENT_DEBUG
|
||||
|
@ -1019,6 +1021,23 @@ namespace aux {
|
|||
}
|
||||
}
|
||||
|
||||
void session_impl::setup_socket_buffers(socket_type& s)
|
||||
{
|
||||
error_code ec;
|
||||
if (m_settings.send_socket_buffer_size)
|
||||
{
|
||||
boost::asio::socket_base::send_buffer_size option(
|
||||
m_settings.send_socket_buffer_size);
|
||||
s.set_option(option, ec);
|
||||
}
|
||||
if (m_settings.recv_socket_buffer_size)
|
||||
{
|
||||
boost::asio::socket_base::receive_buffer_size option(
|
||||
m_settings.recv_socket_buffer_size);
|
||||
s.set_option(option, ec);
|
||||
}
|
||||
}
|
||||
|
||||
void session_impl::on_socks_accept(boost::shared_ptr<socket_type> const& s
|
||||
, error_code const& e)
|
||||
{
|
||||
|
|
|
@ -3519,6 +3519,8 @@ namespace libtorrent
|
|||
(void)ret;
|
||||
TORRENT_ASSERT(ret);
|
||||
|
||||
m_ses.setup_socket_buffers(*s);
|
||||
|
||||
boost::intrusive_ptr<peer_connection> c(new bt_peer_connection(
|
||||
m_ses, shared_from_this(), s, a, peerinfo));
|
||||
|
||||
|
|
Loading…
Reference in New Issue