Commit Graph

70 Commits

Author SHA1 Message Date
Charles Kerr 25fdb5805c
refactor: use tr_torrent_id_t (#3314)
* refactor: use semantic type tr_torrent_type_t in libtransmission

* refactor: use semantic type tr_torrent_type_t in gtk client

* refactor: use semantic type tr_torrent_type_t in qt client
2022-06-17 10:43:04 -05:00
Dmytro Lytovchenko d34bd0b4d6
refactor: modernize cache.cc (#3108)
* Modernize cache.cc: Convert tr_cache to a class

* Modernize cache.cc: Replaced ptrArray with vector

* refactor: Cache now takes a tr_torrents reference

* refactor: add Key type to Cache

* refactor: avoid std::back_inserter

* refactor: add Cache::flushOldest()
2022-06-11 19:46:30 -05:00
Charles Kerr 75a7c5f080
refactor: add tr_peerMsgs.networkSocket() (#3175) 2022-06-01 21:33:33 -05:00
Charles Kerr f71ace588f
fix: assertion failed: task->loc.byte <= task->end_byte (#3109) 2022-05-18 15:49:40 -05:00
Charles Kerr d4e1b32e38
fix: corruptin when downloading webseeds (#2978)
Fixes #2909.
2022-04-24 12:46:44 -05:00
Charles Kerr b256da02e3
refactor: remove unused macros (#2897)
* refactor: remove unused fu nction tr_lowerBound()

* refactor: tr_timerAdd() takes a reference, not a pointer

* refactor: tr_timerAddMsec() takes a reference, not a pointer

* refactor: tr_moveFile() takes a reference, not a pointer

* refactor: tr_wildmat() takes std::string_views

* refactor: remove unused macro TR_GNUC_NONNULL

* refactor: remove unused macro TR_GNUC_PRINTF

* refactor: remove unused macro TR_GNUC_NULL_TERMINATED

* refactor: remove unused macro TR_GNUC_HOT

* refactor: remove unused macro __has_feature

* refactor: remove unused macro __has_attribute

* refactor: remove unused macro TR_DEPRECATED

* refactor: remove unused macro TR_DISABLE_COPY_MOVE
2022-04-07 19:20:29 -05:00
Charles Kerr 80dd460773
refactor: annotate nodiscard, constexpr, noexcept methods (#2879) 2022-04-04 22:51:56 -05:00
Charles Kerr e4461c48d7
refactor: prefer FMT_STRING (#2845)
* use FMT_STRING in libtr client on non-i18n strings

This gives compile-time safety checks.
2022-03-30 14:59:13 -05:00
Charles Kerr 2996e223dd
refactor: strbuf for metainfo files (#2833)
* refactor: tr_ctorSaveContents takes a string_view filename

* refactor: remove tr_ctorSaveMagnetContents

* refactor: announce_list::save takes a std::string_view

* refactor: magnet() takes an OutputIt arg

Generate the magnet link URL into an output iterator

* refactor: remove deprecated calls to tr_http_escape

* refactor: tr_torrent.torrentFile takes an OutputIterator

* refactor: tr_torrent.torrentFile returns a tr_pathbuf

* refactor: tr_torrent_metainfo.makeFilename returns a tr_pathbuf

* refactor: use tr_urlbuf in announcer-http
2022-03-28 17:13:32 -05:00
Charles Kerr b94c6796c8
fix: sonarcloud warnings (#2815)
* fix: add default case to switch statement

* fix: remove redundant static specifier

* fix: use std::optional.value_or

* fix: make type of variable pointer-to-const

* refactor: move log state into a struct

* refactor: make tr_peerMgr constructor explicit

* fix: make type of variable pointer-to-const

* fix: replace insert with try_emplace

* fix: implicit conversion may lose precision

* fix: use init-statement to reduce variable scope

* chore: mark unused return value with (void)
2022-03-25 00:24:04 -05:00
Charles Kerr b8c3778cf4
fix: sonarcloud warnings (#2804)
* fix: break will never be executed

* refactor: compile the name fallback string

* fix: replace redundant type with auto

* fix: use init-statement to reduce variable scope

* fix: implicit conversion loses precision

* fix: use in-class initializer

* fix: make variable a pointer-to-const

* fix: local variable name shadows class variable

* fix: implicit conversion may lose precision
2022-03-24 00:18:41 -05:00
Charles Kerr 22499c677a
refactor: aggregate bandwidth objects (#2783) 2022-03-18 11:34:29 -05:00
Charles Kerr cdd819772d
feat: tr_runInEventThread() now takes std::function, typesafe args (#2739) 2022-03-04 20:26:03 -08:00
Charles Kerr 0cd3eb26ff
fix: webseed assertion failures (#2735) 2022-03-04 12:00:42 -08:00
Charles Kerr 412ebc63c6
fixup: webseed (#2712)
* fixup! refactor: tr_webseed simplification (#2613)

call connection_limiter.taskStarted in the right place

* perf: put web thread to sleep when inactive
2022-02-25 14:45:00 -06:00
Charles Kerr 7238724318
refactor: webseed (#2689)
* refactor: reduce nested conditional webseed logic

* refactor: use tr_block_info::Location in webseed

* request larger chunks at a time from webseeds

* fix: CURLOPT_MAXREDIRS to safeguard against loops

Discussion at https://trac.transmissionbt.com/ticket/6110 .
Reported by @x190 and @cfpp2p a few years back.
2022-02-23 07:38:18 -06:00
Charles Kerr 78ad90a4c5
refactor: use tr_block_info::Location in inout.cc (#2658) 2022-02-19 10:07:08 -06:00
Charles Kerr 87d9f9b00a
refactor: use tr_block_info::Location in cache.cc (#2652) 2022-02-19 07:45:19 -06:00
Charles Kerr f88f3c4b03
Feat: add tr_block_info::Location (#2649) 2022-02-18 17:17:19 -06:00
Charles Kerr 29af76d977
refactor: tr_web (#2640)
* fixup! refactor: tr_web (#2633)

fix: race condition in web threadfunc during bootstrap

fixes #2639
2022-02-17 17:35:57 -06:00
Charles Kerr f1a53840f9
refactor: tr_web (#2633)
* refactor: fix tr_web rate limiting and dns caching
2022-02-16 12:33:50 -06:00
Charles Kerr 8805d7c67b
refactor: remove tr_webGetTaskResponseCode() (#2628)
It's not really needed anymore, and removing it is aligned with the
goal of simplifying the tr_web and tr_webseed codebase.
2022-02-14 16:39:52 -06:00
Charles Kerr a822a46e47
refactor: add fetch options object to tr_webRun() (#2620)
* refactor: add fetch options object to tr_webRun()

Fold `tr_webRun()`, `tr_webRunWithCookies()`, and `tr_webRunWebseed()`
into a single API that takes an options argument that callers can
customize to their needs.

Also does a surface cleanup pass to the tr_webseed and tr_web internal
structures, e.g. making fields const where possible, not using raw
pointers, and making some fields private.

This revision is still full of code smells. Refactoring the entire
system is overwhelming, so instead I'm doing it in incremental steps.
2022-02-13 20:09:56 -06:00
Charles Kerr dfe79af34c
refactor: tr_webseed simplification (#2613)
* refactor: remove effective-url caching in webseeds

The upcoming CURLSH refactor is a more effective way of doing this and
the current appoach makes tr_web harder to refactor, so remove it.

* refactor: webseed rate limiting

The current code that limits the number of parallel fetches is overly
complicated and is also interwoven into the tr_webseed class. Extract
it into a new private helper class "ConnectionLimiter" with a simpler
public API for tr_webseed to use.
2022-02-12 16:52:40 -06:00
Charles Kerr ebb2ab6aee
chore: update license spdx abbreviations (#2582)
Use SPDX license list 3.0 terminology: replace deprecated identifiers
GPL-2.0" and "GPL-3.0" with "GPL-3.0-only" and "GPL-3.0-only".
2022-02-07 10:25:02 -06:00
Charles Kerr ecef0feb0c
refactor: clang-tidy in libtransmission (#2578)
* chore: enable cppcoreguidelines-slicing warning

* chore: enable readability-named-parameter warning

* chore: enable bugprone-reserved-identifier check

* chore: enable bugprone-not-null-terminated-result check

* chore: enable bugprone-sizeof-expression check

* chore: enable bugprone-incorrect-roundings check

* chore: enable misc-misplaced-const check

* chore: enable bugprone-suspicious-include check

* chore: enable bugprone-signed-char-misuse check

* chore: enable modernize-raw-string-literal check

* chore: enable readability-static-accessed-through-instance check

* chore: enable readability-implicit-bool-conversion check

* fixup! Merge branch 'main' into refactor/clang-tidy
2022-02-06 22:28:36 -06:00
Charles Kerr 878405f862
Revert "fix: sonarcloud (#2558)" (#2562)
This reverts commit 8b9483f7fb.
2022-02-01 11:30:51 -06:00
Charles Kerr 8b9483f7fb
fix: sonarcloud (#2558)
* fix: add const modifier for functions

* fix: many sonarcloud use-init-statement warnings
2022-01-31 22:46:27 -06:00
Charles Kerr e51527203e
refactor: re-enable clang-tidy warnings (#2485) 2022-01-23 16:47:41 -06:00
Charles Kerr df1cca9b57
chore: update copyright years, make notices consistent (#2463) 2022-01-20 12:27:56 -06:00
Charles Kerr b0ee4007ff
refactor: include cleanups (#2392)
* refactor: include <memory> when using shared_ptr or unique_ptr

* refactor: include <cstdio> iff we use it

* refactor: include <cstring> iff we use it

* refactor: include <cstdlib> iff we use it

* refactor: include <string_view> or <string> iff we use it

* refactor: include <array> iff we use it

* refactor: include <ctime> iff we use it

* refactor: include <cctype> iff we use it

* refactor: misc #include cleanups in libtransmission
2022-01-12 20:13:58 -06:00
Charles Kerr 385a119fb1
refactor: make tr_torrent aggregates tr_block_info instead of subclassing (#2376) 2022-01-07 13:13:37 -06:00
Charles Kerr eafbf59832
refactor: avoid referencing tr_file struct directly (#2373) 2022-01-01 19:25:25 -06:00
Charles Kerr af183b1423
chore: remove tr_pieceOffset() (#2346) 2021-12-26 11:25:51 -06:00
Charles Kerr 33553c5331
refactor: move tr_ioFindFileLocation() to tr_file_piece_manager (#2334) 2021-12-24 00:39:55 -06:00
Charles Kerr e4a172d39c
fix: sonarcloud (#2322)
* fix: sonarcloud warning - redundant cast

* fix: sonarcloud warning - init-statement

* fix: sonarcloud warning - init-statement

* fix: sonarcloud warning - move #include to top of file

* fix: sonarcloud warning - implicit conversion loses precision

* fix: sonarcloud warning - confirm safe use of strlen

* fix: sonarcloud warning - refactor code to not nest more than three deep

* iwyu: cstring

* iwyu: algorithm
2021-12-16 16:58:58 -06:00
Charles Kerr 4ea2429217
refactor: tr_torrent housekeeping (#2319) 2021-12-16 02:49:04 -06:00
Charles Kerr 42b1362760
refactor: tidy libtransmission includes (#2316) 2021-12-15 15:25:42 -06:00
Charles Kerr 1c848cf174
refactor: add tr_info accessors to tr_torrent (#2314)
* refactor: add tr_info accessors to tr_torrent
2021-12-15 09:53:20 -06:00
Charles Kerr d00be0dec7
refactor: tr_torrentIsSeed() -> tr_torrent::isDone() (#2313) 2021-12-15 01:04:26 -06:00
Charles Kerr 0f92232c65
fix: memleak regressions (#2293)
* fixup! refactor: add tr_saveFile() (#2267)

fix: memleak regression

* fixup! fixup! refactor: make parts of tr file private (#2241) (#2281)

fix: memory leak regression

* fixup! refactor: use C++ inheritance for tr_peer, tr_peerMsgs, and tr_webseed (#1877)

fix: memory leak regression
2021-12-09 18:49:30 -06:00
Charles Kerr c46ce2da06
refactor: add tr_torrentWebseed(), tr_torrentWebseedCount() (#2277)
* refactor: add tr_torrentWebseedCount()
2021-12-07 12:11:28 -06:00
Charles Kerr 5096bbae9b
refactor: add tr_torrent::file() (#2274)
* refactor: add tr_torrent::fileCount()
2021-12-06 22:18:17 -06:00
Charles Kerr 867a131e1d
refactor: add tr_torrent::fileCount() (#2273)
Provide an accessor to get a torrent's file count.

This is an incremental step towards making tr_torrent's impl private.
2021-12-06 15:26:04 -06:00
Charles Kerr 34881f6295
refactor: make parts of tr file private (#2241)
* refactor: make parts of tr_file private
2021-11-27 21:17:47 -06:00
Charles Kerr 742ae6fb00
refactor: minor naming change in block_info (#2233)
* refactor: rename method as block_info.pieceSize()

* refactor: rename method as block_info.blockSize()
2021-11-26 13:33:56 -06:00
Charles Kerr de169c7ec3
refactor: tr_completion (#2220)
* refactor: refactor tr_completion + add test coverage for it
2021-11-25 12:26:51 -06:00
Charles Kerr 843e486d2a
refactor: tr_block_info class (#2210)
* refactor: add tr_block_info with tests
2021-11-24 08:48:52 -06:00
Charles Kerr da855a7257
refactor: use std mutex/lock intead of bespoke (#2194)
* refactor: use std mutex/lock intead of bespoke
2021-11-20 15:20:45 -06:00
Charles Kerr 073c6af1d6
refactor: swarm (#2103)
* refactor: encapsulate request tracking in a class

Introduces a new class to peer-mgr, `ClientRequests`, which tracks what
active requests we've got pending: which blocks, when the requests were
sent, and who they were sent to.

This shouldn't change peer-mgr behavior. Its goal is to carve out some
of peer-mgr's data structures and encapsulte them behind an API that's
simpler to understand.

* refactor: move ActiveRequests to its own file

* perf: avoid duplicate call to tr_cpMissingBlocksInPiece
2021-11-19 12:37:38 -06:00