From 261be677698d7dd1648db9078e9e36a719a16bd1 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Fri, 15 Jun 2007 22:30:39 +0000 Subject: [PATCH] add new lt files --- .../include/libtorrent/asio/ip/unicast.hpp | 70 +++++++++++ .../include/libtorrent/asio/ip/v6_only.hpp | 68 ++++++++++ .../include/libtorrent/asio/version.hpp | 23 ++++ .../include/libtorrent/disk_io_thread.hpp | 119 ++++++++++++++++++ .../include/libtorrent/intrusive_ptr_base.hpp | 71 +++++++++++ .../include/libtorrent/socks4_stream.hpp | 91 ++++++++++++++ src/core.py | 1 + src/interface.py | 1 - 8 files changed, 443 insertions(+), 1 deletion(-) create mode 100644 libtorrent/include/libtorrent/asio/ip/unicast.hpp create mode 100644 libtorrent/include/libtorrent/asio/ip/v6_only.hpp create mode 100644 libtorrent/include/libtorrent/asio/version.hpp create mode 100644 libtorrent/include/libtorrent/disk_io_thread.hpp create mode 100644 libtorrent/include/libtorrent/intrusive_ptr_base.hpp create mode 100644 libtorrent/include/libtorrent/socks4_stream.hpp diff --git a/libtorrent/include/libtorrent/asio/ip/unicast.hpp b/libtorrent/include/libtorrent/asio/ip/unicast.hpp new file mode 100644 index 000000000..ef065f298 --- /dev/null +++ b/libtorrent/include/libtorrent/asio/ip/unicast.hpp @@ -0,0 +1,70 @@ +// +// unicast.hpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef ASIO_IP_UNICAST_HPP +#define ASIO_IP_UNICAST_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include "asio/detail/push_options.hpp" + +#include "asio/detail/push_options.hpp" +#include +#include +#include "asio/detail/pop_options.hpp" + +#include "asio/ip/detail/socket_option.hpp" + +namespace asio { +namespace ip { +namespace unicast { + +/// Socket option for time-to-live associated with outgoing unicast packets. +/** + * Implements the IPPROTO_IP/IP_UNICAST_TTL socket option. + * + * @par Examples + * Setting the option: + * @code + * asio::ip::udp::socket socket(io_service); + * ... + * asio::ip::unicast::hops option(4); + * socket.set_option(option); + * @endcode + * + * @par + * Getting the current option value: + * @code + * asio::ip::udp::socket socket(io_service); + * ... + * asio::ip::unicast::hops option; + * socket.get_option(option); + * int ttl = option.value(); + * @endcode + * + * @par Concepts: + * GettableSocketOption, SettableSocketOption. + */ +#if defined(GENERATING_DOCUMENTATION) +typedef implementation_defined hops; +#else +typedef asio::ip::detail::socket_option::unicast_hops< + IPPROTO_IP, IP_TTL, IPPROTO_IPV6, IPV6_UNICAST_HOPS> hops; +#endif + +} // namespace unicast +} // namespace ip +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#endif // ASIO_IP_UNICAST_HPP diff --git a/libtorrent/include/libtorrent/asio/ip/v6_only.hpp b/libtorrent/include/libtorrent/asio/ip/v6_only.hpp new file mode 100644 index 000000000..8c3708139 --- /dev/null +++ b/libtorrent/include/libtorrent/asio/ip/v6_only.hpp @@ -0,0 +1,68 @@ +// +// v6_only.hpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef ASIO_IP_V6_ONLY_HPP +#define ASIO_IP_V6_ONLY_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include "asio/detail/push_options.hpp" + +#include "asio/detail/socket_option.hpp" + +namespace asio { +namespace ip { + +/// Socket option for determining whether an IPv6 socket supports IPv6 +/// communication only. +/** + * Implements the IPPROTO_IPV6/IP_V6ONLY socket option. + * + * @par Examples + * Setting the option: + * @code + * asio::ip::tcp::socket socket(io_service); + * ... + * asio::ip::v6_only option(true); + * socket.set_option(option); + * @endcode + * + * @par + * Getting the current option value: + * @code + * asio::ip::tcp::socket socket(io_service); + * ... + * asio::ip::v6_only option; + * socket.get_option(option); + * bool v6_only = option.value(); + * @endcode + * + * @par Concepts: + * GettableSocketOption, SettableSocketOption. + */ +#if defined(GENERATING_DOCUMENTATION) +typedef implementation_defined v6_only; +#elif defined(IPV6_V6ONLY) +typedef asio::detail::socket_option::boolean< + IPPROTO_IPV6, IPV6_V6ONLY> v6_only; +#else +typedef asio::detail::socket_option::boolean< + asio::detail::custom_socket_option_level, + asio::detail::always_fail_option> v6_only; +#endif + +} // namespace ip +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#endif // ASIO_IP_V6_ONLY_HPP diff --git a/libtorrent/include/libtorrent/asio/version.hpp b/libtorrent/include/libtorrent/asio/version.hpp new file mode 100644 index 000000000..82cf4e15a --- /dev/null +++ b/libtorrent/include/libtorrent/asio/version.hpp @@ -0,0 +1,23 @@ +// +// version.hpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef ASIO_VERSION_HPP +#define ASIO_VERSION_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +// ASIO_VERSION % 100 is the sub-minor version +// ASIO_VERSION / 100 % 1000 is the minor version +// ASIO_VERSION / 100000 is the major version +#define ASIO_VERSION 308 // 0.3.8 + +#endif // ASIO_VERSION_HPP diff --git a/libtorrent/include/libtorrent/disk_io_thread.hpp b/libtorrent/include/libtorrent/disk_io_thread.hpp new file mode 100644 index 000000000..aff0930e4 --- /dev/null +++ b/libtorrent/include/libtorrent/disk_io_thread.hpp @@ -0,0 +1,119 @@ +/* + +Copyright (c) 2007, Arvid Norberg +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "libtorrent/storage.hpp" +#include +#include +#include +#include +#include +#include +#include "libtorrent/config.hpp" + +namespace libtorrent +{ + + struct disk_io_job + { + disk_io_job() + : action(read) + , buffer(0) + , buffer_size(0) + , piece(0) + , offset(0) + {} + + enum action_t + { + read + , write + , hash + , move_storage + , release_files + }; + + action_t action; + + char* buffer; + size_type buffer_size; + boost::intrusive_ptr storage; + // arguments used for read and write + int piece, offset; + // used for move_storage. On errors, this is set + // to the error message + std::string str; + + // this is called when operation completes + boost::function callback; + }; + + // this is a singleton consisting of the thread and a queue + // of disk io jobs + struct disk_io_thread : boost::noncopyable + { + disk_io_thread(int block_size = 16 * 1024); + ~disk_io_thread(); + + // aborts read operations + void stop(boost::intrusive_ptr s); + void add_job(disk_io_job const& j + , boost::function const& f + = boost::function()); + + // keep track of the number of bytes in the job queue + // at any given time. i.e. the sum of all buffer_size. + // this is used to slow down the download global download + // speed when the queue buffer size is too big. + size_type queue_buffer_size() const + { return m_queue_buffer_size; } + + void operator()(); + + char* allocate_buffer(); + + private: + + boost::mutex m_mutex; + boost::condition m_signal; + bool m_abort; + std::deque m_jobs; + size_type m_queue_buffer_size; + + // memory pool for read and write operations + boost::pool<> m_pool; + + // thread for performing blocking disk io operations + boost::thread m_disk_io_thread; + }; + +} + diff --git a/libtorrent/include/libtorrent/intrusive_ptr_base.hpp b/libtorrent/include/libtorrent/intrusive_ptr_base.hpp new file mode 100644 index 000000000..a432bc350 --- /dev/null +++ b/libtorrent/include/libtorrent/intrusive_ptr_base.hpp @@ -0,0 +1,71 @@ +/* + +Copyright (c) 2007, Arvid Norberg +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef TORRENT_INTRUSIVE_PTR_BASE +#define TORRENT_INTRUSIVE_PTR_BASE + +#include +#include +#include "libtorrent/config.hpp" + +namespace libtorrent +{ + template + struct intrusive_ptr_base + { + friend void intrusive_ptr_add_ref(intrusive_ptr_base const* s) + { + assert(s->m_refs >= 0); + assert(s != 0); + ++s->m_refs; + } + + friend void intrusive_ptr_release(intrusive_ptr_base const* s) + { + assert(s->m_refs > 0); + assert(s != 0); + if (--s->m_refs == 0) + delete static_cast(s); + } + + int refcount() const { return m_refs; } + + intrusive_ptr_base(): m_refs(0) {} + private: + // reference counter for intrusive_ptr + mutable boost::detail::atomic_count m_refs; + }; + +} + +#endif + diff --git a/libtorrent/include/libtorrent/socks4_stream.hpp b/libtorrent/include/libtorrent/socks4_stream.hpp new file mode 100644 index 000000000..6110dbe4d --- /dev/null +++ b/libtorrent/include/libtorrent/socks4_stream.hpp @@ -0,0 +1,91 @@ +/* + +Copyright (c) 2007, Arvid Norberg +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef TORRENT_SOCKS4_STREAM_HPP_INCLUDED +#define TORRENT_SOCKS4_STREAM_HPP_INCLUDED + +#include "libtorrent/proxy_base.hpp" + +namespace libtorrent { + +class socks4_stream : public proxy_base +{ +public: + + explicit socks4_stream(asio::io_service& io_service) + : proxy_base(io_service) + {} + + void set_username(std::string const& user) + { + m_user = user; + } + + typedef boost::function handler_type; + + template + void async_connect(endpoint_type const& endpoint, Handler const& handler) + { + m_remote_endpoint = endpoint; + + // the connect is split up in the following steps: + // 1. resolve name of proxy server + // 2. connect to proxy server + // 3. send SOCKS4 CONNECT message + + // to avoid unnecessary copying of the handler, + // store it in a shaed_ptr + boost::shared_ptr h(new handler_type(handler)); + + tcp::resolver::query q(m_hostname + , boost::lexical_cast(m_port)); + m_resolver.async_resolve(q, boost::bind( + &socks4_stream::name_lookup, this, _1, _2, h)); + } + +private: + + void name_lookup(asio::error_code const& e, tcp::resolver::iterator i + , boost::shared_ptr h); + void connected(asio::error_code const& e, boost::shared_ptr h); + void handshake1(asio::error_code const& e, boost::shared_ptr h); + void handshake2(asio::error_code const& e, boost::shared_ptr h); + + // send and receive buffer + std::vector m_buffer; + // proxy authentication + std::string m_user; +}; + +} + +#endif diff --git a/src/core.py b/src/core.py index 276cbff9a..f29f3500f 100644 --- a/src/core.py +++ b/src/core.py @@ -446,6 +446,7 @@ class Manager: # altering max_active_torrents), or just from time to time # ___ALL queuing code should be in this function, and ONLY here___ def apply_queue(self, efficient = True): + print ("applying queue") # Handle autoseeding - downqueue as needed if self.get_pref('auto_seed_ratio') > 0: for unique_ID in self.unique_IDs: diff --git a/src/interface.py b/src/interface.py index 1cbd5d6c8..9d26f97aa 100644 --- a/src/interface.py +++ b/src/interface.py @@ -640,7 +640,6 @@ class DelugeGTK: def update(self): # We need to apply the queue changes self.manager.apply_queue() - # Make sure that the interface still exists try: tab = self.wtree.get_widget("torrent_info").get_current_page()