From 619c375528345dd75d420c099c5881f05fbf988d Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 19 Mar 2012 06:06:52 +0000 Subject: [PATCH] don't inline large functions --- include/libtorrent/create_torrent.hpp | 1 + include/libtorrent/file_storage.hpp | 7 +- include/libtorrent/http_parser.hpp | 1 + include/libtorrent/rss.hpp | 5 +- include/libtorrent/session_settings.hpp | 179 +---------------------- include/libtorrent/torrent_handle.hpp | 69 +-------- include/libtorrent/torrent_info.hpp | 16 +-- src/create_torrent.cpp | 2 + src/file_storage.cpp | 8 ++ src/http_parser.cpp | 2 + src/rss.cpp | 3 + src/session.cpp | 180 ++++++++++++++++++++++++ src/torrent_handle.cpp | 70 +++++++++ src/torrent_info.cpp | 17 +++ 14 files changed, 295 insertions(+), 265 deletions(-) diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index 14631be13..6df06b937 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -77,6 +77,7 @@ namespace libtorrent create_torrent(file_storage& fs, int piece_size = 0 , int pad_file_limit = -1, int flags = optimize); create_torrent(torrent_info const& ti); + ~create_torrent(); entry generate() const; file_storage const& files() const { return m_files; } diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 5f4184a3d..3b4c663a6 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -48,11 +48,8 @@ namespace libtorrent struct TORRENT_EXPORT file_entry { - file_entry(): offset(0), size(0), file_base(0) - , mtime(0), pad_file(false), hidden_attribute(false) - , executable_attribute(false) - , symlink_attribute(false) - {} + file_entry(); + ~file_entry(); std::string path; size_type offset; // the offset of this file inside the torrent diff --git a/include/libtorrent/http_parser.hpp b/include/libtorrent/http_parser.hpp index b230fe023..594033965 100644 --- a/include/libtorrent/http_parser.hpp +++ b/include/libtorrent/http_parser.hpp @@ -67,6 +67,7 @@ namespace libtorrent public: enum flags_t { dont_parse_chunks = 1 }; http_parser(int flags = 0); + ~http_parser(); std::string const& header(char const* key) const { static std::string empty; diff --git a/include/libtorrent/rss.hpp b/include/libtorrent/rss.hpp index 0a84f45dc..44a1947df 100644 --- a/include/libtorrent/rss.hpp +++ b/include/libtorrent/rss.hpp @@ -45,9 +45,10 @@ namespace libtorrent namespace aux { struct session_impl; } - struct feed_item + struct TORRENT_EXPORT feed_item { - feed_item(): size(-1) {} + feed_item(); + ~feed_item(); std::string url; std::string uuid; std::string title; diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index d2622d386..4e929680f 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -95,183 +95,8 @@ namespace libtorrent struct TORRENT_EXPORT session_settings { session_settings(std::string const& user_agent_ = "libtorrent/" - LIBTORRENT_VERSION) - : version(LIBTORRENT_VERSION_NUM) - , user_agent(user_agent_) - , tracker_completion_timeout(60) - , tracker_receive_timeout(40) - , stop_tracker_timeout(5) - , tracker_maximum_response_length(1024*1024) - , piece_timeout(20) - , request_timeout(50) - , request_queue_time(3) - , max_allowed_in_request_queue(250) - , max_out_request_queue(200) - , whole_pieces_threshold(20) - , peer_timeout(120) - , urlseed_timeout(20) - , urlseed_pipeline_size(5) - , urlseed_wait_retry(30) - , file_pool_size(40) - , allow_multiple_connections_per_ip(false) - , max_failcount(3) - , min_reconnect_time(60) - , peer_connect_timeout(15) - , ignore_limits_on_local_network(true) - , connection_speed(6) - , send_redundant_have(false) - , lazy_bitfields(true) - , inactivity_timeout(600) - , unchoke_interval(15) - , optimistic_unchoke_interval(30) - , num_want(200) - , initial_picker_threshold(4) - , allowed_fast_set_size(10) - , suggest_mode(no_piece_suggestions) - , max_queued_disk_bytes(1024 * 1024) - , max_queued_disk_bytes_low_watermark(0) - , handshake_timeout(10) -#ifndef TORRENT_DISABLE_DHT - , use_dht_as_fallback(false) -#endif - , free_torrent_hashes(true) - , upnp_ignore_nonrouters(false) - , send_buffer_low_watermark(512) - , send_buffer_watermark(500 * 1024) - , send_buffer_watermark_factor(50) -#ifndef TORRENT_NO_DEPRECATE - // deprecated in 0.16 - , auto_upload_slots(true) - , auto_upload_slots_rate_based(true) -#endif - , choking_algorithm(fixed_slots_choker) - , seed_choking_algorithm(round_robin) - , use_parole_mode(true) - , cache_size(1024) - , cache_buffer_chunk_size(16) - , cache_expiry(300) - , use_read_cache(true) - , explicit_read_cache(0) - , explicit_cache_interval(30) - , disk_io_write_mode(0) - , disk_io_read_mode(0) - , coalesce_reads(false) - , coalesce_writes(false) - , outgoing_ports(0,0) - , peer_tos(0) - , active_downloads(3) - , active_seeds(5) - , active_dht_limit(88) // don't announce more than once every 40 seconds - , active_tracker_limit(360) // don't announce to trackers more than once every 5 seconds - , active_lsd_limit(60) // don't announce to local network more than once every 5 seconds - , active_limit(15) - , auto_manage_prefer_seeds(false) - , dont_count_slow_torrents(true) - , auto_manage_interval(30) - , share_ratio_limit(2.f) - , seed_time_ratio_limit(7.f) - , seed_time_limit(24 * 60 * 60) // 24 hours - , peer_turnover_interval(300) - , peer_turnover(2 / 50.f) - , peer_turnover_cutoff(.9f) - , close_redundant_connections(true) - , auto_scrape_interval(1800) - , auto_scrape_min_interval(300) - , max_peerlist_size(4000) - , max_paused_peerlist_size(4000) - , min_announce_interval(5 * 60) - , prioritize_partial_pieces(false) - , auto_manage_startup(120) - , rate_limit_ip_overhead(true) - , announce_to_all_trackers(false) - , announce_to_all_tiers(false) - , prefer_udp_trackers(true) - , strict_super_seeding(false) - , seeding_piece_quota(20) -#ifdef TORRENT_WINDOWS - , max_sparse_regions(30000) -#else - , max_sparse_regions(0) -#endif -#ifndef TORRENT_DISABLE_MLOCK - , lock_disk_cache(false) -#endif - , max_rejects(50) - , recv_socket_buffer_size(0) - , send_socket_buffer_size(0) - , optimize_hashing_for_speed(true) - , file_checks_delay_per_block(0) - , disk_cache_algorithm(avoid_readback) - , read_cache_line_size(32) - , write_cache_line_size(32) - , optimistic_disk_retry(10 * 60) - , disable_hash_checks(false) - , allow_reordered_disk_operations(true) - , allow_i2p_mixed(false) - , max_suggest_pieces(10) - , drop_skipped_requests(false) - , low_prio_disk(true) - , local_service_announce_interval(5 * 60) - , dht_announce_interval(15 * 60) - , udp_tracker_token_expiry(60) - , volatile_read_cache(false) - , guided_read_cache(false) - , default_cache_min_age(1) - , num_optimistic_unchoke_slots(0) - , no_atime_storage(true) - , default_est_reciprocation_rate(16000) - , increase_est_reciprocation_rate(20) - , decrease_est_reciprocation_rate(3) - , incoming_starts_queued_torrents(false) - , report_true_downloaded(false) - , strict_end_game_mode(true) - , broadcast_lsd(true) - , enable_outgoing_utp(true) - , enable_incoming_utp(true) - , enable_outgoing_tcp(true) - , enable_incoming_tcp(true) - , max_pex_peers(50) - , ignore_resume_timestamps(false) - , no_recheck_incomplete_resume(false) - , anonymous_mode(false) - , tick_interval(100) - , report_web_seed_downloads(true) - , share_mode_target(3) - , upload_rate_limit(0) - , download_rate_limit(0) - , local_upload_rate_limit(0) - , local_download_rate_limit(0) - , dht_upload_rate_limit(4000) - , unchoke_slots_limit(8) - , half_open_limit(0) - , connections_limit(200) - , utp_target_delay(100) // milliseconds - , utp_gain_factor(1500) // bytes per rtt - , utp_min_timeout(500) // milliseconds - , utp_syn_resends(2) - , utp_fin_resends(2) - , utp_num_resends(6) - , utp_connect_timeout(3000) // milliseconds - , utp_delayed_ack(0) // milliseconds - , utp_dynamic_sock_buf(true) - , utp_loss_multiplier(50) // specified in percent - , mixed_mode_algorithm(peer_proportional) - , rate_limit_utp(false) - , listen_queue_size(5) - , announce_double_nat(false) - , torrent_connect_boost(10) - , seeding_outgoing_connections(true) - , no_connect_privileged_ports(true) - , alert_queue_size(1000) - , max_metadata_size(3*1024*1024) - , smooth_connects(true) - , always_send_user_agent(false) - , apply_ip_filter_to_trackers(true) - , read_job_every(10) - , use_disk_read_ahead(true) - , lock_files(false) - , ssl_listen(4433) - {} + LIBTORRENT_VERSION); + ~session_settings(); // libtorrent version. Used for forward binary compatibility int version; diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 48dab2738..b900318ef 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -433,73 +433,8 @@ namespace libtorrent struct TORRENT_EXPORT torrent_status { - torrent_status() - : state(checking_resume_data) - , paused(false) - , auto_managed(false) - , sequential_download(false) - , is_seeding(false) - , is_finished(false) - , has_metadata(false) - , progress(0.f) - , progress_ppm(0) - , total_download(0) - , total_upload(0) - , total_payload_download(0) - , total_payload_upload(0) - , total_failed_bytes(0) - , total_redundant_bytes(0) - , download_rate(0) - , upload_rate(0) - , download_payload_rate(0) - , upload_payload_rate(0) - , num_seeds(0) - , num_peers(0) - , num_complete(-1) - , num_incomplete(-1) - , list_seeds(0) - , list_peers(0) - , connect_candidates(0) - , num_pieces(0) - , total_done(0) - , total_wanted_done(0) - , total_wanted(0) - , distributed_full_copies(0) - , distributed_fraction(0) - , distributed_copies(0.f) - , block_size(0) - , num_uploads(0) - , num_connections(0) - , uploads_limit(0) - , connections_limit(0) - , storage_mode(storage_mode_sparse) - , up_bandwidth_queue(0) - , down_bandwidth_queue(0) - , all_time_upload(0) - , all_time_download(0) - , active_time(0) - , finished_time(0) - , seeding_time(0) - , seed_rank(0) - , last_scrape(0) - , has_incoming(false) - , sparse_regions(0) - , seed_mode(false) - , upload_mode(false) - , share_mode(false) - , super_seeding(false) - , priority(0) - , added_time(0) - , completed_time(0) - , last_seen_complete(0) - , time_since_upload(0) - , time_since_download(0) - , queue_position(0) - , need_save_resume(false) - , ip_filter_applies(true) - , info_hash(0) - , listen_port(0) - {} + torrent_status(); + ~torrent_status(); bool operator==(torrent_status const& st) const { return handle == st.handle; } diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 1acc1380b..2fd009134 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -74,20 +74,8 @@ namespace libtorrent struct TORRENT_EXPORT announce_entry { - announce_entry(std::string const& u) - : url(u) - , next_announce(min_time()) - , min_announce(min_time()) - , tier(0) - , fail_limit(0) - , fails(0) - , updating(false) - , source(0) - , verified(false) - , start_sent(false) - , complete_sent(false) - , send_stats(true) - {} + announce_entry(std::string const& u); + ~announce_entry(); // tracker URL as it appeared in the torrent file std::string url; diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 0d29a6e8f..7fef0068b 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -220,6 +220,8 @@ namespace libtorrent } } + create_torrent::~create_torrent() {} + create_torrent::create_torrent(file_storage& fs, int piece_size, int pad_file_limit, int flags) : m_files(fs) , m_creation_date(time(0)) diff --git a/src/file_storage.cpp b/src/file_storage.cpp index 3942bd1d3..81a3d9f79 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -96,6 +96,14 @@ namespace libtorrent } } + file_entry::file_entry(): offset(0), size(0), file_base(0) + , mtime(0), pad_file(false), hidden_attribute(false) + , executable_attribute(false) + , symlink_attribute(false) + {} + + file_entry::~file_entry() {} + internal_file_entry::~internal_file_entry() { if (name_len == 0) free((void*)name); } internal_file_entry::internal_file_entry(internal_file_entry const& fe) diff --git a/src/http_parser.cpp b/src/http_parser.cpp index 64043cb98..6ff00cc4e 100644 --- a/src/http_parser.cpp +++ b/src/http_parser.cpp @@ -60,6 +60,8 @@ namespace libtorrent && http_status < 400; } + http_parser::~http_parser() {} + http_parser::http_parser(int flags) : m_recv_pos(0) , m_status_code(-1) diff --git a/src/rss.cpp b/src/rss.cpp index f0a002f13..1a6f69f85 100644 --- a/src/rss.cpp +++ b/src/rss.cpp @@ -46,6 +46,9 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { +feed_item::feed_item(): size(-1) {} +feed_item::~feed_item() {} + struct feed_state { feed_state(feed& r) diff --git a/src/session.cpp b/src/session.cpp index ab6283858..8a08d04db 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -1099,5 +1099,185 @@ namespace libtorrent { return m_impl->m_half_open; } + + session_settings::session_settings(std::string const& user_agent_) + : version(LIBTORRENT_VERSION_NUM) + , user_agent(user_agent_) + , tracker_completion_timeout(60) + , tracker_receive_timeout(40) + , stop_tracker_timeout(5) + , tracker_maximum_response_length(1024*1024) + , piece_timeout(20) + , request_timeout(50) + , request_queue_time(3) + , max_allowed_in_request_queue(250) + , max_out_request_queue(200) + , whole_pieces_threshold(20) + , peer_timeout(120) + , urlseed_timeout(20) + , urlseed_pipeline_size(5) + , urlseed_wait_retry(30) + , file_pool_size(40) + , allow_multiple_connections_per_ip(false) + , max_failcount(3) + , min_reconnect_time(60) + , peer_connect_timeout(15) + , ignore_limits_on_local_network(true) + , connection_speed(6) + , send_redundant_have(false) + , lazy_bitfields(true) + , inactivity_timeout(600) + , unchoke_interval(15) + , optimistic_unchoke_interval(30) + , num_want(200) + , initial_picker_threshold(4) + , allowed_fast_set_size(10) + , suggest_mode(no_piece_suggestions) + , max_queued_disk_bytes(1024 * 1024) + , max_queued_disk_bytes_low_watermark(0) + , handshake_timeout(10) +#ifndef TORRENT_DISABLE_DHT + , use_dht_as_fallback(false) +#endif + , free_torrent_hashes(true) + , upnp_ignore_nonrouters(false) + , send_buffer_low_watermark(512) + , send_buffer_watermark(500 * 1024) + , send_buffer_watermark_factor(50) +#ifndef TORRENT_NO_DEPRECATE + // deprecated in 0.16 + , auto_upload_slots(true) + , auto_upload_slots_rate_based(true) +#endif + , choking_algorithm(fixed_slots_choker) + , seed_choking_algorithm(round_robin) + , use_parole_mode(true) + , cache_size(1024) + , cache_buffer_chunk_size(16) + , cache_expiry(300) + , use_read_cache(true) + , explicit_read_cache(0) + , explicit_cache_interval(30) + , disk_io_write_mode(0) + , disk_io_read_mode(0) + , coalesce_reads(false) + , coalesce_writes(false) + , outgoing_ports(0,0) + , peer_tos(0) + , active_downloads(3) + , active_seeds(5) + , active_dht_limit(88) // don't announce more than once every 40 seconds + , active_tracker_limit(360) // don't announce to trackers more than once every 5 seconds + , active_lsd_limit(60) // don't announce to local network more than once every 5 seconds + , active_limit(15) + , auto_manage_prefer_seeds(false) + , dont_count_slow_torrents(true) + , auto_manage_interval(30) + , share_ratio_limit(2.f) + , seed_time_ratio_limit(7.f) + , seed_time_limit(24 * 60 * 60) // 24 hours + , peer_turnover_interval(300) + , peer_turnover(2 / 50.f) + , peer_turnover_cutoff(.9f) + , close_redundant_connections(true) + , auto_scrape_interval(1800) + , auto_scrape_min_interval(300) + , max_peerlist_size(4000) + , max_paused_peerlist_size(4000) + , min_announce_interval(5 * 60) + , prioritize_partial_pieces(false) + , auto_manage_startup(120) + , rate_limit_ip_overhead(true) + , announce_to_all_trackers(false) + , announce_to_all_tiers(false) + , prefer_udp_trackers(true) + , strict_super_seeding(false) + , seeding_piece_quota(20) +#ifdef TORRENT_WINDOWS + , max_sparse_regions(30000) +#else + , max_sparse_regions(0) +#endif +#ifndef TORRENT_DISABLE_MLOCK + , lock_disk_cache(false) +#endif + , max_rejects(50) + , recv_socket_buffer_size(0) + , send_socket_buffer_size(0) + , optimize_hashing_for_speed(true) + , file_checks_delay_per_block(0) + , disk_cache_algorithm(avoid_readback) + , read_cache_line_size(32) + , write_cache_line_size(32) + , optimistic_disk_retry(10 * 60) + , disable_hash_checks(false) + , allow_reordered_disk_operations(true) + , allow_i2p_mixed(false) + , max_suggest_pieces(10) + , drop_skipped_requests(false) + , low_prio_disk(true) + , local_service_announce_interval(5 * 60) + , dht_announce_interval(15 * 60) + , udp_tracker_token_expiry(60) + , volatile_read_cache(false) + , guided_read_cache(false) + , default_cache_min_age(1) + , num_optimistic_unchoke_slots(0) + , no_atime_storage(true) + , default_est_reciprocation_rate(16000) + , increase_est_reciprocation_rate(20) + , decrease_est_reciprocation_rate(3) + , incoming_starts_queued_torrents(false) + , report_true_downloaded(false) + , strict_end_game_mode(true) + , broadcast_lsd(true) + , enable_outgoing_utp(true) + , enable_incoming_utp(true) + , enable_outgoing_tcp(true) + , enable_incoming_tcp(true) + , max_pex_peers(50) + , ignore_resume_timestamps(false) + , no_recheck_incomplete_resume(false) + , anonymous_mode(false) + , tick_interval(100) + , report_web_seed_downloads(true) + , share_mode_target(3) + , upload_rate_limit(0) + , download_rate_limit(0) + , local_upload_rate_limit(0) + , local_download_rate_limit(0) + , dht_upload_rate_limit(4000) + , unchoke_slots_limit(8) + , half_open_limit(0) + , connections_limit(200) + , utp_target_delay(100) // milliseconds + , utp_gain_factor(1500) // bytes per rtt + , utp_min_timeout(500) // milliseconds + , utp_syn_resends(2) + , utp_fin_resends(2) + , utp_num_resends(6) + , utp_connect_timeout(3000) // milliseconds + , utp_delayed_ack(0) // milliseconds + , utp_dynamic_sock_buf(true) + , utp_loss_multiplier(50) // specified in percent + , mixed_mode_algorithm(peer_proportional) + , rate_limit_utp(false) + , listen_queue_size(5) + , announce_double_nat(false) + , torrent_connect_boost(10) + , seeding_outgoing_connections(true) + , no_connect_privileged_ports(true) + , alert_queue_size(1000) + , max_metadata_size(3*1024*1024) + , smooth_connects(true) + , always_send_user_agent(false) + , apply_ip_filter_to_trackers(true) + , read_job_every(10) + , use_disk_read_ahead(true) + , lock_files(false) + , ssl_listen(4433) + {} + + session_settings::~session_settings() {} } diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index a9d499c62..d921c65d2 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -76,6 +76,76 @@ using libtorrent::aux::session_impl; namespace libtorrent { + torrent_status::torrent_status() + : state(checking_resume_data) + , paused(false) + , auto_managed(false) + , sequential_download(false) + , is_seeding(false) + , is_finished(false) + , has_metadata(false) + , progress(0.f) + , progress_ppm(0) + , total_download(0) + , total_upload(0) + , total_payload_download(0) + , total_payload_upload(0) + , total_failed_bytes(0) + , total_redundant_bytes(0) + , download_rate(0) + , upload_rate(0) + , download_payload_rate(0) + , upload_payload_rate(0) + , num_seeds(0) + , num_peers(0) + , num_complete(-1) + , num_incomplete(-1) + , list_seeds(0) + , list_peers(0) + , connect_candidates(0) + , num_pieces(0) + , total_done(0) + , total_wanted_done(0) + , total_wanted(0) + , distributed_full_copies(0) + , distributed_fraction(0) + , distributed_copies(0.f) + , block_size(0) + , num_uploads(0) + , num_connections(0) + , uploads_limit(0) + , connections_limit(0) + , storage_mode(storage_mode_sparse) + , up_bandwidth_queue(0) + , down_bandwidth_queue(0) + , all_time_upload(0) + , all_time_download(0) + , active_time(0) + , finished_time(0) + , seeding_time(0) + , seed_rank(0) + , last_scrape(0) + , has_incoming(false) + , sparse_regions(0) + , seed_mode(false) + , upload_mode(false) + , share_mode(false) + , super_seeding(false) + , priority(0) + , added_time(0) + , completed_time(0) + , last_seen_complete(0) + , time_since_upload(0) + , time_since_download(0) + , queue_position(0) + , need_save_resume(false) + , ip_filter_applies(true) + , info_hash(0) + , listen_port(0) + {} + + torrent_status::~torrent_status() {} + template void fun_ret(R* ret, bool* done, condition* e, mutex* m, boost::function f) { diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 0b29b4e50..91a157b7c 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -447,6 +447,23 @@ namespace libtorrent return 0; } + announce_entry::announce_entry(std::string const& u) + : url(u) + , next_announce(min_time()) + , min_announce(min_time()) + , tier(0) + , fail_limit(0) + , fails(0) + , updating(false) + , source(0) + , verified(false) + , start_sent(false) + , complete_sent(false) + , send_stats(true) + {} + + announce_entry::~announce_entry() {} + int announce_entry::next_announce_in() const { return total_seconds(next_announce - time_now()); }