fix: "Implicit conversion loses integer precision" warnings (#3960)
This commit is contained in:
parent
14f2698cdc
commit
12e564096b
|
@ -1261,13 +1261,13 @@ void DetailsDialog::Impl::refreshPeerList(std::vector<tr_torrent*> const& torren
|
|||
|
||||
/* step 1: get all the peers */
|
||||
std::vector<tr_peer_stat*> peers;
|
||||
std::vector<int> peerCount;
|
||||
std::vector<size_t> peerCount;
|
||||
|
||||
peers.reserve(torrents.size());
|
||||
peerCount.reserve(torrents.size());
|
||||
for (auto const* const torrent : torrents)
|
||||
{
|
||||
int count = 0;
|
||||
size_t count = 0;
|
||||
peers.push_back(tr_torrentPeers(torrent, &count));
|
||||
peerCount.push_back(count);
|
||||
}
|
||||
|
@ -1288,7 +1288,7 @@ void DetailsDialog::Impl::refreshPeerList(std::vector<tr_torrent*> const& torren
|
|||
{
|
||||
auto const* tor = torrents.at(i);
|
||||
|
||||
for (int j = 0; j < peerCount[i]; ++j)
|
||||
for (size_t j = 0; j < peerCount[i]; ++j)
|
||||
{
|
||||
auto const* s = &peers.at(i)[j];
|
||||
auto const key = make_key(tor, s);
|
||||
|
|
|
@ -203,23 +203,23 @@ void tr_announcerParseHttpAnnounceResponse(tr_announce_response& response, std::
|
|||
{
|
||||
if (auto const key = currentKey(); key == "interval")
|
||||
{
|
||||
response_.interval = value;
|
||||
response_.interval = static_cast<int>(value);
|
||||
}
|
||||
else if (key == "min interval"sv)
|
||||
{
|
||||
response_.min_interval = value;
|
||||
response_.min_interval = static_cast<int>(value);
|
||||
}
|
||||
else if (key == "complete"sv)
|
||||
{
|
||||
response_.seeders = value;
|
||||
response_.seeders = static_cast<int>(value);
|
||||
}
|
||||
else if (key == "incomplete"sv)
|
||||
{
|
||||
response_.leechers = value;
|
||||
response_.leechers = static_cast<int>(value);
|
||||
}
|
||||
else if (key == "downloaded"sv)
|
||||
{
|
||||
response_.downloads = value;
|
||||
response_.downloads = static_cast<int>(value);
|
||||
}
|
||||
else if (key == "port"sv)
|
||||
{
|
||||
|
@ -549,23 +549,23 @@ void tr_announcerParseHttpScrapeResponse(tr_scrape_response& response, std::stri
|
|||
{
|
||||
if (auto const key = currentKey(); row_ && key == "complete"sv)
|
||||
{
|
||||
response_.rows[*row_].seeders = value;
|
||||
response_.rows[*row_].seeders = static_cast<int>(value);
|
||||
}
|
||||
else if (row_ && key == "downloaded"sv)
|
||||
{
|
||||
response_.rows[*row_].downloads = value;
|
||||
response_.rows[*row_].downloads = static_cast<int>(value);
|
||||
}
|
||||
else if (row_ && key == "incomplete"sv)
|
||||
{
|
||||
response_.rows[*row_].leechers = value;
|
||||
response_.rows[*row_].leechers = static_cast<int>(value);
|
||||
}
|
||||
else if (row_ && key == "downloaders"sv)
|
||||
{
|
||||
response_.rows[*row_].downloaders = value;
|
||||
response_.rows[*row_].downloaders = static_cast<int>(value);
|
||||
}
|
||||
else if (key == "min_request_interval"sv)
|
||||
{
|
||||
response_.min_request_interval = value;
|
||||
response_.min_request_interval = static_cast<int>(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
****
|
||||
***/
|
||||
|
||||
unsigned int tr_bandwidth::getSpeedBytesPerSecond(RateControl& r, unsigned int interval_msec, uint64_t now)
|
||||
tr_bytes_per_second_t tr_bandwidth::getSpeedBytesPerSecond(RateControl& r, unsigned int interval_msec, uint64_t now)
|
||||
{
|
||||
if (now == 0)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ unsigned int tr_bandwidth::getSpeedBytesPerSecond(RateControl& r, unsigned int i
|
|||
}
|
||||
}
|
||||
|
||||
r.cache_val_ = unsigned(bytes * 1000U / interval_msec);
|
||||
r.cache_val_ = static_cast<tr_bytes_per_second_t>(bytes * 1000U / interval_msec);
|
||||
r.cache_time_ = now;
|
||||
}
|
||||
|
||||
|
@ -182,11 +182,11 @@ void tr_bandwidth::phaseOne(std::vector<tr_peerIo*>& peer_array, tr_direction di
|
|||
* out in a timely manner. */
|
||||
size_t const increment = 3000;
|
||||
|
||||
int const bytes_used = peer_array[i]->flush(dir, increment);
|
||||
auto const bytes_used = peer_array[i]->flush(dir, increment);
|
||||
|
||||
tr_logAddTrace(fmt::format("peer #{} of {} used {} bytes in this pass", i, n, bytes_used));
|
||||
|
||||
if (bytes_used != int(increment))
|
||||
if (bytes_used != increment)
|
||||
{
|
||||
/* peer is done writing for now; move it to the end of the list */
|
||||
std::swap(peer_array[i], peer_array[n - 1]);
|
||||
|
|
|
@ -29,8 +29,8 @@ class tr_peerIo;
|
|||
|
||||
struct tr_bandwidth_limits
|
||||
{
|
||||
unsigned int up_limit_KBps = 0;
|
||||
unsigned int down_limit_KBps = 0;
|
||||
tr_kilobytes_per_second_t up_limit_KBps = 0;
|
||||
tr_kilobytes_per_second_t down_limit_KBps = 0;
|
||||
bool up_limited = false;
|
||||
bool down_limited = false;
|
||||
};
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
}
|
||||
|
||||
/** @brief Get the raw total of bytes read or sent by this bandwidth subtree. */
|
||||
[[nodiscard]] unsigned int getRawSpeedBytesPerSecond(uint64_t const now, tr_direction const dir) const
|
||||
[[nodiscard]] tr_bytes_per_second_t getRawSpeedBytesPerSecond(uint64_t const now, tr_direction const dir) const
|
||||
{
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
}
|
||||
|
||||
/** @brief Get the number of piece data bytes read or sent by this bandwidth subtree. */
|
||||
[[nodiscard]] unsigned int getPieceSpeedBytesPerSecond(uint64_t const now, tr_direction const dir) const
|
||||
[[nodiscard]] tr_bytes_per_second_t getPieceSpeedBytesPerSecond(uint64_t const now, tr_direction const dir) const
|
||||
{
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
* @see tr_bandwidth::allocate
|
||||
* @see tr_bandwidth::getDesiredSpeed
|
||||
*/
|
||||
constexpr bool setDesiredSpeedBytesPerSecond(tr_direction dir, unsigned int desired_speed)
|
||||
constexpr bool setDesiredSpeedBytesPerSecond(tr_direction dir, tr_bytes_per_second_t desired_speed)
|
||||
{
|
||||
auto& value = this->band_[dir].desired_speed_bps_;
|
||||
bool const did_change = desired_speed != value;
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
* @brief Get the desired speed for the bandwidth subtree.
|
||||
* @see tr_bandwidth::setDesiredSpeed
|
||||
*/
|
||||
[[nodiscard]] constexpr double getDesiredSpeedBytesPerSecond(tr_direction dir) const
|
||||
[[nodiscard]] constexpr tr_bytes_per_second_t getDesiredSpeedBytesPerSecond(tr_direction dir) const
|
||||
{
|
||||
return this->band_[dir].desired_speed_bps_;
|
||||
}
|
||||
|
@ -220,9 +220,9 @@ public:
|
|||
struct RateControl
|
||||
{
|
||||
std::array<uint64_t, HistorySize> date_;
|
||||
std::array<uint32_t, HistorySize> size_;
|
||||
std::array<size_t, HistorySize> size_;
|
||||
uint64_t cache_time_;
|
||||
unsigned int cache_val_;
|
||||
tr_bytes_per_second_t cache_val_;
|
||||
int newest_;
|
||||
};
|
||||
|
||||
|
@ -231,7 +231,7 @@ public:
|
|||
RateControl raw_;
|
||||
RateControl piece_;
|
||||
unsigned int bytes_left_;
|
||||
unsigned int desired_speed_bps_;
|
||||
tr_bytes_per_second_t desired_speed_bps_;
|
||||
bool is_limited_ = false;
|
||||
bool honor_parent_limits_ = true;
|
||||
};
|
||||
|
@ -246,7 +246,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
static unsigned int getSpeedBytesPerSecond(RateControl& r, unsigned int interval_msec, uint64_t now);
|
||||
static tr_bytes_per_second_t getSpeedBytesPerSecond(RateControl& r, unsigned int interval_msec, uint64_t now);
|
||||
|
||||
static void notifyBandwidthConsumedBytes(uint64_t now, RateControl* r, size_t size);
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ void two_major_two_minor_formatter(char* buf, size_t buflen, std::string_view na
|
|||
// characters denoting version are limited to the following characters:
|
||||
// 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-
|
||||
// For example: 'S58B-----'... for Shadow's 5.8.11
|
||||
std::optional<size_t> get_shad0w_int(char ch)
|
||||
std::optional<int> get_shad0w_int(char ch)
|
||||
{
|
||||
auto constexpr Str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-"sv;
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ std::optional<tr_sha1_digest_t> recalculateHash(tr_torrent* tor, tr_piece_index_
|
|||
TR_ASSERT(tor != nullptr);
|
||||
TR_ASSERT(piece < tor->pieceCount());
|
||||
|
||||
auto bytes_left = size_t(tor->pieceSize(piece));
|
||||
auto bytes_left = tor->pieceSize(piece);
|
||||
auto loc = tor->pieceLoc(piece);
|
||||
tr_ioPrefetch(tor, loc, bytes_left);
|
||||
|
||||
|
@ -244,7 +244,7 @@ std::optional<tr_sha1_digest_t> recalculateHash(tr_torrent* tor, tr_piece_index_
|
|||
auto buffer = std::vector<uint8_t>(tr_block_info::BlockSize);
|
||||
while (bytes_left != 0)
|
||||
{
|
||||
size_t const len = std::min(bytes_left, std::size(buffer));
|
||||
auto const len = static_cast<uint32_t>(std::min(static_cast<size_t>(bytes_left), std::size(buffer)));
|
||||
if (auto const success = tor->session->cache->readBlock(tor, loc, len, std::data(buffer)) == 0; !success)
|
||||
{
|
||||
return {};
|
||||
|
|
|
@ -185,7 +185,7 @@ public:
|
|||
tr_peer(tr_torrent const* tor, peer_atom* atom = nullptr);
|
||||
virtual ~tr_peer();
|
||||
|
||||
virtual bool isTransferringPieces(uint64_t now, tr_direction dir, unsigned int* setme_bytes_per_second) const = 0;
|
||||
virtual bool isTransferringPieces(uint64_t now, tr_direction dir, tr_bytes_per_second_t* setme_bytes_per_second) const = 0;
|
||||
|
||||
[[nodiscard]] virtual std::string readable() const = 0;
|
||||
|
||||
|
|
|
@ -67,22 +67,22 @@ static constexpr size_t guessPacketOverhead(size_t d)
|
|||
*/
|
||||
double const assumed_payload_data_rate = 94.0;
|
||||
|
||||
return (unsigned int)(d * (100.0 / assumed_payload_data_rate) - d);
|
||||
return (size_t)(d * (100.0 / assumed_payload_data_rate) - d);
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
static void didWriteWrapper(tr_peerIo* io, unsigned int bytes_transferred)
|
||||
static void didWriteWrapper(tr_peerIo* io, size_t bytes_transferred)
|
||||
{
|
||||
while (bytes_transferred != 0 && tr_isPeerIo(io) && !std::empty(io->outbuf_info))
|
||||
{
|
||||
auto& [n_bytes_left, is_piece_data] = io->outbuf_info.front();
|
||||
|
||||
unsigned int const payload = std::min(uint64_t{ n_bytes_left }, uint64_t{ bytes_transferred });
|
||||
size_t const payload = std::min(uint64_t{ n_bytes_left }, uint64_t{ bytes_transferred });
|
||||
/* For µTP sockets, the overhead is computed in utp_on_overhead. */
|
||||
unsigned int const overhead = io->socket.type == TR_PEER_SOCKET_TYPE_TCP ? guessPacketOverhead(payload) : 0;
|
||||
size_t const overhead = io->socket.type == TR_PEER_SOCKET_TYPE_TCP ? guessPacketOverhead(payload) : 0;
|
||||
uint64_t const now = tr_time_msec();
|
||||
|
||||
io->bandwidth().notifyBandwidthConsumed(TR_UP, payload, is_piece_data, now);
|
||||
|
@ -136,7 +136,7 @@ static void canReadWrapper(tr_peerIo* io_in)
|
|||
size_t const old_len = io->readBufferSize();
|
||||
int const ret = io->canRead(io.get(), io->userData, &piece);
|
||||
size_t const used = old_len - io->readBufferSize();
|
||||
unsigned int const overhead = guessPacketOverhead(used);
|
||||
auto const overhead = guessPacketOverhead(used);
|
||||
|
||||
if (piece != 0 || piece != used)
|
||||
{
|
||||
|
@ -187,12 +187,12 @@ static void event_read_cb(evutil_socket_t fd, short /*event*/, void* vio)
|
|||
|
||||
/* Limit the input buffer to 256K, so it doesn't grow too large */
|
||||
tr_direction const dir = TR_DOWN;
|
||||
unsigned int const max = 256 * 1024;
|
||||
size_t const max = 256 * 1024;
|
||||
|
||||
io->pendingEvents &= ~EV_READ;
|
||||
|
||||
unsigned int const curlen = io->readBufferSize();
|
||||
unsigned int howmuch = curlen >= max ? 0 : max - curlen;
|
||||
auto const curlen = io->readBufferSize();
|
||||
unsigned int howmuch = static_cast<unsigned int>(curlen >= max ? 0 : max - curlen);
|
||||
howmuch = io->bandwidth().clamp(TR_DOWN, howmuch);
|
||||
|
||||
tr_logAddTraceIo(io, "libevent says this peer is ready to read");
|
||||
|
@ -326,13 +326,13 @@ static size_t utp_get_rb_size(tr_peerIo* const io)
|
|||
return UtpReadBufferSize - bytes;
|
||||
}
|
||||
|
||||
static int tr_peerIoTryWrite(tr_peerIo* io, size_t howmuch);
|
||||
static ssize_t tr_peerIoTryWrite(tr_peerIo* io, size_t howmuch);
|
||||
|
||||
static void utp_on_writable(tr_peerIo* io)
|
||||
{
|
||||
tr_logAddTraceIo(io, "libutp says this peer is ready to write");
|
||||
|
||||
int const n = tr_peerIoTryWrite(io, SIZE_MAX);
|
||||
auto const n = tr_peerIoTryWrite(io, SIZE_MAX);
|
||||
io->setEnabled(TR_UP, n != 0 && !std::empty(io->outbuf));
|
||||
}
|
||||
|
||||
|
@ -776,16 +776,16 @@ int tr_peerIo::reconnect()
|
|||
***
|
||||
**/
|
||||
|
||||
static unsigned int getDesiredOutputBufferSize(tr_peerIo const* io, uint64_t now)
|
||||
static size_t getDesiredOutputBufferSize(tr_peerIo const* io, uint64_t now)
|
||||
{
|
||||
/* this is all kind of arbitrary, but what seems to work well is
|
||||
* being large enough to hold the next 20 seconds' worth of input,
|
||||
* or a few blocks, whichever is bigger.
|
||||
* It's okay to tweak this as needed */
|
||||
unsigned int const current_speed_bytes_per_second = io->bandwidth().getPieceSpeedBytesPerSecond(now, TR_UP);
|
||||
auto const current_speed_bytes_per_second = io->bandwidth().getPieceSpeedBytesPerSecond(now, TR_UP);
|
||||
unsigned int const period = 15U; /* arbitrary */
|
||||
/* the 3 is arbitrary; the .5 is to leave room for messages */
|
||||
static auto const ceiling = (unsigned int)(tr_block_info::BlockSize * 3.5);
|
||||
static auto const ceiling = static_cast<size_t>(tr_block_info::BlockSize * 3.5);
|
||||
return std::max(ceiling, current_speed_bytes_per_second * period);
|
||||
}
|
||||
|
||||
|
@ -875,7 +875,7 @@ void tr_peerIo::readBufferDrain(size_t byte_count)
|
|||
****
|
||||
***/
|
||||
|
||||
static int tr_peerIoTryRead(tr_peerIo* io, size_t howmuch)
|
||||
static ssize_t tr_peerIoTryRead(tr_peerIo* io, size_t howmuch)
|
||||
{
|
||||
howmuch = io->bandwidth().clamp(TR_DOWN, howmuch);
|
||||
if (howmuch == 0)
|
||||
|
@ -883,7 +883,7 @@ static int tr_peerIoTryRead(tr_peerIo* io, size_t howmuch)
|
|||
return 0;
|
||||
}
|
||||
|
||||
auto res = int{};
|
||||
auto res = ssize_t{};
|
||||
switch (io->socket.type)
|
||||
{
|
||||
case TR_PEER_SOCKET_TYPE_UTP:
|
||||
|
@ -943,7 +943,7 @@ static int tr_peerIoTryRead(tr_peerIo* io, size_t howmuch)
|
|||
return res;
|
||||
}
|
||||
|
||||
static int tr_peerIoTryWrite(tr_peerIo* io, size_t howmuch)
|
||||
static ssize_t tr_peerIoTryWrite(tr_peerIo* io, size_t howmuch)
|
||||
{
|
||||
auto const old_len = std::size(io->outbuf);
|
||||
|
||||
|
@ -955,7 +955,7 @@ static int tr_peerIoTryWrite(tr_peerIo* io, size_t howmuch)
|
|||
return 0;
|
||||
}
|
||||
|
||||
auto n = int{};
|
||||
auto n = ssize_t{};
|
||||
switch (io->socket.type)
|
||||
{
|
||||
case TR_PEER_SOCKET_TYPE_UTP:
|
||||
|
@ -1001,16 +1001,16 @@ static int tr_peerIoTryWrite(tr_peerIo* io, size_t howmuch)
|
|||
return n;
|
||||
}
|
||||
|
||||
int tr_peerIo::flush(tr_direction dir, size_t limit)
|
||||
ssize_t tr_peerIo::flush(tr_direction dir, size_t limit)
|
||||
{
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
||||
int const bytes_used = dir == TR_DOWN ? tr_peerIoTryRead(this, limit) : tr_peerIoTryWrite(this, limit);
|
||||
auto const bytes_used = dir == TR_DOWN ? tr_peerIoTryRead(this, limit) : tr_peerIoTryWrite(this, limit);
|
||||
tr_logAddTraceIo(this, fmt::format("flushing peer-io, direction:{}, limit:{}, byte_used:{}", dir, limit, bytes_used));
|
||||
return bytes_used;
|
||||
}
|
||||
|
||||
int tr_peerIo::flushOutgoingProtocolMsgs()
|
||||
ssize_t tr_peerIo::flushOutgoingProtocolMsgs()
|
||||
{
|
||||
size_t byte_count = 0;
|
||||
|
||||
|
|
|
@ -144,8 +144,8 @@ public:
|
|||
|
||||
void readBufferAdd(void const* data, size_t n_bytes);
|
||||
|
||||
int flushOutgoingProtocolMsgs();
|
||||
int flush(tr_direction dir, size_t byte_limit);
|
||||
ssize_t flushOutgoingProtocolMsgs();
|
||||
ssize_t flush(tr_direction dir, size_t byte_limit);
|
||||
|
||||
void writeBytes(void const* bytes, size_t n_bytes, bool is_piece_data);
|
||||
|
||||
|
|
|
@ -630,9 +630,9 @@ private:
|
|||
*** tr_peer virtual functions
|
||||
**/
|
||||
|
||||
unsigned int tr_peerGetPieceSpeedBytesPerSecond(tr_peer const* peer, uint64_t now, tr_direction direction)
|
||||
tr_bytes_per_second_t tr_peerGetPieceSpeedBytesPerSecond(tr_peer const* peer, uint64_t now, tr_direction direction)
|
||||
{
|
||||
unsigned int bytes_per_second = 0;
|
||||
tr_bytes_per_second_t bytes_per_second = 0;
|
||||
peer->isTransferringPieces(now, direction, &bytes_per_second);
|
||||
return bytes_per_second;
|
||||
}
|
||||
|
@ -1651,7 +1651,7 @@ uint64_t tr_peerMgrGetDesiredAvailable(tr_torrent const* tor)
|
|||
|
||||
for (auto const* const peer : s->peers)
|
||||
{
|
||||
for (size_t j = 0; j < n_pieces; ++j)
|
||||
for (tr_piece_index_t j = 0; j < n_pieces; ++j)
|
||||
{
|
||||
if (peer->hasPiece(j))
|
||||
{
|
||||
|
@ -1660,7 +1660,7 @@ uint64_t tr_peerMgrGetDesiredAvailable(tr_torrent const* tor)
|
|||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < n_pieces; ++i)
|
||||
for (tr_piece_index_t i = 0; i < n_pieces; ++i)
|
||||
{
|
||||
if (tor->pieceIsWanted(i) && have.at(i))
|
||||
{
|
||||
|
@ -1784,7 +1784,7 @@ namespace peer_stat_helpers
|
|||
|
||||
} // namespace peer_stat_helpers
|
||||
|
||||
tr_peer_stat* tr_peerMgrPeerStats(tr_torrent const* tor, int* setme_count)
|
||||
tr_peer_stat* tr_peerMgrPeerStats(tr_torrent const* tor, size_t* setme_count)
|
||||
{
|
||||
using namespace peer_stat_helpers;
|
||||
|
||||
|
@ -2059,8 +2059,8 @@ void rechokeDownloads(tr_swarm* s)
|
|||
return false;
|
||||
}
|
||||
|
||||
unsigned int const got = b.getPieceSpeedBytesPerSecond(now_msec, dir);
|
||||
unsigned int const want = b.getDesiredSpeedBytesPerSecond(dir);
|
||||
auto const got = b.getPieceSpeedBytesPerSecond(now_msec, dir);
|
||||
auto const want = b.getDesiredSpeedBytesPerSecond(dir);
|
||||
return got >= want;
|
||||
}
|
||||
|
||||
|
@ -2306,12 +2306,12 @@ namespace disconnect_helpers
|
|||
namespace
|
||||
{
|
||||
// when many peers are available, keep idle ones this long
|
||||
auto constexpr MinUploadIdleSecs = int{ 60 };
|
||||
auto constexpr MinUploadIdleSecs = time_t{ 60 };
|
||||
|
||||
// when few peers are available, keep idle ones this long
|
||||
auto constexpr MaxUploadIdleSecs = int{ 60 * 5 };
|
||||
auto constexpr MaxUploadIdleSecs = time_t{ 60 * 5 };
|
||||
|
||||
[[nodiscard]] bool shouldPeerBeClosed(tr_swarm const* s, tr_peerMsgs const* peer, int peer_count, time_t const now)
|
||||
[[nodiscard]] bool shouldPeerBeClosed(tr_swarm const* s, tr_peerMsgs const* peer, size_t peer_count, time_t const now)
|
||||
{
|
||||
/* if it's marked for purging, close it */
|
||||
if (peer->do_purge)
|
||||
|
@ -2338,10 +2338,10 @@ auto constexpr MaxUploadIdleSecs = int{ 60 * 5 };
|
|||
float const strictness = peer_count >= relax_strictness_if_fewer_than_n ?
|
||||
1.0 :
|
||||
peer_count / (float)relax_strictness_if_fewer_than_n;
|
||||
int const lo = MinUploadIdleSecs;
|
||||
int const hi = MaxUploadIdleSecs;
|
||||
int const limit = hi - (hi - lo) * strictness;
|
||||
int const idle_time = now - std::max(atom->time, atom->piece_data_time);
|
||||
auto const lo = MinUploadIdleSecs;
|
||||
auto const hi = MaxUploadIdleSecs;
|
||||
time_t const limit = hi - (hi - lo) * strictness;
|
||||
time_t const idle_time = now - std::max(atom->time, atom->piece_data_time);
|
||||
|
||||
if (idle_time > limit)
|
||||
{
|
||||
|
|
|
@ -207,11 +207,14 @@ void tr_peerMgrOnTorrentGotMetainfo(tr_torrent* tor);
|
|||
|
||||
void tr_peerMgrOnBlocklistChanged(tr_peerMgr* mgr);
|
||||
|
||||
[[nodiscard]] struct tr_peer_stat* tr_peerMgrPeerStats(tr_torrent const* tor, int* setme_count);
|
||||
[[nodiscard]] struct tr_peer_stat* tr_peerMgrPeerStats(tr_torrent const* tor, size_t* setme_count);
|
||||
|
||||
[[nodiscard]] tr_webseed_view tr_peerMgrWebseed(tr_torrent const* tor, size_t i);
|
||||
|
||||
[[nodiscard]] unsigned int tr_peerGetPieceSpeedBytesPerSecond(tr_peer const* peer, uint64_t now, tr_direction direction);
|
||||
[[nodiscard]] tr_bytes_per_second_t tr_peerGetPieceSpeedBytesPerSecond(
|
||||
tr_peer const* peer,
|
||||
uint64_t now,
|
||||
tr_direction direction);
|
||||
|
||||
void tr_peerMgrClearInterest(tr_torrent* tor);
|
||||
|
||||
|
|
|
@ -324,7 +324,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool isTransferringPieces(uint64_t now, tr_direction dir, unsigned int* setme_bytes_per_second) const override
|
||||
bool isTransferringPieces(uint64_t now, tr_direction dir, tr_bytes_per_second_t* setme_bytes_per_second) const override
|
||||
{
|
||||
auto const bytes_per_second = io->getPieceSpeedBytesPerSecond(now, dir);
|
||||
|
||||
|
@ -1159,7 +1159,7 @@ static void parseUtMetadata(tr_peerMsgsImpl* msgs, uint32_t msglen)
|
|||
if (msg_type == MetadataMsgType::Data && !msgs->torrent->hasMetainfo() && msg_end - benc_end <= METADATA_PIECE_SIZE &&
|
||||
piece * METADATA_PIECE_SIZE + (msg_end - benc_end) <= total_size)
|
||||
{
|
||||
int const piece_len = msg_end - benc_end;
|
||||
auto const piece_len = msg_end - benc_end;
|
||||
tr_torrentSetMetadataPiece(msgs->torrent, piece, benc_end, piece_len);
|
||||
}
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ static auto loadFilenames(tr_variant* dict, tr_torrent* tor)
|
|||
|
||||
auto const n_files = tor->fileCount();
|
||||
auto const n_list = tr_variantListSize(list);
|
||||
for (size_t i = 0; i < n_files && i < n_list; ++i)
|
||||
for (tr_file_index_t i = 0; i < n_files && i < n_list; ++i)
|
||||
{
|
||||
auto sv = std::string_view{};
|
||||
if (tr_variantGetStrView(tr_variantListChild(list, i), &sv) && !std::empty(sv))
|
||||
|
|
|
@ -614,7 +614,7 @@ static bool bindUnixSocket(
|
|||
[[maybe_unused]] struct event_base* base,
|
||||
[[maybe_unused]] struct evhttp* httpd,
|
||||
[[maybe_unused]] char const* path,
|
||||
[[maybe_unused]] int socket_mode)
|
||||
[[maybe_unused]] mode_t socket_mode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
tr_logAddError(fmt::format(
|
||||
|
@ -1029,7 +1029,7 @@ tr_rpc_server::tr_rpc_server(tr_session* session_in, tr_variant* settings)
|
|||
}
|
||||
else
|
||||
{
|
||||
this->setAntiBruteForceLimit(i);
|
||||
this->setAntiBruteForceLimit(static_cast<int>(i));
|
||||
}
|
||||
|
||||
key = TR_KEY_rpc_socket_mode;
|
||||
|
@ -1052,7 +1052,7 @@ tr_rpc_server::tr_rpc_server(tr_session* session_in, tr_variant* settings)
|
|||
}
|
||||
else
|
||||
{
|
||||
this->socket_mode_ = i;
|
||||
this->socket_mode_ = static_cast<mode_t>(i);
|
||||
}
|
||||
|
||||
key = TR_KEY_rpc_bind_address;
|
||||
|
|
|
@ -141,8 +141,8 @@ public:
|
|||
int anti_brute_force_limit_ = 0;
|
||||
int login_attempts_ = 0;
|
||||
int start_retry_counter = 0;
|
||||
static int constexpr DefaultRpcSocketMode = 0750;
|
||||
int socket_mode_ = DefaultRpcSocketMode;
|
||||
static mode_t constexpr DefaultRpcSocketMode = 0750;
|
||||
mode_t socket_mode_ = DefaultRpcSocketMode;
|
||||
|
||||
tr_port port_;
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ static auto getTorrents(tr_session* session, tr_variant* args)
|
|||
|
||||
if (tr_variantGetInt(node, &id))
|
||||
{
|
||||
tor = tr_torrentFindFromId(session, id);
|
||||
tor = tr_torrentFindFromId(session, static_cast<tr_torrent_id_t>(id));
|
||||
}
|
||||
else if (tr_variantGetStrView(node, &sv))
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ static auto getTorrents(tr_session* session, tr_variant* args)
|
|||
}
|
||||
else if (tr_variantDictFindInt(args, TR_KEY_ids, &id) || tr_variantDictFindInt(args, TR_KEY_id, &id))
|
||||
{
|
||||
if (auto* const tor = tr_torrentFindFromId(session, id); tor != nullptr)
|
||||
if (auto* const tor = tr_torrentFindFromId(session, static_cast<tr_torrent_id_t>(id)); tor != nullptr)
|
||||
{
|
||||
torrents.push_back(tor);
|
||||
}
|
||||
|
@ -428,12 +428,12 @@ static void addTrackerStats(tr_tracker_view const& tracker, tr_variant* list)
|
|||
|
||||
static void addPeers(tr_torrent const* tor, tr_variant* list)
|
||||
{
|
||||
auto peer_count = int{};
|
||||
auto peer_count = size_t{};
|
||||
tr_peer_stat* peers = tr_torrentPeers(tor, &peer_count);
|
||||
|
||||
tr_variantInitList(list, peer_count);
|
||||
|
||||
for (int i = 0; i < peer_count; ++i)
|
||||
for (size_t i = 0; i < peer_count; ++i)
|
||||
{
|
||||
tr_variant* d = tr_variantListAddDict(list, 16);
|
||||
tr_peer_stat const* peer = peers + i;
|
||||
|
@ -1102,12 +1102,12 @@ static char const* setFileDLs(tr_torrent* tor, bool wanted, tr_variant* list)
|
|||
{
|
||||
for (size_t i = 0; i < n_items; ++i)
|
||||
{
|
||||
auto tmp = int64_t{};
|
||||
if (tr_variantGetInt(tr_variantListChild(list, i), &tmp))
|
||||
auto file_index = int64_t{};
|
||||
if (tr_variantGetInt(tr_variantListChild(list, i), &file_index))
|
||||
{
|
||||
if (0 <= tmp && tmp < n_files)
|
||||
if (0 <= file_index && file_index < n_files)
|
||||
{
|
||||
files.push_back(tmp);
|
||||
files.push_back(static_cast<tr_file_index_t>(file_index));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1165,7 +1165,7 @@ static char const* replaceTrackers(tr_torrent* tor, tr_variant* urls)
|
|||
if (tr_variantGetInt(tr_variantListChild(urls, i), &id) &&
|
||||
tr_variantGetStrView(tr_variantListChild(urls, i + 1), &newval))
|
||||
{
|
||||
changed |= tor->announceList().replace(id, newval);
|
||||
changed |= tor->announceList().replace(static_cast<tr_tracker_id_t>(id), newval);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1192,7 +1192,7 @@ static char const* removeTrackers(tr_torrent* tor, tr_variant* ids)
|
|||
continue;
|
||||
}
|
||||
|
||||
tor->announceList().remove(id);
|
||||
tor->announceList().remove(static_cast<tr_tracker_id_t>(id));
|
||||
}
|
||||
|
||||
if (tor->trackerCount() == old_size)
|
||||
|
@ -1296,7 +1296,7 @@ static char const* torrentSet(
|
|||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_seedIdleLimit, &tmp))
|
||||
{
|
||||
tr_torrentSetIdleLimit(tor, (uint16_t)tmp);
|
||||
tr_torrentSetIdleLimit(tor, static_cast<uint16_t>(tmp));
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_seedIdleMode, &tmp))
|
||||
|
@ -1316,7 +1316,7 @@ static char const* torrentSet(
|
|||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_queuePosition, &tmp))
|
||||
{
|
||||
tr_torrentSetQueuePosition(tor, (int)tmp);
|
||||
tr_torrentSetQueuePosition(tor, static_cast<size_t>(tmp));
|
||||
}
|
||||
|
||||
if (errmsg == nullptr && tr_variantDictFindList(args_in, TR_KEY_trackerAdd, &tmp_variant))
|
||||
|
@ -1636,7 +1636,7 @@ static auto fileListFromList(tr_variant* list)
|
|||
{
|
||||
if (tr_variantGetInt(tr_variantListChild(list, i), &file_index))
|
||||
{
|
||||
files.push_back(file_index);
|
||||
files.push_back(static_cast<tr_file_index_t>(file_index));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1838,12 +1838,12 @@ static char const* groupSet(
|
|||
|
||||
if (auto limit = int64_t{}; tr_variantDictFindInt(args_in, TR_KEY_speed_limit_down, &limit))
|
||||
{
|
||||
limits.down_limit_KBps = limit;
|
||||
limits.down_limit_KBps = static_cast<tr_kilobytes_per_second_t>(limit);
|
||||
}
|
||||
|
||||
if (auto limit = int64_t{}; tr_variantDictFindInt(args_in, TR_KEY_speed_limit_up, &limit))
|
||||
{
|
||||
limits.up_limit_KBps = limit;
|
||||
limits.up_limit_KBps = static_cast<tr_kilobytes_per_second_t>(limit);
|
||||
}
|
||||
|
||||
group.setLimits(&limits);
|
||||
|
@ -1906,12 +1906,12 @@ static char const* sessionSet(
|
|||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_alt_speed_time_begin, &i))
|
||||
{
|
||||
tr_sessionSetAltSpeedBegin(session, i);
|
||||
tr_sessionSetAltSpeedBegin(session, static_cast<int>(i));
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_alt_speed_time_end, &i))
|
||||
{
|
||||
tr_sessionSetAltSpeedEnd(session, i);
|
||||
tr_sessionSetAltSpeedEnd(session, static_cast<int>(i));
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_alt_speed_time_day, &i))
|
||||
|
@ -1941,7 +1941,7 @@ static char const* sessionSet(
|
|||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_queue_stalled_minutes, &i))
|
||||
{
|
||||
tr_sessionSetQueueStalledMinutes(session, i);
|
||||
tr_sessionSetQueueStalledMinutes(session, static_cast<int>(i));
|
||||
}
|
||||
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_queue_stalled_enabled, &val))
|
||||
|
@ -1956,7 +1956,7 @@ static char const* sessionSet(
|
|||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_download_queue_size, &i))
|
||||
{
|
||||
tr_sessionSetQueueSize(session, TR_DOWN, (int)i);
|
||||
tr_sessionSetQueueSize(session, TR_DOWN, i);
|
||||
}
|
||||
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_download_queue_enabled, &val))
|
||||
|
@ -2056,7 +2056,7 @@ static char const* sessionSet(
|
|||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_seed_queue_size, &i))
|
||||
{
|
||||
tr_sessionSetQueueSize(session, TR_UP, (int)i);
|
||||
tr_sessionSetQueueSize(session, TR_UP, i);
|
||||
}
|
||||
|
||||
for (auto const& [enabled_key, script_key, script] : tr_session::Scripts)
|
||||
|
@ -2079,7 +2079,7 @@ static char const* sessionSet(
|
|||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_speed_limit_down, &i))
|
||||
{
|
||||
tr_sessionSetSpeedLimit_KBps(session, TR_DOWN, i);
|
||||
tr_sessionSetSpeedLimit_KBps(session, TR_DOWN, static_cast<tr_kilobytes_per_second_t>(i));
|
||||
}
|
||||
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_speed_limit_down_enabled, &val))
|
||||
|
@ -2089,7 +2089,7 @@ static char const* sessionSet(
|
|||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_speed_limit_up, &i))
|
||||
{
|
||||
tr_sessionSetSpeedLimit_KBps(session, TR_UP, i);
|
||||
tr_sessionSetSpeedLimit_KBps(session, TR_UP, static_cast<tr_kilobytes_per_second_t>(i));
|
||||
}
|
||||
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_speed_limit_up_enabled, &val))
|
||||
|
@ -2115,7 +2115,7 @@ static char const* sessionSet(
|
|||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_anti_brute_force_threshold, &i))
|
||||
{
|
||||
tr_sessionSetAntiBruteForceThreshold(session, i);
|
||||
tr_sessionSetAntiBruteForceThreshold(session, static_cast<int>(i));
|
||||
}
|
||||
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_anti_brute_force_enabled, &val))
|
||||
|
|
|
@ -866,7 +866,7 @@ void tr_session::setImpl(init_data& data)
|
|||
/* torrent queues */
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_queue_stalled_minutes, &i))
|
||||
{
|
||||
tr_sessionSetQueueStalledMinutes(this, i);
|
||||
tr_sessionSetQueueStalledMinutes(this, static_cast<int>(i));
|
||||
}
|
||||
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_queue_stalled_enabled, &val))
|
||||
|
@ -1003,7 +1003,7 @@ void tr_session::setImpl(init_data& data)
|
|||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_speed_limit_up, &i))
|
||||
{
|
||||
tr_sessionSetSpeedLimit_KBps(this, TR_UP, i);
|
||||
tr_sessionSetSpeedLimit_KBps(this, TR_UP, static_cast<tr_kilobytes_per_second_t>(i));
|
||||
}
|
||||
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_speed_limit_up_enabled, &val))
|
||||
|
@ -1013,7 +1013,7 @@ void tr_session::setImpl(init_data& data)
|
|||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_speed_limit_down, &i))
|
||||
{
|
||||
tr_sessionSetSpeedLimit_KBps(this, TR_DOWN, i);
|
||||
tr_sessionSetSpeedLimit_KBps(this, TR_DOWN, static_cast<tr_kilobytes_per_second_t>(i));
|
||||
}
|
||||
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_speed_limit_down_enabled, &val))
|
||||
|
@ -1058,12 +1058,12 @@ void tr_session::setImpl(init_data& data)
|
|||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_alt_speed_time_begin, &i))
|
||||
{
|
||||
turtle.beginMinute = i;
|
||||
turtle.beginMinute = static_cast<int>(i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_alt_speed_time_end, &i))
|
||||
{
|
||||
turtle.endMinute = i;
|
||||
turtle.endMinute = static_cast<int>(i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_alt_speed_time_day, &i))
|
||||
|
@ -1107,7 +1107,7 @@ void tr_session::setImpl(init_data& data)
|
|||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_anti_brute_force_threshold, &i))
|
||||
{
|
||||
tr_sessionSetAntiBruteForceThreshold(this, i);
|
||||
tr_sessionSetAntiBruteForceThreshold(this, static_cast<int>(i));
|
||||
}
|
||||
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_anti_brute_force_enabled, &val))
|
||||
|
@ -1369,9 +1369,9 @@ uint16_t tr_sessionGetIdleLimit(tr_session const* session)
|
|||
****
|
||||
***/
|
||||
|
||||
static unsigned int tr_sessionGetAltSpeed_Bps(tr_session const* s, tr_direction d);
|
||||
static tr_bytes_per_second_t tr_sessionGetAltSpeed_Bps(tr_session const* s, tr_direction d);
|
||||
|
||||
std::optional<unsigned int> tr_session::activeSpeedLimitBps(tr_direction dir) const noexcept
|
||||
std::optional<tr_bytes_per_second_t> tr_session::activeSpeedLimitBps(tr_direction dir) const noexcept
|
||||
{
|
||||
if (tr_sessionUsesAltSpeed(this))
|
||||
{
|
||||
|
@ -1411,8 +1411,8 @@ static void turtleUpdateTable(struct tr_turtle_info* t)
|
|||
{
|
||||
if ((t->days & (1 << day)) != 0)
|
||||
{
|
||||
time_t const begin = t->beginMinute;
|
||||
time_t end = t->endMinute;
|
||||
auto const begin = t->beginMinute;
|
||||
auto end = t->endMinute;
|
||||
|
||||
if (end <= begin)
|
||||
{
|
||||
|
@ -1518,7 +1518,7 @@ static void turtleBootstrap(tr_session* session, struct tr_turtle_info* turtle)
|
|||
**** Primary session speed limits
|
||||
***/
|
||||
|
||||
void tr_sessionSetSpeedLimit_Bps(tr_session* session, tr_direction dir, unsigned int bytes_per_second)
|
||||
void tr_sessionSetSpeedLimit_Bps(tr_session* session, tr_direction dir, tr_bytes_per_second_t bytes_per_second)
|
||||
{
|
||||
TR_ASSERT(session != nullptr);
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
@ -1528,12 +1528,12 @@ void tr_sessionSetSpeedLimit_Bps(tr_session* session, tr_direction dir, unsigned
|
|||
updateBandwidth(session, dir);
|
||||
}
|
||||
|
||||
void tr_sessionSetSpeedLimit_KBps(tr_session* session, tr_direction dir, unsigned int kilo_per_second)
|
||||
void tr_sessionSetSpeedLimit_KBps(tr_session* session, tr_direction dir, tr_kilobytes_per_second_t kilo_per_second)
|
||||
{
|
||||
tr_sessionSetSpeedLimit_Bps(session, dir, tr_toSpeedBytes(kilo_per_second));
|
||||
}
|
||||
|
||||
unsigned int tr_sessionGetSpeedLimit_KBps(tr_session const* s, tr_direction d)
|
||||
tr_kilobytes_per_second_t tr_sessionGetSpeedLimit_KBps(tr_session const* s, tr_direction d)
|
||||
{
|
||||
return tr_toSpeedKBps(s->speedLimitBps(d));
|
||||
}
|
||||
|
@ -1560,7 +1560,7 @@ bool tr_sessionIsSpeedLimited(tr_session const* session, tr_direction dir)
|
|||
**** Alternative speed limits that are used during scheduled times
|
||||
***/
|
||||
|
||||
static void tr_sessionSetAltSpeed_Bps(tr_session* s, tr_direction d, unsigned int bytes_per_second)
|
||||
static void tr_sessionSetAltSpeed_Bps(tr_session* s, tr_direction d, tr_bytes_per_second_t bytes_per_second)
|
||||
{
|
||||
TR_ASSERT(s != nullptr);
|
||||
TR_ASSERT(tr_isDirection(d));
|
||||
|
@ -1570,12 +1570,12 @@ static void tr_sessionSetAltSpeed_Bps(tr_session* s, tr_direction d, unsigned in
|
|||
updateBandwidth(s, d);
|
||||
}
|
||||
|
||||
void tr_sessionSetAltSpeed_KBps(tr_session* s, tr_direction d, unsigned int kilo_per_second)
|
||||
void tr_sessionSetAltSpeed_KBps(tr_session* s, tr_direction d, tr_kilobytes_per_second_t kilo_per_second)
|
||||
{
|
||||
tr_sessionSetAltSpeed_Bps(s, d, tr_toSpeedBytes(kilo_per_second));
|
||||
}
|
||||
|
||||
static unsigned int tr_sessionGetAltSpeed_Bps(tr_session const* s, tr_direction d)
|
||||
static tr_bytes_per_second_t tr_sessionGetAltSpeed_Bps(tr_session const* s, tr_direction d)
|
||||
{
|
||||
TR_ASSERT(s != nullptr);
|
||||
TR_ASSERT(tr_isDirection(d));
|
||||
|
@ -1583,7 +1583,7 @@ static unsigned int tr_sessionGetAltSpeed_Bps(tr_session const* s, tr_direction
|
|||
return s->turtle.speedLimit_Bps[d];
|
||||
}
|
||||
|
||||
unsigned int tr_sessionGetAltSpeed_KBps(tr_session const* s, tr_direction d)
|
||||
tr_kilobytes_per_second_t tr_sessionGetAltSpeed_KBps(tr_session const* s, tr_direction d)
|
||||
{
|
||||
return tr_toSpeedKBps(tr_sessionGetAltSpeed_Bps(s, d));
|
||||
}
|
||||
|
@ -1628,7 +1628,7 @@ void tr_sessionSetAltSpeedBegin(tr_session* s, int minutes_since_midnight)
|
|||
{
|
||||
TR_ASSERT(s != nullptr);
|
||||
TR_ASSERT(minutes_since_midnight >= 0);
|
||||
TR_ASSERT(minutes_since_midnight < 60 * 24);
|
||||
TR_ASSERT(minutes_since_midnight < MinutesPerDay);
|
||||
|
||||
if (s->turtle.beginMinute != minutes_since_midnight)
|
||||
{
|
||||
|
@ -1648,7 +1648,7 @@ void tr_sessionSetAltSpeedEnd(tr_session* s, int minutes_since_midnight)
|
|||
{
|
||||
TR_ASSERT(s != nullptr);
|
||||
TR_ASSERT(minutes_since_midnight >= 0);
|
||||
TR_ASSERT(minutes_since_midnight < 60 * 24);
|
||||
TR_ASSERT(minutes_since_midnight < MinutesPerDay);
|
||||
|
||||
if (s->turtle.endMinute != minutes_since_midnight)
|
||||
{
|
||||
|
@ -1770,7 +1770,7 @@ bool tr_sessionGetDeleteSource(tr_session const* session)
|
|||
****
|
||||
***/
|
||||
|
||||
static unsigned int tr_sessionGetRawSpeed_Bps(tr_session const* session, tr_direction dir)
|
||||
static tr_kilobytes_per_second_t tr_sessionGetRawSpeed_Bps(tr_session const* session, tr_direction dir)
|
||||
{
|
||||
return session != nullptr ? session->top_bandwidth_.getRawSpeedBytesPerSecond(0, dir) : 0;
|
||||
}
|
||||
|
@ -2128,14 +2128,14 @@ bool tr_sessionIsLPDEnabled(tr_session const* session)
|
|||
****
|
||||
***/
|
||||
|
||||
void tr_sessionSetCacheLimit_MB(tr_session* session, int mb)
|
||||
void tr_sessionSetCacheLimit_MB(tr_session* session, size_t mb)
|
||||
{
|
||||
TR_ASSERT(session != nullptr);
|
||||
|
||||
session->cache->setLimit(tr_toMemBytes(mb));
|
||||
}
|
||||
|
||||
int tr_sessionGetCacheLimit_MB(tr_session const* session)
|
||||
size_t tr_sessionGetCacheLimit_MB(tr_session const* session)
|
||||
{
|
||||
TR_ASSERT(session != nullptr);
|
||||
|
||||
|
@ -2475,7 +2475,7 @@ char const* tr_sessionGetScript(tr_session const* session, TrScript type)
|
|||
****
|
||||
***/
|
||||
|
||||
void tr_sessionSetQueueSize(tr_session* session, tr_direction dir, int max_simultaneous_seed_torrents)
|
||||
void tr_sessionSetQueueSize(tr_session* session, tr_direction dir, size_t max_simultaneous_seed_torrents)
|
||||
{
|
||||
TR_ASSERT(session != nullptr);
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
@ -2483,7 +2483,7 @@ void tr_sessionSetQueueSize(tr_session* session, tr_direction dir, int max_simul
|
|||
session->queue_size_[dir] = max_simultaneous_seed_torrents;
|
||||
}
|
||||
|
||||
int tr_sessionGetQueueSize(tr_session const* session, tr_direction dir)
|
||||
size_t tr_sessionGetQueueSize(tr_session const* session, tr_direction dir)
|
||||
{
|
||||
TR_ASSERT(session != nullptr);
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
@ -2666,12 +2666,12 @@ static void bandwidthGroupRead(tr_session* session, std::string_view config_dir)
|
|||
|
||||
if (auto limit = int64_t{}; tr_variantDictFindInt(dict, TR_KEY_uploadLimit, &limit))
|
||||
{
|
||||
limits.up_limit_KBps = limit;
|
||||
limits.up_limit_KBps = static_cast<tr_kilobytes_per_second_t>(limit);
|
||||
}
|
||||
|
||||
if (auto limit = int64_t{}; tr_variantDictFindInt(dict, TR_KEY_downloadLimit, &limit))
|
||||
{
|
||||
limits.down_limit_KBps = limit;
|
||||
limits.down_limit_KBps = static_cast<tr_kilobytes_per_second_t>(limit);
|
||||
}
|
||||
|
||||
group.setLimits(&limits);
|
||||
|
|
|
@ -79,7 +79,7 @@ class SessionTest;
|
|||
struct tr_turtle_info
|
||||
{
|
||||
/* TR_UP and TR_DOWN speed limits */
|
||||
std::array<unsigned int, 2> speedLimit_Bps = {};
|
||||
std::array<tr_bytes_per_second_t, 2> speedLimit_Bps = {};
|
||||
|
||||
/* is turtle mode on right now? */
|
||||
bool isEnabled = false;
|
||||
|
@ -87,10 +87,12 @@ struct tr_turtle_info
|
|||
/* does turtle mode turn itself on and off at given times? */
|
||||
bool isClockEnabled = false;
|
||||
|
||||
/* when clock mode is on, minutes after midnight to turn on turtle mode */
|
||||
/* when clock mode is on, minutes after midnight to turn on turtle mode.
|
||||
* Valid range: 0..<1440 */
|
||||
int beginMinute = 0;
|
||||
|
||||
/* when clock mode is on, minutes after midnight to turn off turtle mode */
|
||||
/* when clock mode is on, minutes after midnight to turn off turtle mode.
|
||||
* Valid range: 0..<1440 */
|
||||
int endMinute = 0;
|
||||
|
||||
/* only use clock mode on these days of the week */
|
||||
|
@ -789,7 +791,7 @@ public:
|
|||
return top_bandwidth_.getPieceSpeedBytesPerSecond(0, dir);
|
||||
}
|
||||
|
||||
[[nodiscard]] std::optional<unsigned int> activeSpeedLimitBps(tr_direction dir) const noexcept;
|
||||
[[nodiscard]] std::optional<tr_bytes_per_second_t> activeSpeedLimitBps(tr_direction dir) const noexcept;
|
||||
|
||||
[[nodiscard]] constexpr auto isIncompleteFileNamingEnabled() const noexcept
|
||||
{
|
||||
|
@ -915,7 +917,7 @@ private:
|
|||
friend void tr_sessionSetPexEnabled(tr_session* session, bool enabled);
|
||||
friend void tr_sessionSetPortForwardingEnabled(tr_session* session, bool enabled);
|
||||
friend void tr_sessionSetQueueEnabled(tr_session* session, tr_direction dir, bool do_limit_simultaneous_seed_torrents);
|
||||
friend void tr_sessionSetQueueSize(tr_session* session, tr_direction dir, int max_simultaneous_seed_torrents);
|
||||
friend void tr_sessionSetQueueSize(tr_session* session, tr_direction dir, size_t max_simultaneous_seed_torrents);
|
||||
friend void tr_sessionSetQueueStalledEnabled(tr_session* session, bool is_enabled);
|
||||
friend void tr_sessionSetQueueStalledMinutes(tr_session* session, int minutes);
|
||||
friend void tr_sessionSetRPCCallback(tr_session* session, tr_rpc_func func, void* user_data);
|
||||
|
@ -926,7 +928,7 @@ private:
|
|||
friend void tr_sessionSetRPCUsername(tr_session* session, char const* username);
|
||||
friend void tr_sessionSetRatioLimit(tr_session* session, double desired_ratio);
|
||||
friend void tr_sessionSetRatioLimited(tr_session* session, bool is_limited);
|
||||
friend void tr_sessionSetSpeedLimit_Bps(tr_session* session, tr_direction dir, unsigned int bytes_per_second);
|
||||
friend void tr_sessionSetSpeedLimit_Bps(tr_session* session, tr_direction dir, tr_bytes_per_second_t bytes_per_second);
|
||||
friend void tr_sessionSetUTPEnabled(tr_session* session, bool enabled);
|
||||
|
||||
/// constexpr fields
|
||||
|
@ -979,11 +981,11 @@ private:
|
|||
|
||||
float desired_ratio_ = 2.0F;
|
||||
|
||||
std::array<unsigned int, 2> speed_limit_Bps_ = { 0U, 0U };
|
||||
std::array<tr_bytes_per_second_t, 2> speed_limit_Bps_ = { 0U, 0U };
|
||||
std::array<bool, 2> speed_limit_enabled_ = { false, false };
|
||||
|
||||
std::array<bool, 2> queue_enabled_ = { false, false };
|
||||
std::array<int, 2> queue_size_ = { 0, 0 };
|
||||
std::array<size_t, 2> queue_size_ = { 0, 0 };
|
||||
|
||||
int umask_ = 022;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ private:
|
|||
auto const secs = duration_cast<seconds>(interval_);
|
||||
auto tv = timeval{};
|
||||
tv.tv_sec = secs.count();
|
||||
tv.tv_usec = duration_cast<microseconds>(interval_ - secs).count();
|
||||
tv.tv_usec = static_cast<suseconds_t>(duration_cast<microseconds>(interval_ - secs).count());
|
||||
evtimer_add(evtimer_, &tv);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ std::optional<std::vector<std::byte>> tr_torrentGetMetadataPiece(tr_torrent cons
|
|||
return buf;
|
||||
}
|
||||
|
||||
static int getPieceLength(struct tr_incomplete_metadata const* m, int piece)
|
||||
static ssize_t getPieceLength(struct tr_incomplete_metadata const* m, int piece)
|
||||
{
|
||||
return piece + 1 == m->piece_count ? // last piece
|
||||
std::size(m->metadata) - (piece * METADATA_PIECE_SIZE) :
|
||||
|
|
|
@ -76,7 +76,7 @@ tr_torrent_id_t tr_torrentId(tr_torrent const* tor)
|
|||
return tor != nullptr ? tor->id() : -1;
|
||||
}
|
||||
|
||||
tr_torrent* tr_torrentFindFromId(tr_session* session, int id)
|
||||
tr_torrent* tr_torrentFindFromId(tr_session* session, tr_torrent_id_t id)
|
||||
{
|
||||
return session->torrents().get(id);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ tr_peer_id_t const& tr_torrentGetPeerId(tr_torrent* tor)
|
|||
**** PER-TORRENT UL / DL SPEEDS
|
||||
***/
|
||||
|
||||
void tr_torrent::setSpeedLimitBps(tr_direction dir, unsigned int bytes_per_second)
|
||||
void tr_torrent::setSpeedLimitBps(tr_direction dir, tr_bytes_per_second_t bytes_per_second)
|
||||
{
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
||||
|
@ -198,19 +198,19 @@ void tr_torrent::setSpeedLimitBps(tr_direction dir, unsigned int bytes_per_secon
|
|||
}
|
||||
}
|
||||
|
||||
void tr_torrentSetSpeedLimit_KBps(tr_torrent* tor, tr_direction dir, unsigned int kilo_per_second)
|
||||
void tr_torrentSetSpeedLimit_KBps(tr_torrent* tor, tr_direction dir, tr_kilobytes_per_second_t kilo_per_second)
|
||||
{
|
||||
tor->setSpeedLimitBps(dir, tr_toSpeedBytes(kilo_per_second));
|
||||
}
|
||||
|
||||
unsigned int tr_torrent::speedLimitBps(tr_direction dir) const
|
||||
tr_bytes_per_second_t tr_torrent::speedLimitBps(tr_direction dir) const
|
||||
{
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
||||
return this->bandwidth_.getDesiredSpeedBytesPerSecond(dir);
|
||||
}
|
||||
|
||||
unsigned int tr_torrentGetSpeedLimit_KBps(tr_torrent const* tor, tr_direction dir)
|
||||
tr_kilobytes_per_second_t tr_torrentGetSpeedLimit_KBps(tr_torrent const* tor, tr_direction dir)
|
||||
{
|
||||
TR_ASSERT(tr_isTorrent(tor));
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
@ -993,14 +993,14 @@ tr_torrent_activity tr_torrentGetActivity(tr_torrent const* tor)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int torrentGetIdleSecs(tr_torrent const* tor, tr_torrent_activity activity)
|
||||
static time_t torrentGetIdleSecs(tr_torrent const* tor, tr_torrent_activity activity)
|
||||
{
|
||||
return ((activity == TR_STATUS_DOWNLOAD || activity == TR_STATUS_SEED) && tor->startDate != 0) ?
|
||||
(int)difftime(tr_time(), std::max(tor->startDate, tor->activityDate)) :
|
||||
(time_t)difftime(tr_time(), std::max(tor->startDate, tor->activityDate)) :
|
||||
-1;
|
||||
}
|
||||
|
||||
static inline bool tr_torrentIsStalled(tr_torrent const* tor, int idle_secs)
|
||||
static inline bool tr_torrentIsStalled(tr_torrent const* tor, time_t idle_secs)
|
||||
{
|
||||
return tor->session->queueStalledEnabled() && idle_secs > tor->session->queueStalledMinutes() * 60;
|
||||
}
|
||||
|
@ -1255,14 +1255,14 @@ size_t tr_torrentFilenameToBuf(tr_torrent const* tor, char* buf, size_t buflen)
|
|||
****
|
||||
***/
|
||||
|
||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* tor, int* peer_count)
|
||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* tor, size_t* peer_count)
|
||||
{
|
||||
TR_ASSERT(tr_isTorrent(tor));
|
||||
|
||||
return tr_peerMgrPeerStats(tor, peer_count);
|
||||
}
|
||||
|
||||
void tr_torrentPeersFree(tr_peer_stat* peers, int /*peerCount*/)
|
||||
void tr_torrentPeersFree(tr_peer_stat* peers, size_t /*peerCount*/)
|
||||
{
|
||||
delete[] peers;
|
||||
}
|
||||
|
@ -2375,23 +2375,10 @@ static bool queueIsSequenced(tr_session const* session)
|
|||
std::end(torrents),
|
||||
[](auto const* a, auto const* b) { return a->queuePosition < b->queuePosition; });
|
||||
|
||||
#if 0
|
||||
|
||||
fprintf(stderr, "%s", "queue: ");
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
fprintf(stderr, "%d ", tmp[i]->queuePosition);
|
||||
}
|
||||
|
||||
fputc('\n', stderr);
|
||||
|
||||
#endif
|
||||
|
||||
/* test them */
|
||||
bool is_sequenced = true;
|
||||
|
||||
for (int i = 0, n = std::size(torrents); is_sequenced && i < n; ++i)
|
||||
for (size_t i = 0, n = std::size(torrents); is_sequenced && i < n; ++i)
|
||||
{
|
||||
is_sequenced = torrents[i]->queuePosition == i;
|
||||
}
|
||||
|
@ -2401,20 +2388,15 @@ static bool queueIsSequenced(tr_session const* session)
|
|||
|
||||
#endif
|
||||
|
||||
int tr_torrentGetQueuePosition(tr_torrent const* tor)
|
||||
size_t tr_torrentGetQueuePosition(tr_torrent const* tor)
|
||||
{
|
||||
return tor->queuePosition;
|
||||
}
|
||||
|
||||
void tr_torrentSetQueuePosition(tr_torrent* tor, int queue_position)
|
||||
void tr_torrentSetQueuePosition(tr_torrent* tor, size_t queue_position)
|
||||
{
|
||||
int back = -1;
|
||||
int const old_pos = tor->queuePosition;
|
||||
|
||||
if (queue_position < 0)
|
||||
{
|
||||
queue_position = 0;
|
||||
}
|
||||
size_t current = 0;
|
||||
auto const old_pos = tor->queuePosition;
|
||||
|
||||
tor->queuePosition = -1;
|
||||
|
||||
|
@ -2432,13 +2414,13 @@ void tr_torrentSetQueuePosition(tr_torrent* tor, int queue_position)
|
|||
walk->markChanged();
|
||||
}
|
||||
|
||||
if (back < walk->queuePosition)
|
||||
if (current < walk->queuePosition + 1)
|
||||
{
|
||||
back = walk->queuePosition;
|
||||
current = walk->queuePosition + 1;
|
||||
}
|
||||
}
|
||||
|
||||
tor->queuePosition = std::min(queue_position, back + 1);
|
||||
tor->queuePosition = std::min(queue_position, current);
|
||||
tor->markChanged();
|
||||
|
||||
TR_ASSERT(queueIsSequenced(tor->session));
|
||||
|
@ -2468,7 +2450,10 @@ void tr_torrentsQueueMoveUp(tr_torrent* const* torrents_in, size_t torrent_count
|
|||
std::sort(std::begin(torrents), std::end(torrents), CompareTorrentByQueuePosition{});
|
||||
for (auto* tor : torrents)
|
||||
{
|
||||
tr_torrentSetQueuePosition(tor, tor->queuePosition - 1);
|
||||
if (tor->queuePosition > 0)
|
||||
{
|
||||
tr_torrentSetQueuePosition(tor, tor->queuePosition - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2478,7 +2463,10 @@ void tr_torrentsQueueMoveDown(tr_torrent* const* torrents_in, size_t torrent_cou
|
|||
std::sort(std::rbegin(torrents), std::rend(torrents), CompareTorrentByQueuePosition{});
|
||||
for (auto* tor : torrents)
|
||||
{
|
||||
tr_torrentSetQueuePosition(tor, tor->queuePosition + 1);
|
||||
if (tor->queuePosition < UINT_MAX)
|
||||
{
|
||||
tr_torrentSetQueuePosition(tor, tor->queuePosition + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2488,7 +2476,7 @@ void tr_torrentsQueueMoveBottom(tr_torrent* const* torrents_in, size_t torrent_c
|
|||
std::sort(std::begin(torrents), std::end(torrents), CompareTorrentByQueuePosition{});
|
||||
for (auto* tor : torrents)
|
||||
{
|
||||
tr_torrentSetQueuePosition(tor, INT_MAX);
|
||||
tr_torrentSetQueuePosition(tor, UINT_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,9 +123,9 @@ public:
|
|||
|
||||
/// SPEED LIMIT
|
||||
|
||||
void setSpeedLimitBps(tr_direction, unsigned int bytes_per_second);
|
||||
void setSpeedLimitBps(tr_direction, tr_bytes_per_second_t bytes_per_second);
|
||||
|
||||
[[nodiscard]] unsigned int speedLimitBps(tr_direction) const;
|
||||
[[nodiscard]] tr_bytes_per_second_t speedLimitBps(tr_direction) const;
|
||||
|
||||
/// BLOCK INFO
|
||||
|
||||
|
@ -705,12 +705,12 @@ public:
|
|||
|
||||
tr_stat_errtype error = TR_STAT_OK;
|
||||
|
||||
unsigned int etaSpeed_Bps = 0;
|
||||
tr_bytes_per_second_t etaSpeed_Bps = 0;
|
||||
|
||||
int secondsDownloading = 0;
|
||||
int secondsSeeding = 0;
|
||||
time_t secondsDownloading = 0;
|
||||
time_t secondsSeeding = 0;
|
||||
|
||||
int queuePosition = 0;
|
||||
size_t queuePosition = 0;
|
||||
|
||||
tr_torrent_id_t unique_id_ = 0;
|
||||
|
||||
|
|
|
@ -823,7 +823,10 @@ extern "C"
|
|||
|
||||
int dht_random_bytes(void* buf, size_t size)
|
||||
{
|
||||
tr_rand_buffer(buf, size);
|
||||
if (!tr_rand_buffer(buf, size))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ static void event_callback(evutil_socket_t s, [[maybe_unused]] short type, void*
|
|||
auto* session = static_cast<tr_session*>(vsession);
|
||||
|
||||
socklen_t fromlen = sizeof(from);
|
||||
int const
|
||||
auto const
|
||||
rc = recvfrom(s, reinterpret_cast<char*>(std::data(buf)), std::size(buf) - 1, 0, (struct sockaddr*)&from, &fromlen);
|
||||
|
||||
/* Since most packets we receive here are µTP, make quick inline
|
||||
|
|
|
@ -24,15 +24,17 @@
|
|||
|
||||
#include "tr-macros.h"
|
||||
|
||||
using tr_file_index_t = uint32_t;
|
||||
using tr_file_index_t = size_t;
|
||||
using tr_piece_index_t = uint32_t;
|
||||
/* Assuming a 16 KiB block (tr_block_info::BlockSize), a 32-bit block index gives us a maximum torrent size of 64 TiB.
|
||||
* When we ever need to grow past that, change tr_block_index_t and tr_piece_index_t to uint64_t. */
|
||||
using tr_block_index_t = uint32_t;
|
||||
using tr_byte_index_t = uint64_t;
|
||||
using tr_tracker_tier_t = uint32_t;
|
||||
using tr_tracker_id_t = uint32_t;
|
||||
using tr_byte_index_t = uint64_t;
|
||||
using tr_torrent_id_t = int;
|
||||
using tr_bytes_per_second_t = size_t;
|
||||
using tr_kilobytes_per_second_t = size_t;
|
||||
|
||||
struct tr_block_span_t
|
||||
{
|
||||
|
@ -450,8 +452,8 @@ void tr_sessionSetUTPEnabled(tr_session* session, bool);
|
|||
bool tr_sessionIsLPDEnabled(tr_session const* session);
|
||||
void tr_sessionSetLPDEnabled(tr_session* session, bool enabled);
|
||||
|
||||
void tr_sessionSetCacheLimit_MB(tr_session* session, int mb);
|
||||
int tr_sessionGetCacheLimit_MB(tr_session const* session);
|
||||
void tr_sessionSetCacheLimit_MB(tr_session* session, size_t mb);
|
||||
size_t tr_sessionGetCacheLimit_MB(tr_session const* session);
|
||||
|
||||
tr_encryption_mode tr_sessionGetEncryption(tr_session const* session);
|
||||
void tr_sessionSetEncryption(tr_session* session, tr_encryption_mode mode);
|
||||
|
@ -501,9 +503,9 @@ enum tr_direction
|
|||
**** Primary session speed limits
|
||||
***/
|
||||
|
||||
void tr_sessionSetSpeedLimit_Bps(tr_session*, tr_direction, unsigned int bytes_per_second);
|
||||
void tr_sessionSetSpeedLimit_KBps(tr_session*, tr_direction, unsigned int kilo_per_second);
|
||||
unsigned int tr_sessionGetSpeedLimit_KBps(tr_session const*, tr_direction);
|
||||
void tr_sessionSetSpeedLimit_Bps(tr_session*, tr_direction, tr_bytes_per_second_t bytes_per_second);
|
||||
void tr_sessionSetSpeedLimit_KBps(tr_session*, tr_direction, tr_kilobytes_per_second_t kilo_per_second);
|
||||
tr_kilobytes_per_second_t tr_sessionGetSpeedLimit_KBps(tr_session const*, tr_direction);
|
||||
|
||||
void tr_sessionLimitSpeed(tr_session*, tr_direction, bool);
|
||||
bool tr_sessionIsSpeedLimited(tr_session const*, tr_direction);
|
||||
|
@ -512,8 +514,8 @@ bool tr_sessionIsSpeedLimited(tr_session const*, tr_direction);
|
|||
**** Alternative speed limits that are used during scheduled times
|
||||
***/
|
||||
|
||||
void tr_sessionSetAltSpeed_KBps(tr_session*, tr_direction, unsigned int kilo_per_second);
|
||||
unsigned int tr_sessionGetAltSpeed_KBps(tr_session const*, tr_direction);
|
||||
void tr_sessionSetAltSpeed_KBps(tr_session*, tr_direction, tr_kilobytes_per_second_t kilo_per_second);
|
||||
tr_kilobytes_per_second_t tr_sessionGetAltSpeed_KBps(tr_session const*, tr_direction);
|
||||
|
||||
void tr_sessionUseAltSpeed(tr_session*, bool);
|
||||
bool tr_sessionUsesAltSpeed(tr_session const*);
|
||||
|
@ -613,11 +615,11 @@ bool tr_sessionGetAntiBruteForceEnabled(tr_session const*);
|
|||
void tr_torrentStartNow(tr_torrent*);
|
||||
|
||||
/** @brief Return the queued torrent's position in the queue it's in. [0...n) */
|
||||
int tr_torrentGetQueuePosition(tr_torrent const*);
|
||||
size_t tr_torrentGetQueuePosition(tr_torrent const*);
|
||||
|
||||
/** @brief Set the queued torrent's position in the queue it's in.
|
||||
* Special cases: pos <= 0 moves to the front; pos >= queue length moves to the back */
|
||||
void tr_torrentSetQueuePosition(tr_torrent*, int queue_position);
|
||||
void tr_torrentSetQueuePosition(tr_torrent*, size_t queue_position);
|
||||
|
||||
/**
|
||||
**/
|
||||
|
@ -638,10 +640,10 @@ void tr_torrentsQueueMoveBottom(tr_torrent* const* torrents, size_t torrent_coun
|
|||
**/
|
||||
|
||||
/** @brief Set the number of torrents allowed to download (if direction is TR_DOWN) or seed (if direction is TR_UP) at the same time */
|
||||
void tr_sessionSetQueueSize(tr_session*, tr_direction, int max_simultaneous_seed_torrents);
|
||||
void tr_sessionSetQueueSize(tr_session*, tr_direction, size_t max_simultaneous_seed_torrents);
|
||||
|
||||
/** @brief Return the number of torrents allowed to download (if direction is TR_DOWN) or seed (if direction is TR_UP) at the same time */
|
||||
int tr_sessionGetQueueSize(tr_session const*, tr_direction);
|
||||
size_t tr_sessionGetQueueSize(tr_session const*, tr_direction);
|
||||
|
||||
/** @brief Set whether or not to limit how many torrents can download (TR_DOWN) or seed (TR_UP) at the same time */
|
||||
void tr_sessionSetQueueEnabled(tr_session*, tr_direction, bool do_limit_simultaneous_seed_torrents);
|
||||
|
@ -970,7 +972,7 @@ uint64_t tr_torrentGetBytesLeftToAllocate(tr_torrent const* torrent);
|
|||
*/
|
||||
tr_torrent_id_t tr_torrentId(tr_torrent const* torrent);
|
||||
|
||||
tr_torrent* tr_torrentFindFromId(tr_session* session, int id);
|
||||
tr_torrent* tr_torrentFindFromId(tr_session* session, tr_torrent_id_t id);
|
||||
|
||||
tr_torrent* tr_torrentFindFromMetainfo(tr_session*, tr_torrent_metainfo const*);
|
||||
|
||||
|
@ -1009,8 +1011,8 @@ size_t tr_torrentFindFileToBuf(tr_torrent const* tor, tr_file_index_t file_num,
|
|||
****
|
||||
***/
|
||||
|
||||
void tr_torrentSetSpeedLimit_KBps(tr_torrent*, tr_direction, unsigned int kilo_per_second);
|
||||
unsigned int tr_torrentGetSpeedLimit_KBps(tr_torrent const*, tr_direction);
|
||||
void tr_torrentSetSpeedLimit_KBps(tr_torrent*, tr_direction, tr_kilobytes_per_second_t kilo_per_second);
|
||||
tr_kilobytes_per_second_t tr_torrentGetSpeedLimit_KBps(tr_torrent const*, tr_direction);
|
||||
|
||||
void tr_torrentUseSpeedLimit(tr_torrent*, tr_direction, bool);
|
||||
bool tr_torrentUsesSpeedLimit(tr_torrent const*, tr_direction);
|
||||
|
@ -1284,15 +1286,15 @@ struct tr_peer_stat
|
|||
uint32_t cancelsToClient;
|
||||
|
||||
/* how many requests the peer has made that we haven't responded to yet */
|
||||
int activeReqsToClient;
|
||||
size_t activeReqsToClient;
|
||||
|
||||
/* how many requests we've made and are currently awaiting a response for */
|
||||
int activeReqsToPeer;
|
||||
size_t activeReqsToPeer;
|
||||
};
|
||||
|
||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* torrent, int* peer_count);
|
||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* torrent, size_t* peer_count);
|
||||
|
||||
void tr_torrentPeersFree(tr_peer_stat* peerStats, int peerCount);
|
||||
void tr_torrentPeersFree(tr_peer_stat* peerStats, size_t peerCount);
|
||||
|
||||
/***
|
||||
**** tr_tracker_stat
|
||||
|
@ -1396,7 +1398,7 @@ struct tr_webseed_view
|
|||
{
|
||||
char const* url; // the url to download from
|
||||
bool is_downloading; // can be true even if speed is 0, e.g. slow download
|
||||
unsigned download_bytes_per_second; // current download speed
|
||||
tr_bytes_per_second_t download_bytes_per_second; // current download speed
|
||||
};
|
||||
|
||||
struct tr_webseed_view tr_torrentWebseed(tr_torrent const* torrent, size_t nth);
|
||||
|
@ -1485,6 +1487,11 @@ enum
|
|||
TR_PEER_FROM_LTEP, /* peer address provided in an LTEP handshake */
|
||||
TR_PEER_FROM__MAX
|
||||
};
|
||||
enum
|
||||
{
|
||||
TR_ETA_NOT_AVAIL = -1,
|
||||
TR_ETA_UNKNOWN = -2,
|
||||
};
|
||||
|
||||
enum tr_stat_errtype
|
||||
{
|
||||
|
@ -1606,26 +1613,24 @@ struct tr_stat
|
|||
|
||||
/** Number of seconds since the last activity (or since started).
|
||||
-1 if activity is not seeding or downloading. */
|
||||
int idleSecs;
|
||||
time_t idleSecs;
|
||||
|
||||
/** Cumulative seconds the torrent's ever spent downloading */
|
||||
int secondsDownloading;
|
||||
time_t secondsDownloading;
|
||||
|
||||
/** Cumulative seconds the torrent's ever spent seeding */
|
||||
int secondsSeeding;
|
||||
time_t secondsSeeding;
|
||||
|
||||
/** This torrent's queue position.
|
||||
All torrents have a queue position, even if it's not queued. */
|
||||
int queuePosition;
|
||||
size_t queuePosition;
|
||||
|
||||
#define TR_ETA_NOT_AVAIL (-1)
|
||||
#define TR_ETA_UNKNOWN (-2)
|
||||
/** If downloading, estimated number of seconds left until the torrent is done.
|
||||
If seeding, estimated number of seconds left until seed ratio is reached. */
|
||||
int eta;
|
||||
time_t eta;
|
||||
|
||||
/** If seeding, number of seconds left until the idle time limit is reached. */
|
||||
int etaIdle;
|
||||
time_t etaIdle;
|
||||
|
||||
/** What is this torrent doing right now? */
|
||||
tr_torrent_activity activity;
|
||||
|
|
|
@ -546,7 +546,7 @@ bool parseNumberSection(std::string_view str, number_range& range)
|
|||
{
|
||||
auto constexpr Delimiter = "-"sv;
|
||||
|
||||
auto const first = tr_parseNum<size_t>(str, &str);
|
||||
auto const first = tr_parseNum<int>(str, &str);
|
||||
if (!first)
|
||||
{
|
||||
return false;
|
||||
|
@ -564,7 +564,7 @@ bool parseNumberSection(std::string_view str, number_range& range)
|
|||
}
|
||||
|
||||
str.remove_prefix(std::size(Delimiter));
|
||||
auto const second = tr_parseNum<size_t>(str);
|
||||
auto const second = tr_parseNum<int>(str);
|
||||
if (!second)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -328,26 +328,24 @@ extern uint64_t tr_size_K; /* unused? */
|
|||
|
||||
void tr_formatter_get_units(void* dict);
|
||||
|
||||
[[nodiscard]] static inline unsigned int tr_toSpeedBytes(unsigned int KBps)
|
||||
[[nodiscard]] static inline size_t tr_toSpeedBytes(size_t KBps)
|
||||
{
|
||||
return KBps * tr_speed_K;
|
||||
}
|
||||
|
||||
[[nodiscard]] static inline auto tr_toSpeedKBps(unsigned int Bps)
|
||||
[[nodiscard]] static inline auto tr_toSpeedKBps(size_t Bps)
|
||||
{
|
||||
return Bps / double(tr_speed_K);
|
||||
}
|
||||
|
||||
[[nodiscard]] static inline auto tr_toMemBytes(unsigned int MB)
|
||||
[[nodiscard]] static inline auto tr_toMemBytes(size_t MB)
|
||||
{
|
||||
auto B = uint64_t(tr_mem_K) * tr_mem_K;
|
||||
B *= MB;
|
||||
return B;
|
||||
return uint64_t(tr_mem_K) * tr_mem_K * MB;
|
||||
}
|
||||
|
||||
[[nodiscard]] static inline auto tr_toMemMB(uint64_t B)
|
||||
{
|
||||
return int(B / (tr_mem_K * tr_mem_K));
|
||||
return size_t(B / (tr_mem_K * tr_mem_K));
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
|
@ -39,7 +39,7 @@ using namespace std::literals;
|
|||
using Buffer = libtransmission::Buffer;
|
||||
|
||||
/* arbitrary value... this is much deeper than our code goes */
|
||||
static auto constexpr MaxDepth = int{ 64 };
|
||||
static auto constexpr MaxDepth = size_t{ 64 };
|
||||
|
||||
struct json_wrapper_data
|
||||
{
|
||||
|
@ -316,7 +316,7 @@ static void action_callback_POP(
|
|||
}
|
||||
else if (state->type == JSONSL_T_LIST || state->type == JSONSL_T_OBJECT)
|
||||
{
|
||||
int const depth = std::size(data->stack);
|
||||
auto const depth = std::size(data->stack);
|
||||
auto const* const v = data->stack.back();
|
||||
data->stack.pop_back();
|
||||
if (depth < MaxDepth)
|
||||
|
|
|
@ -188,9 +188,12 @@ public:
|
|||
return tr_torrentFindFromId(session, torrent_id);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool isTransferringPieces(uint64_t now, tr_direction dir, unsigned int* setme_bytes_per_second) const override
|
||||
[[nodiscard]] bool isTransferringPieces( //
|
||||
uint64_t now,
|
||||
tr_direction dir,
|
||||
tr_bytes_per_second_t* setme_bytes_per_second) const override
|
||||
{
|
||||
unsigned int bytes_per_second = 0;
|
||||
tr_bytes_per_second_t bytes_per_second = 0;
|
||||
bool is_active = false;
|
||||
|
||||
if (dir == TR_DOWN)
|
||||
|
@ -547,7 +550,7 @@ tr_webseed_view tr_webseedView(tr_peer const* peer)
|
|||
return {};
|
||||
}
|
||||
|
||||
auto bytes_per_second = unsigned{ 0 };
|
||||
auto bytes_per_second = tr_bytes_per_second_t{ 0 };
|
||||
auto const is_downloading = peer->isTransferringPieces(tr_time_msec(), TR_DOWN, &bytes_per_second);
|
||||
return { w->base_url.c_str(), is_downloading, bytes_per_second };
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ BlocklistDownloader* fBLDownloader = nil;
|
|||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
int const count = tr_blocklistSetContent(((Controller*)NSApp.delegate).sessionHandle, blocklistFile.UTF8String);
|
||||
auto const count = tr_blocklistSetContent(((Controller*)NSApp.delegate).sessionHandle, blocklistFile.UTF8String);
|
||||
|
||||
//delete downloaded file
|
||||
[NSFileManager.defaultManager removeItemAtPath:blocklistFile error:nil];
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
self.fUploadLimitField.intValue = [self.fDefaults integerForKey:@"UploadLimit"];
|
||||
self.fDownloadLimitField.intValue = [self.fDefaults integerForKey:@"DownloadLimit"];
|
||||
self.fUploadLimitField.integerValue = [self.fDefaults integerForKey:@"UploadLimit"];
|
||||
self.fDownloadLimitField.integerValue = [self.fDefaults integerForKey:@"DownloadLimit"];
|
||||
|
||||
self.fRatioStopField.floatValue = [self.fDefaults floatForKey:@"RatioLimit"];
|
||||
self.fIdleStopField.integerValue = [self.fDefaults integerForKey:@"IdleLimitMinutes"];
|
||||
|
|
|
@ -246,7 +246,7 @@ static CGFloat const kStackViewSpacing = 8.0;
|
|||
self.fUploadLimitField.enabled = uploadUseSpeedLimit == NSControlStateValueOn;
|
||||
if (uploadSpeedLimit != kInvalidValue)
|
||||
{
|
||||
self.fUploadLimitField.intValue = uploadSpeedLimit;
|
||||
self.fUploadLimitField.integerValue = uploadSpeedLimit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -261,7 +261,7 @@ static CGFloat const kStackViewSpacing = 8.0;
|
|||
self.fDownloadLimitField.enabled = downloadUseSpeedLimit == NSControlStateValueOn;
|
||||
if (downloadSpeedLimit != kInvalidValue)
|
||||
{
|
||||
self.fDownloadLimitField.intValue = downloadSpeedLimit;
|
||||
self.fDownloadLimitField.integerValue = downloadSpeedLimit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -436,7 +436,7 @@ static CGFloat const kStackViewSpacing = 8.0;
|
|||
self.fPeersConnectLabel.enabled = YES;
|
||||
if (maxPeers != kInvalidValue)
|
||||
{
|
||||
self.fPeersConnectField.intValue = maxPeers;
|
||||
self.fPeersConnectField.integerValue = maxPeers;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -257,7 +257,7 @@ static NSTimeInterval const kUpdateSeconds = 0.75;
|
|||
NSString* name = !std::empty(currentMessage->name) ? @(currentMessage->name.c_str()) : NSProcessInfo.processInfo.processName;
|
||||
|
||||
auto const file_string = std::string{ currentMessage->file };
|
||||
NSString* file = [(@(file_string.c_str())).lastPathComponent stringByAppendingFormat:@":%d", currentMessage->line];
|
||||
NSString* file = [(@(file_string.c_str())).lastPathComponent stringByAppendingFormat:@":%ld", currentMessage->line];
|
||||
|
||||
NSDictionary* message = @{
|
||||
@"Message" : @(currentMessage->message.c_str()),
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
|
||||
@property(nonatomic, readonly) NSArray<NSString*>* sounds;
|
||||
|
||||
+ (NSInteger)dateToTimeSum:(NSDate*)date;
|
||||
/// - returns: number of minutes
|
||||
+ (int)dateToTimeSum:(NSDate*)date;
|
||||
|
||||
- (instancetype)initWithHandle:(tr_session*)handle;
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ static ToolbarTab const ToolbarTabPeers = @"TOOLBAR_PEERS";
|
|||
static ToolbarTab const ToolbarTabNetwork = @"TOOLBAR_NETWORK";
|
||||
static ToolbarTab const ToolbarTabRemote = @"TOOLBAR_REMOTE";
|
||||
|
||||
static char* const kRPCKeychainService = "Transmission:Remote";
|
||||
static char* const kRPCKeychainName = "Remote";
|
||||
static char const* const kRPCKeychainService = "Transmission:Remote";
|
||||
static char const* const kRPCKeychainName = "Remote";
|
||||
|
||||
static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
||||
|
||||
|
@ -235,11 +235,11 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
[self updateLimitFields];
|
||||
|
||||
//set speed limit
|
||||
self.fSpeedLimitUploadField.intValue = [self.fDefaults integerForKey:@"SpeedLimitUploadLimit"];
|
||||
self.fSpeedLimitDownloadField.intValue = [self.fDefaults integerForKey:@"SpeedLimitDownloadLimit"];
|
||||
self.fSpeedLimitUploadField.integerValue = [self.fDefaults integerForKey:@"SpeedLimitUploadLimit"];
|
||||
self.fSpeedLimitDownloadField.integerValue = [self.fDefaults integerForKey:@"SpeedLimitDownloadLimit"];
|
||||
|
||||
//set port
|
||||
self.fPortField.intValue = [self.fDefaults integerForKey:@"BindPort"];
|
||||
self.fPortField.intValue = static_cast<int>([self.fDefaults integerForKey:@"BindPort"]);
|
||||
self.fNatStatus = -1;
|
||||
|
||||
[self updatePortStatus];
|
||||
|
@ -248,13 +248,13 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
repeats:YES];
|
||||
|
||||
//set peer connections
|
||||
self.fPeersGlobalField.intValue = [self.fDefaults integerForKey:@"PeersTotal"];
|
||||
self.fPeersTorrentField.intValue = [self.fDefaults integerForKey:@"PeersTorrent"];
|
||||
self.fPeersGlobalField.integerValue = [self.fDefaults integerForKey:@"PeersTotal"];
|
||||
self.fPeersTorrentField.integerValue = [self.fDefaults integerForKey:@"PeersTorrent"];
|
||||
|
||||
//set queue values
|
||||
self.fQueueDownloadField.intValue = [self.fDefaults integerForKey:@"QueueDownloadNumber"];
|
||||
self.fQueueSeedField.intValue = [self.fDefaults integerForKey:@"QueueSeedNumber"];
|
||||
self.fStalledField.intValue = [self.fDefaults integerForKey:@"StalledMinutes"];
|
||||
self.fQueueDownloadField.integerValue = [self.fDefaults integerForKey:@"QueueDownloadNumber"];
|
||||
self.fQueueSeedField.integerValue = [self.fDefaults integerForKey:@"QueueSeedNumber"];
|
||||
self.fStalledField.integerValue = [self.fDefaults integerForKey:@"StalledMinutes"];
|
||||
|
||||
//set blocklist
|
||||
NSString* blocklistURL = [self.fDefaults stringForKey:@"BlocklistURL"];
|
||||
|
@ -286,7 +286,7 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
object:self.fBlocklistURLField];
|
||||
|
||||
//set rpc port
|
||||
self.fRPCPortField.intValue = [self.fDefaults integerForKey:@"RPCPort"];
|
||||
self.fRPCPortField.intValue = static_cast<int>([self.fDefaults integerForKey:@"RPCPort"]);
|
||||
|
||||
//set rpc password
|
||||
if (self.fRPCPassword)
|
||||
|
@ -752,19 +752,19 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
return;
|
||||
}
|
||||
|
||||
self.fUploadField.intValue = [self.fDefaults integerForKey:@"UploadLimit"];
|
||||
self.fDownloadField.intValue = [self.fDefaults integerForKey:@"DownloadLimit"];
|
||||
self.fUploadField.integerValue = [self.fDefaults integerForKey:@"UploadLimit"];
|
||||
self.fDownloadField.integerValue = [self.fDefaults integerForKey:@"DownloadLimit"];
|
||||
}
|
||||
|
||||
- (void)setGlobalLimit:(id)sender
|
||||
{
|
||||
[self.fDefaults setInteger:[sender intValue] forKey:sender == self.fUploadField ? @"UploadLimit" : @"DownloadLimit"];
|
||||
[self.fDefaults setInteger:[sender integerValue] forKey:sender == self.fUploadField ? @"UploadLimit" : @"DownloadLimit"];
|
||||
[self applySpeedSettings:self];
|
||||
}
|
||||
|
||||
- (void)setSpeedLimit:(id)sender
|
||||
{
|
||||
[self.fDefaults setInteger:[sender intValue]
|
||||
[self.fDefaults setInteger:[sender integerValue]
|
||||
forKey:sender == self.fSpeedLimitUploadField ? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"];
|
||||
[self applyAltSpeedSettings];
|
||||
}
|
||||
|
@ -785,14 +785,14 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
tr_sessionSetAltSpeedDay(self.fHandle, static_cast<tr_sched_day>([sender selectedItem].tag));
|
||||
}
|
||||
|
||||
+ (NSInteger)dateToTimeSum:(NSDate*)date
|
||||
+ (int)dateToTimeSum:(NSDate*)date
|
||||
{
|
||||
NSCalendar* calendar = NSCalendar.currentCalendar;
|
||||
NSDateComponents* components = [calendar components:NSCalendarUnitHour | NSCalendarUnitMinute fromDate:date];
|
||||
return components.hour * 60 + components.minute;
|
||||
return static_cast<int>(components.hour * 60 + components.minute);
|
||||
}
|
||||
|
||||
+ (NSDate*)timeSumToDate:(NSInteger)sum
|
||||
+ (NSDate*)timeSumToDate:(int)sum
|
||||
{
|
||||
NSDateComponents* comps = [[NSDateComponents alloc] init];
|
||||
comps.hour = sum / 60;
|
||||
|
@ -866,7 +866,7 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
|
||||
- (void)setQueueNumber:(id)sender
|
||||
{
|
||||
int const number = [sender intValue];
|
||||
NSInteger const number = [sender integerValue];
|
||||
BOOL const seed = sender == self.fQueueSeedField;
|
||||
|
||||
[self.fDefaults setInteger:number forKey:seed ? @"QueueSeedNumber" : @"QueueDownloadNumber"];
|
||||
|
@ -1168,7 +1168,7 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
{
|
||||
if ([self.fDefaults boolForKey:@"RPC"] && [self.fDefaults boolForKey:@"RPCWebDiscovery"])
|
||||
{
|
||||
[BonjourController.defaultController startWithPort:[self.fDefaults integerForKey:@"RPCPort"]];
|
||||
[BonjourController.defaultController startWithPort:static_cast<int>([self.fDefaults integerForKey:@"RPCPort"])];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1385,14 +1385,14 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
BOOL const downLimitEnabled = tr_sessionIsSpeedLimited(self.fHandle, TR_DOWN);
|
||||
[self.fDefaults setBool:downLimitEnabled forKey:@"CheckDownload"];
|
||||
|
||||
int const downLimit = tr_sessionGetSpeedLimit_KBps(self.fHandle, TR_DOWN);
|
||||
auto const downLimit = tr_sessionGetSpeedLimit_KBps(self.fHandle, TR_DOWN);
|
||||
[self.fDefaults setInteger:downLimit forKey:@"DownloadLimit"];
|
||||
|
||||
//speed limit - up
|
||||
BOOL const upLimitEnabled = tr_sessionIsSpeedLimited(self.fHandle, TR_UP);
|
||||
[self.fDefaults setBool:upLimitEnabled forKey:@"CheckUpload"];
|
||||
|
||||
int const upLimit = tr_sessionGetSpeedLimit_KBps(self.fHandle, TR_UP);
|
||||
auto const upLimit = tr_sessionGetSpeedLimit_KBps(self.fHandle, TR_UP);
|
||||
[self.fDefaults setInteger:upLimit forKey:@"UploadLimit"];
|
||||
|
||||
//alt speed limit enabled
|
||||
|
@ -1400,11 +1400,11 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
[self.fDefaults setBool:useAltSpeed forKey:@"SpeedLimit"];
|
||||
|
||||
//alt speed limit - down
|
||||
int const downLimitAlt = tr_sessionGetAltSpeed_KBps(self.fHandle, TR_DOWN);
|
||||
auto const downLimitAlt = tr_sessionGetAltSpeed_KBps(self.fHandle, TR_DOWN);
|
||||
[self.fDefaults setInteger:downLimitAlt forKey:@"SpeedLimitDownloadLimit"];
|
||||
|
||||
//alt speed limit - up
|
||||
int const upLimitAlt = tr_sessionGetAltSpeed_KBps(self.fHandle, TR_UP);
|
||||
auto const upLimitAlt = tr_sessionGetAltSpeed_KBps(self.fHandle, TR_UP);
|
||||
[self.fDefaults setInteger:upLimitAlt forKey:@"SpeedLimitUploadLimit"];
|
||||
|
||||
//alt speed limit schedule
|
||||
|
@ -1445,13 +1445,13 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
BOOL const downloadQueue = tr_sessionGetQueueEnabled(self.fHandle, TR_DOWN);
|
||||
[self.fDefaults setBool:downloadQueue forKey:@"Queue"];
|
||||
|
||||
int const downloadQueueNum = tr_sessionGetQueueSize(self.fHandle, TR_DOWN);
|
||||
size_t const downloadQueueNum = tr_sessionGetQueueSize(self.fHandle, TR_DOWN);
|
||||
[self.fDefaults setInteger:downloadQueueNum forKey:@"QueueDownloadNumber"];
|
||||
|
||||
BOOL const seedQueue = tr_sessionGetQueueEnabled(self.fHandle, TR_UP);
|
||||
[self.fDefaults setBool:seedQueue forKey:@"QueueSeed"];
|
||||
|
||||
int const seedQueueNum = tr_sessionGetQueueSize(self.fHandle, TR_UP);
|
||||
size_t const seedQueueNum = tr_sessionGetQueueSize(self.fHandle, TR_UP);
|
||||
[self.fDefaults setInteger:seedQueueNum forKey:@"QueueSeedNumber"];
|
||||
|
||||
BOOL const checkStalled = tr_sessionGetQueueStalledEnabled(self.fHandle);
|
||||
|
@ -1490,14 +1490,14 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
//random port handled by bindings
|
||||
|
||||
//limit check handled by bindings
|
||||
self.fDownloadField.intValue = downLimit;
|
||||
self.fDownloadField.integerValue = downLimit;
|
||||
|
||||
//limit check handled by bindings
|
||||
self.fUploadField.intValue = upLimit;
|
||||
self.fUploadField.integerValue = upLimit;
|
||||
|
||||
self.fSpeedLimitDownloadField.intValue = downLimitAlt;
|
||||
self.fSpeedLimitDownloadField.integerValue = downLimitAlt;
|
||||
|
||||
self.fSpeedLimitUploadField.intValue = upLimitAlt;
|
||||
self.fSpeedLimitUploadField.integerValue = upLimitAlt;
|
||||
|
||||
//speed limit schedule handled by bindings
|
||||
|
||||
|
@ -1514,8 +1514,8 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/";
|
|||
self.fIdleStopField.integerValue = idleLimitMin;
|
||||
|
||||
//queues enabled handled by bindings
|
||||
self.fQueueDownloadField.intValue = downloadQueueNum;
|
||||
self.fQueueSeedField.intValue = seedQueueNum;
|
||||
self.fQueueDownloadField.integerValue = downloadQueueNum;
|
||||
self.fQueueSeedField.integerValue = seedQueueNum;
|
||||
|
||||
//check stalled handled by bindings
|
||||
self.fStalledField.intValue = stalledMinutes;
|
||||
|
|
|
@ -931,12 +931,12 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error)
|
|||
|
||||
- (NSArray<NSDictionary*>*)peers
|
||||
{
|
||||
int totalPeers;
|
||||
size_t totalPeers;
|
||||
tr_peer_stat* peers = tr_torrentPeers(self.fHandle, &totalPeers);
|
||||
|
||||
NSMutableArray* peerDicts = [NSMutableArray arrayWithCapacity:totalPeers];
|
||||
|
||||
for (int i = 0; i < totalPeers; i++)
|
||||
for (size_t i = 0; i < totalPeers; i++)
|
||||
{
|
||||
tr_peer_stat* peer = &peers[i];
|
||||
NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithCapacity:12];
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8456a5b5c99ef4544a2ed8e8f20a2fb673dd4192
|
||||
Subproject commit 35bb415f70709884130f30eb24972dc13cf095a9
|
|
@ -122,7 +122,7 @@ static std::string etaToString(int64_t eta)
|
|||
return fmt::format(FMT_STRING("{:d} days"), eta / (60 * 60 * 24));
|
||||
}
|
||||
|
||||
static std::string tr_strltime(int seconds)
|
||||
static std::string tr_strltime(time_t seconds)
|
||||
{
|
||||
if (seconds < 0)
|
||||
{
|
||||
|
@ -372,7 +372,7 @@ static void showUsage(void)
|
|||
tr_getopt_usage(MyName, Usage, std::data(Options));
|
||||
}
|
||||
|
||||
static int numarg(char const* arg)
|
||||
static long numarg(char const* arg)
|
||||
{
|
||||
char* end = nullptr;
|
||||
long const num = strtol(arg, &end, 10);
|
||||
|
@ -927,7 +927,7 @@ static void printDetails(tr_variant* top)
|
|||
|
||||
if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents))
|
||||
{
|
||||
for (int ti = 0, tCount = tr_variantListSize(torrents); ti < tCount; ++ti)
|
||||
for (size_t ti = 0, tCount = tr_variantListSize(torrents); ti < tCount; ++ti)
|
||||
{
|
||||
tr_variant* t = tr_variantListChild(torrents, ti);
|
||||
tr_variant* l;
|
||||
|
@ -1256,7 +1256,7 @@ static void printFileList(tr_variant* top)
|
|||
|
||||
if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents))
|
||||
{
|
||||
for (int i = 0, in = tr_variantListSize(torrents); i < in; ++i)
|
||||
for (size_t i = 0, in = tr_variantListSize(torrents); i < in; ++i)
|
||||
{
|
||||
tr_variant* d = tr_variantListChild(torrents, i);
|
||||
tr_variant* files;
|
||||
|
@ -1267,11 +1267,11 @@ static void printFileList(tr_variant* top)
|
|||
if (tr_variantDictFindStrView(d, TR_KEY_name, &name) && tr_variantDictFindList(d, TR_KEY_files, &files) &&
|
||||
tr_variantDictFindList(d, TR_KEY_priorities, &priorities) && tr_variantDictFindList(d, TR_KEY_wanted, &wanteds))
|
||||
{
|
||||
int const jn = tr_variantListSize(files);
|
||||
auto const jn = tr_variantListSize(files);
|
||||
fmt::print("{:s} ({:d} files):\n", name, jn);
|
||||
printf("%3s %4s %8s %3s %9s %s\n", "#", "Done", "Priority", "Get", "Size", "Name");
|
||||
|
||||
for (int j = 0; j < jn; ++j)
|
||||
for (size_t j = 0; j < jn; ++j)
|
||||
{
|
||||
int64_t have;
|
||||
int64_t length;
|
||||
|
@ -1323,7 +1323,7 @@ static void printPeersImpl(tr_variant* peers)
|
|||
{
|
||||
printf("%-40s %-12s %-5s %-6s %-6s %s\n", "Address", "Flags", "Done", "Down", "Up", "Client");
|
||||
|
||||
for (int i = 0, n = tr_variantListSize(peers); i < n; ++i)
|
||||
for (size_t i = 0, n = tr_variantListSize(peers); i < n; ++i)
|
||||
{
|
||||
auto address = std::string_view{};
|
||||
auto client = std::string_view{};
|
||||
|
@ -1359,7 +1359,7 @@ static void printPeers(tr_variant* top)
|
|||
|
||||
if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents))
|
||||
{
|
||||
for (int i = 0, n = tr_variantListSize(torrents); i < n; ++i)
|
||||
for (size_t i = 0, n = tr_variantListSize(torrents); i < n; ++i)
|
||||
{
|
||||
tr_variant* peers;
|
||||
tr_variant* torrent = tr_variantListChild(torrents, i);
|
||||
|
@ -1409,7 +1409,7 @@ static void printPieces(tr_variant* top)
|
|||
|
||||
if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents))
|
||||
{
|
||||
for (int i = 0, n = tr_variantListSize(torrents); i < n; ++i)
|
||||
for (size_t i = 0, n = tr_variantListSize(torrents); i < n; ++i)
|
||||
{
|
||||
int64_t j;
|
||||
auto raw = std::string_view{};
|
||||
|
@ -1468,7 +1468,7 @@ static void printTorrentList(tr_variant* top)
|
|||
"Status",
|
||||
"Name");
|
||||
|
||||
for (int i = 0, n = tr_variantListSize(list); i < n; ++i)
|
||||
for (size_t i = 0, n = tr_variantListSize(list); i < n; ++i)
|
||||
{
|
||||
int64_t torId;
|
||||
int64_t eta;
|
||||
|
@ -1680,7 +1680,7 @@ static void printTrackers(tr_variant* top)
|
|||
|
||||
if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents))
|
||||
{
|
||||
for (int i = 0, n = tr_variantListSize(torrents); i < n; ++i)
|
||||
for (size_t i = 0, n = tr_variantListSize(torrents); i < n; ++i)
|
||||
{
|
||||
tr_variant* trackerStats;
|
||||
tr_variant* torrent = tr_variantListChild(torrents, i);
|
||||
|
@ -2021,7 +2021,7 @@ static void filterIds(tr_variant* top, Config& config)
|
|||
arg = &config.filter[pos + 2];
|
||||
}
|
||||
|
||||
for (int i = 0, n = tr_variantListSize(list); i < n; ++i)
|
||||
for (size_t i = 0, n = tr_variantListSize(list); i < n; ++i)
|
||||
{
|
||||
tr_variant* d = tr_variantListChild(list, i);
|
||||
int64_t torId;
|
||||
|
|
Loading…
Reference in New Issue