forked from premiere/premiere-libtorrent
fix division by zero when setting tick_interval > 1000
This commit is contained in:
parent
3db77ccf31
commit
39866c2306
|
@ -1,3 +1,4 @@
|
||||||
|
* fix division by zero when setting tick_interval > 1000
|
||||||
* fix move_storage() to its own directory (would delete the files)
|
* fix move_storage() to its own directory (would delete the files)
|
||||||
* fix socks5 support for UDP
|
* fix socks5 support for UDP
|
||||||
* add setting urlseed_max_request_bytes to handle large web seed requests
|
* add setting urlseed_max_request_bytes to handle large web seed requests
|
||||||
|
|
|
@ -34,6 +34,7 @@ alias libtorrent-sims :
|
||||||
[ run test_auto_manage.cpp ]
|
[ run test_auto_manage.cpp ]
|
||||||
[ run test_torrent_status.cpp ]
|
[ run test_torrent_status.cpp ]
|
||||||
[ run test_swarm.cpp ]
|
[ run test_swarm.cpp ]
|
||||||
|
[ run test_session.cpp ]
|
||||||
[ run test_super_seeding.cpp ]
|
[ run test_super_seeding.cpp ]
|
||||||
[ run test_utp.cpp ]
|
[ run test_utp.cpp ]
|
||||||
[ run test_dht.cpp ]
|
[ run test_dht.cpp ]
|
||||||
|
|
|
@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "create_torrent.hpp"
|
#include "create_torrent.hpp"
|
||||||
#include "simulator/simulator.hpp"
|
#include "simulator/simulator.hpp"
|
||||||
#include "simulator/utils.hpp"
|
#include "simulator/utils.hpp" // for timer
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace sim;
|
using namespace sim;
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2017, 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 "setup_swarm.hpp"
|
||||||
|
#include "test.hpp"
|
||||||
|
#include "utils.hpp"
|
||||||
|
#include "libtorrent/session.hpp"
|
||||||
|
#include "libtorrent/socket.hpp"
|
||||||
|
#include "simulator/simulator.hpp"
|
||||||
|
#include "simulator/utils.hpp" // for timer
|
||||||
|
#include "settings.hpp"
|
||||||
|
#include "create_torrent.hpp"
|
||||||
|
|
||||||
|
using namespace libtorrent;
|
||||||
|
|
||||||
|
TORRENT_TEST(seed_mode)
|
||||||
|
{
|
||||||
|
// with seed mode
|
||||||
|
setup_swarm(2, swarm_test::upload
|
||||||
|
// add session
|
||||||
|
, [](lt::settings_pack& pack) {
|
||||||
|
// make sure the session works with a tick interval of 5 seconds
|
||||||
|
pack.set_int(settings_pack::tick_interval, 5000);
|
||||||
|
}
|
||||||
|
// add torrent
|
||||||
|
, [](lt::add_torrent_params& params) {
|
||||||
|
params.flags |= add_torrent_params::flag_seed_mode;
|
||||||
|
}
|
||||||
|
// on alert
|
||||||
|
, [](lt::alert const* a, lt::session& ses) {}
|
||||||
|
// terminate
|
||||||
|
, [](int ticks, lt::session& ses) -> bool {
|
||||||
|
// we don't need to finish seeding, exit after 20 seconds
|
||||||
|
return ticks > 20;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -5453,14 +5453,14 @@ namespace libtorrent
|
||||||
|
|
||||||
if (channel == download_channel)
|
if (channel == download_channel)
|
||||||
{
|
{
|
||||||
return (std::max)((std::max)(m_outstanding_bytes
|
return std::max((std::max)(m_outstanding_bytes
|
||||||
, m_recv_buffer.packet_bytes_remaining()) + 30
|
, m_recv_buffer.packet_bytes_remaining()) + 30
|
||||||
, int(boost::int64_t(m_statistics.download_rate()) * 2
|
, int(boost::int64_t(m_statistics.download_rate()) * 2
|
||||||
/ (1000 / tick_interval)));
|
* tick_interval / 1000));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (std::max)((std::max)(m_reading_bytes
|
return std::max((std::max)(m_reading_bytes
|
||||||
, m_send_buffer.size())
|
, m_send_buffer.size())
|
||||||
, int((boost::int64_t(m_statistics.upload_rate()) * 2
|
, int((boost::int64_t(m_statistics.upload_rate()) * 2
|
||||||
* tick_interval) / 1000));
|
* tick_interval) / 1000));
|
||||||
|
|
Loading…
Reference in New Issue