⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 session_impl.hpp

📁 LINUX下
💻 HPP
📖 第 1 页 / 共 2 页
字号:
			{ m_dht_proxy = s; }			proxy_settings const& dht_proxy() const			{ return m_dht_proxy; }#endif#ifdef TORRENT_STATS			void log_buffer_usage()			{				int send_buffer_capacity = 0;				int used_send_buffer = 0;				for (connection_map::const_iterator i = m_connections.begin()					, end(m_connections.end()); i != end; ++i)				{					send_buffer_capacity += (*i)->send_buffer_capacity();					used_send_buffer += (*i)->send_buffer_size();				}				TORRENT_ASSERT(send_buffer_capacity >= used_send_buffer);				m_buffer_usage_logger << log_time() << " send_buffer_size: " << send_buffer_capacity << std::endl;				m_buffer_usage_logger << log_time() << " used_send_buffer: " << used_send_buffer << std::endl;				m_buffer_usage_logger << log_time() << " send_buffer_utilization: "					<< (used_send_buffer * 100.f / send_buffer_capacity) << std::endl;			}#endif			void start_lsd();			void start_natpmp();			void start_upnp();			void stop_lsd();			void stop_natpmp();			void stop_upnp();			// handles delayed alerts			alert_manager m_alerts;			std::pair<char*, int> allocate_buffer(int size);			void free_buffer(char* buf, int size);			void free_disk_buffer(char* buf);						address m_external_address;//		private:			void on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih);			// this pool is used to allocate and recycle send			// buffers from.			boost::pool<> m_send_buffers;			boost::mutex m_send_buffer_mutex;			// the file pool that all storages in this session's			// torrents uses. It sets a limit on the number of			// open files by this session.			// file pool must be destructed after the torrents			// since they will still have references to it			// when they are destructed.			file_pool m_files;			// handles disk io requests asynchronously			// peers have pointers into the disk buffer			// pool, and must be destructed before this			// object. The disk thread relies on the file			// pool object, and must be destructed before			// m_files.			disk_io_thread m_disk_thread;			// this is where all active sockets are stored.			// the selector can sleep while there's no activity on			// them			io_service m_io_service;			asio::strand m_strand;			// this is a list of half-open tcp connections			// (only outgoing connections)			// this has to be one of the last			// members to be destructed			connection_queue m_half_open;			// the bandwidth manager is responsible for			// handing out bandwidth to connections that			// asks for it, it can also throttle the			// rate.			bandwidth_manager<peer_connection, torrent> m_download_channel;			bandwidth_manager<peer_connection, torrent> m_upload_channel;			bandwidth_manager<peer_connection, torrent>* m_bandwidth_manager[2];			tracker_manager m_tracker_manager;			torrent_map m_torrents;			// this maps sockets to their peer_connection			// object. It is the complete list of all connected			// peers.			connection_map m_connections;						// filters incoming connections			ip_filter m_ip_filter;			// filters outgoing connections			port_filter m_port_filter;						// the peer id that is generated at the start of the session			peer_id m_peer_id;			// the key is an id that is used to identify the			// client with the tracker only. It is randomized			// at startup			int m_key;			// the number of retries we make when binding the			// listen socket. For each retry the port number			// is incremented by one			int m_listen_port_retries;			// the ip-address of the interface			// we are supposed to listen on.			// if the ip is set to zero, it means			// that we should let the os decide which			// interface to listen on			tcp::endpoint m_listen_interface;			// if we're listening on an IPv6 interface			// this is one of the non local IPv6 interfaces			// on this machine			tcp::endpoint m_ipv6_interface;						struct listen_socket_t			{				listen_socket_t(): external_port(0) {}				// this is typically set to the same as the local				// listen port. In case a NAT port forward was				// successfully opened, this will be set to the				// port that is open on the external (NAT) interface				// on the NAT box itself. This is the port that has				// to be published to peers, since this is the port				// the client is reachable through.				int external_port;				// the actual socket				boost::shared_ptr<socket_acceptor> sock;			};			// since we might be listening on multiple interfaces			// we might need more than one listen socket			std::list<listen_socket_t> m_listen_sockets;			listen_socket_t setup_listener(tcp::endpoint ep, int retries, bool v6_only = false);			// the settings for the client			session_settings m_settings;			// the proxy settings for different			// kinds of connections			proxy_settings m_peer_proxy;			proxy_settings m_web_seed_proxy;			proxy_settings m_tracker_proxy;#ifndef TORRENT_DISABLE_DHT			proxy_settings m_dht_proxy;#endif			// set to true when the session object			// is being destructed and the thread			// should exit			volatile bool m_abort;			int m_max_uploads;			int m_max_connections;			// the number of unchoked peers			int m_num_unchoked;			// this is initialized to the unchoke_interval			// session_setting and decreased every second.			// when it reaches zero, it is reset to the			// unchoke_interval and the unchoke set is			// recomputed.			int m_unchoke_time_scaler;			// works like unchoke_time_scaler but it			// is only decresed when the unchoke set			// is recomputed, and when it reaches zero,			// the optimistic unchoke is moved to another peer.			int m_optimistic_unchoke_time_scaler;			// works like unchoke_time_scaler. Each time			// it reaches 0, and all the connections are			// used, the worst connection will be disconnected			// from the torrent with the most peers			int m_disconnect_time_scaler;			// statistics gathered from all torrents.			stat m_stat;			// is false by default and set to true when			// the first incoming connection is established			// this is used to know if the client is behind			// NAT or not.			bool m_incoming_connection;						void second_tick(asio::error_code const& e);			ptime m_last_tick;#ifndef TORRENT_DISABLE_DHT			boost::intrusive_ptr<dht::dht_tracker> m_dht;			dht_settings m_dht_settings;			// if this is set to true, the dht listen port			// will be set to the same as the tcp listen port			// and will be synchronlized with it as it changes			// it defaults to true			bool m_dht_same_port;						// see m_external_listen_port. This is the same			// but for the udp port used by the DHT.			int m_external_udp_port;#endif#ifndef TORRENT_DISABLE_ENCRYPTION			pe_settings m_pe_settings;#endif			boost::intrusive_ptr<natpmp> m_natpmp;			boost::intrusive_ptr<upnp> m_upnp;			boost::intrusive_ptr<lsd> m_lsd;			// the timer used to fire the second_tick			deadline_timer m_timer;			// the index of the torrent that will be offered to			// connect to a peer next time second_tick is called.			// This implements a round robin.			int m_next_connect_torrent;#ifndef NDEBUG			void check_invariant() const;#endif#ifdef TORRENT_STATS			// logger used to write bandwidth usage statistics			std::ofstream m_stats_logger;			int m_second_counter;			// used to log send buffer usage statistics			std::ofstream m_buffer_usage_logger;			// the number of send buffers that are allocated			int m_buffer_allocations;#endif#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)			boost::shared_ptr<logger> create_log(std::string const& name				, int instance, bool append = true);						// this list of tracker loggers serves as tracker_callbacks when			// shutting down. This list is just here to keep them alive during			// whe shutting down process			std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;			fs::path m_logpath;		public:			boost::shared_ptr<logger> m_logger;		private:#endif#ifndef TORRENT_DISABLE_EXTENSIONS			typedef std::list<boost::function<boost::shared_ptr<				torrent_plugin>(torrent*, void*)> > extension_list_t;			extension_list_t m_extensions;#endif			// data shared between the main thread			// and the checker thread			checker_impl m_checker_impl;			// the main working thread			boost::scoped_ptr<boost::thread> m_thread;			// the thread that calls initialize_pieces()			// on all torrents before they start downloading			boost::scoped_ptr<boost::thread> m_checker_thread;		};		#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)		struct tracker_logger : request_callback		{			tracker_logger(session_impl& ses): m_ses(ses) {}			void tracker_warning(std::string const& str)			{				debug_log("*** tracker warning: " + str);			}			void tracker_response(tracker_request const&				, std::vector<peer_entry>& peers				, int interval				, int complete				, int incomplete)			{				std::stringstream s;				s << "TRACKER RESPONSE:\n"					"interval: " << interval << "\n"					"peers:\n";				for (std::vector<peer_entry>::const_iterator i = peers.begin();					i != peers.end(); ++i)				{					s << "  " << std::setfill(' ') << std::setw(16) << i->ip						<< " " << std::setw(5) << std::dec << i->port << "  ";					if (!i->pid.is_all_zeros()) s << " " << i->pid;					s << "\n";				}				debug_log(s.str());			}			void tracker_request_timed_out(				tracker_request const&)			{				debug_log("*** tracker timed out");			}			void tracker_request_error(				tracker_request const&				, int response_code				, const std::string& str)			{				debug_log(std::string("*** tracker error: ")					+ boost::lexical_cast<std::string>(response_code) + ": "					+ str);			}						void debug_log(const std::string& line)			{				(*m_ses.m_logger) << time_now_string() << " " << line << "\n";			}			session_impl& m_ses;		};#endif	}}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -