don't use internal functions in connection_tester (#1172)

This commit is contained in:
Arvid Norberg 2016-10-02 21:17:14 -07:00 committed by GitHub
parent cebd976cc2
commit a057e22e90
1 changed files with 8 additions and 3 deletions

View File

@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/hasher.hpp"
#include "libtorrent/socket_io.hpp"
#include "libtorrent/file_pool.hpp"
#include "libtorrent/random.hpp"
#include <random>
#include <cstring>
#include <thread>
#include <functional>
@ -148,6 +148,11 @@ std::string leaf_path(std::string f)
return std::string(sep + 1);
}
namespace {
std::random_device dev;
std::mt19937 rng(dev());
}
struct peer_conn
{
peer_conn(io_service& ios, int num_pieces, int blocks_pp, tcp::endpoint const& ep
@ -554,7 +559,7 @@ struct peer_conn
pieces.resize(num_pieces);
for (int i = 0; i < int(pieces.size()); ++i)
pieces[i] = i;
aux::random_shuffle(pieces.begin(), pieces.end());
std::shuffle(pieces.begin(), pieces.end(), rng);
}
else if (msg == 4) // have
{
@ -578,7 +583,7 @@ struct peer_conn
}
++ptr;
}
aux::random_shuffle(pieces.begin(), pieces.end());
std::shuffle(pieces.begin(), pieces.end(), rng);
}
else if (msg == 7) // piece
{