From 5b830854063fc7221ee3c60ee11ecf5b92795f4a Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 27 Jan 2018 03:17:20 +0100 Subject: [PATCH 1/3] fix openssl download links in appveyor script --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8da11c667..c762a5e5a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -39,7 +39,7 @@ install: - if %compiler% == msvc-12.0 ( if not exist openssl-1.0.1p-vs2013.7z ( echo downloading openssl-2013 - & appveyor DownloadFile "http://www.npcglib.org/~stathis/downloads/openssl-1.0.1p-vs2013.7z" + & appveyor DownloadFile "https://www.npcglib.org/~stathis/downloads/openssl-1.0.1p-vs2013.7z" ) ) - if %compiler% == msvc-12.0 ( @@ -54,7 +54,7 @@ install: - if %compiler% == msvc-10.0 ( if not exist openssl-1.0.1p-vs2010.7z ( echo downloading openssl-2010 - & appveyor DownloadFile "http://www.npcglib.org/~stathis/downloads/openssl-1.0.1p-vs2010.7z" + & appveyor DownloadFile "https://www.npcglib.org/~stathis/downloads/openssl-1.0.1p-vs2010.7z" ) ) - if %compiler% == msvc-10.0 ( @@ -69,7 +69,7 @@ install: - if %compiler% == msvc-14.0 ( if not exist openssl-1.0.1p-vs2015.7z ( echo downloading openssl-2015 - & appveyor DownloadFile "http://www.npcglib.org/~stathis/downloads/openssl-1.0.1p-vs2015.7z" + & appveyor DownloadFile "https://www.npcglib.org/~stathis/downloads/openssl-1.0.1p-vs2015.7z" ) ) - if %compiler% == msvc-14.0 ( From cc93f8f3a7a53198a308ace867544105186e9d61 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 22 Jan 2018 00:06:35 +0100 Subject: [PATCH 2/3] add switch to create pad files in test torrents in connection-tester --- examples/connection_tester.cpp | 16 ++++++++++------ include/libtorrent/create_torrent.hpp | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/connection_tester.cpp b/examples/connection_tester.cpp index a820bac4e..5b5d34e09 100644 --- a/examples/connection_tester.cpp +++ b/examples/connection_tester.cpp @@ -726,6 +726,8 @@ void print_usage() " options for this command:\n" " -s the size of the torrent in megabytes\n" " -n the number of files in the test torrent\n" + " -a introduce a lot of pad-files\n" + " (pad files are not supported for gen-data or upload)\n" " -t the file to save the .torrent file to\n" " -T the name of the torrent (and directory\n" " its files are saved in)\n\n" @@ -775,13 +777,12 @@ void hasher_thread(libtorrent::create_torrent* t, int start_piece, int end_piece } // size is in megabytes -void generate_torrent(std::vector& buf, int size, int num_files - , char const* torrent_name) +void generate_torrent(std::vector& buf, int num_pieces, int num_files + , char const* torrent_name, bool with_padding) { file_storage fs; // 1 MiB piece size const int piece_size = 1024 * 1024; - const int num_pieces = size; const boost::int64_t total_size = boost::int64_t(piece_size) * num_pieces; boost::int64_t s = total_size; @@ -797,8 +798,9 @@ void generate_torrent(std::vector& buf, int size, int num_files file_size += 200; } -// fs.add_file("stress_test_file", total_size); - libtorrent::create_torrent t(fs, piece_size); + libtorrent::create_torrent t(fs, piece_size, with_padding ? 100 : -1); + + num_pieces = t.num_pieces(); // generate the hashes in 4 threads thread t1(boost::bind(&hasher_thread, &t, 0, 1 * num_pieces / 4, piece_size, false)); @@ -872,6 +874,7 @@ int main(int argc, char* argv[]) char const* destination_ip = "127.0.0.1"; int destination_port = 6881; int churn = 0; + bool gen_pad_files = false; argv += 2; argc -= 2; @@ -892,6 +895,7 @@ int main(int argc, char* argv[]) switch (optname[1]) { case 'C': test_corruption = true; continue; + case 'a': gen_pad_files = true; continue; } if (argc == 0) @@ -926,7 +930,7 @@ int main(int argc, char* argv[]) name = name.substr(0, name.find_last_of('.')); printf("generating torrent: %s\n", name.c_str()); generate_torrent(tmp, size ? size : 1024, num_files ? num_files : 1 - , name.c_str()); + , name.c_str(), gen_pad_files); FILE* output = stdout; if (strcmp("-", torrent_file) != 0) diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index 43c37a2d2..032992cec 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -151,7 +151,7 @@ namespace libtorrent // be a multiple of 16 kiB. If a piece size of 0 is specified, a // piece_size will be calculated such that the torrent file is roughly 40 kB. // - // If a ``pad_size_limit`` is specified (other than -1), any file larger than + // If a ``pad_file_limit`` is specified (other than -1), any file larger than // the specified number of bytes will be preceded by a pad file to align it // with the start of a piece. The pad_file_limit is ignored unless the // ``optimize_alignment`` flag is passed. Typically it doesn't make sense From fa03cbea9b8e01911ec8321b24d0ed5ad141fe6f Mon Sep 17 00:00:00 2001 From: d-komarov Date: Sat, 27 Jan 2018 02:48:22 +0200 Subject: [PATCH 3/3] Revise torrent state update * Remove unused m_in_state_updates * Update m_state_subscription comments --- include/libtorrent/torrent.hpp | 10 ++-------- src/torrent.cpp | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index c1c41e4ae..cc1ad2eed 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -260,8 +260,8 @@ namespace libtorrent // m_allow_peers is also false. bool m_graceful_pause_mode:1; - // state subscription. If set, a pointer to this torrent - // will be added to the m_state_updates set in session_impl + // state subscription. If set, a pointer to this torrent will be added + // to the session_impl::m_torrent_lists[torrent_state_updates] // whenever this torrent's state changes (any state). bool m_state_subscription:1; @@ -1625,16 +1625,10 @@ namespace libtorrent // is optional and may be 0xffffff boost::uint32_t m_incomplete:24; - // true when the torrent should announce to // the DHT bool m_announce_to_dht:1; - // in state_updates list. When adding a torrent to the - // session_impl's m_state_update list, this bit is set - // to never add the same torrent twice - bool m_in_state_updates:1; - // these represent whether or not this torrent is counted // in the total counters of active seeds and downloads // in the session. diff --git a/src/torrent.cpp b/src/torrent.cpp index 16407d659..1fd5ada27 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -276,7 +276,6 @@ namespace libtorrent , m_padding(0) , m_incomplete(0xffffff) , m_announce_to_dht((p.flags & add_torrent_params::flag_paused) == 0) - , m_in_state_updates(false) , m_is_active_download(false) , m_is_active_finished(false) , m_ssl_torrent(false)