Commit Graph

5295 Commits

Author SHA1 Message Date
Charles Kerr 84d65d8e61
fix: coverity warnings (#3168)
* fix: uninitialized peer_atom field

* fix: silence inaccurate open-files-test warning

* fix: assertion-is-always-true

asserting unsigned val is >= 0

* fix: unnecessary nullptr check

* fix: nullptr dereference warning
2022-05-31 18:58:20 -05:00
Charles Kerr 1c3d60fcd5
refactor: simplify announceToScrape() (#3167) 2022-05-31 12:12:25 -05:00
Charles Kerr d9f70f51dc
perf: avoid std::string temporaries in sessionLoadTorrent() (#3165) 2022-05-31 10:53:46 -05:00
Charles Kerr d1030b58b1
perf: use std::string_view for compile-time UserAgent (#3161) 2022-05-31 09:28:01 -05:00
Charles Kerr 0097921f42
perf: avoid some unnecessary psl domain strdups (#3160)
We were incorrectly duplicating most domains because the "do we need
to convert before feeding to psl" test incorrectly returned true for
many domains.
2022-05-30 21:55:05 -05:00
Charles Kerr 1fc0e5d0d8
refactor: simplify atom pruning (#3159)
Possible fix for #3153
2022-05-30 14:36:03 -05:00
Charles Kerr d1028510c1
refactor: use std::vector instead of tr_ptrArray in peer-mgr (#3149)
* refactor: make peer_atom.pool a std::vector

* refactor: remove unused tr_ptrArray methods

* refactor: remove unused #include ptrarray.h

* refactor: remove unused tr_ptrArrayRemove()

* refactor: remove unused peer-mgr.cc code
2022-05-27 16:27:47 -05:00
Charles Kerr 992775cfdc
refactor: struct peer_atom (#3147)
* refactor: make peer_atom.blocklisted private

* refactor: make tr_atomAddrStr a member function

* refactor: make atomIsSeed a member function

* refactor: make tr_isAtom a member function

* refactor: make peer_atom constructor

* refactor: make getReconnectIntervalSecs a member function

* refactor: make peer_atom.fromFirst const
2022-05-27 12:19:24 -05:00
Charles Kerr cec2195c78
refactor: tr_peerMgrGetPeers() returns a vector (#3142)
* refactor: tr_peerMgrGetPeers() returns a vector

* chore: iwyu <iterator> for std::back_inserter

* chore: iwyu <vector> for std::vector
2022-05-26 20:29:10 -05:00
Charles Kerr 51760bd5c1
refactor: make tr_peerIoGetAddress() a member function (#3141)
* refactor: make tr_peerIoGetAddress() a member function

* refactor: make tr_peerIo.addr a private field

* refactor: make tr_peerIoIsIncoming a member function

* refactor: make tr_peerIoHasBandwidthLeft a member function

* refactor: make tr_peerIoGetPieceSpeed_Bps a member function

* refactor: make tr_peerIoSupportsFEXT() a member function

* refactor: mark tr_peerIo::supportsDHT nodiscard

* refactor: update naming style for tr_peerIo fields

* refactor: make tr_peerIo.is_seed a private field
2022-05-26 12:17:03 -05:00
Charles Kerr 4f0f3f1c49
refactor: prefer std::vector over raw array in torrentGet() (#3140) 2022-05-26 09:36:00 -05:00
Charles Kerr 46eb379205
fix: ESPIPE "illegal seek" error while seeding (#3137)
* fix: ESPIPE "illegal seek" error while seeding

The root cause is createSocket returning `{}` instead of `TR_BAD_SOCKET`
when we have too many peers in use. This defaulted to fd 0, which wound
up closing stdin.

Commit also includes some const-correctness changes made while tracking
the problem down.
2022-05-25 18:16:15 -05:00
Charles Kerr 26b1a9154e
fix: silence unexpected key warnings in torrent file parser (#3133) 2022-05-24 15:28:02 -05:00
Charles Kerr fe288b45e5
perf: do not use tr_variant when parsing .torrent files 2022-05-23 23:05:16 -05:00
Charles Kerr 19db28c04d
perf: faster detection of invalid filenames (#3126)
* refactor: move file_info into tr_torrent_files

* chore: rename files-test as torrent-files-test.cc

* test: add tests for tr_torrent_files::isSubpathPortable()
2022-05-23 17:53:26 -05:00
Charles Kerr 67a078402d
fix: compiler warnings (#3123)
* fix: unused function warning tr_rpc_address_is_valid

* fix: unused variable warning old_byte_pop

* fix: method-can-be-made-static warning assertValidRules

* fix: signed-unsigned comparison warning

* fix: invalid case style warning for KBps

* chore: disable warning for static class member varaible
2022-05-22 21:22:34 -05:00
Charles Kerr c0bb2d40f1
refactor: add pathbuf and std::string-friendly helpers to tr_sys file and path funcs (#3118)
* refactor: add sv-friendly tr_sys_dir_create() variant

* refactor: add sv-friendly tr_sys_path_get_info() variant

* refactor: add sv-friendly tr_sys_path_exists() variant

* refactor: add sv-friendly tr_sys_path_remove() variant

* refactor: add sv-friendly tr_sys_path_rename() variant

* fixup! refactor: add sv-friendly tr_sys_path_rename() variant
2022-05-21 20:17:00 -05:00
Charles Kerr 690cf50e53
perf: tr_sys_path_dirname() returns a std::string_view (#2990)
* refactor: use nodejs impl of path.win32.dirname()

* refactor: use nodejs impl of path.posix.dirname()
2022-05-21 11:10:58 -05:00
A Cœur 2e25370cc5
Fix QuickLook (#3001)
* Fix QuickLook symbol not found; add file sort and filesize
2022-05-19 23:07:17 -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 a28b07b390
Revert "refactor: move tr_torrent callbacks to tr_session (#3003)" (#3104)
This reverts commit 27fbfd8da6.

Fixes #3088.
2022-05-16 13:48:43 -05:00
Charles Kerr 2293f4336a
perf: use fast_float to parse floating-point numbers (#3092) 2022-05-16 00:06:17 -05:00
Dmytro Lytovchenko aa502f9312
Modernize blocklist.cc: Rename, move members inside struct (#2010)
* Modernize blocklist.cc to C++

* Modernize blocklist.cc: Renamed BlocklistFile struct and moved IPv4 range struct inside it

 Modernize bandwidth.cc: Review notes; Promote container of blocklists in session to vec of unique_ptrs
2022-05-15 11:32:22 -05:00
Charles Kerr 36e6d4ed07
chore: remove unused header fdlimit.h (#3084) 2022-05-14 11:17:55 -05:00
Charles Kerr 27fbfd8da6
refactor: move tr_torrent callbacks to tr_session (#3003)
* refactor: move tr_torrent callbacks to tr_session

* Support tr_sessionSet* (#3044)

Co-authored-by: Antoine Cœur <coeur@gmx.fr>
2022-05-14 10:00:13 -05:00
Antoine Cœur 5d52da8726
Address format conversion warnings in localizations (#3059) 2022-05-14 00:31:24 -05:00
Antoine Cœur d3e1c83c9b
Address build warnings (#3052) 2022-05-04 18:54:41 -05:00
Antoine Cœur 9069e4c910
Fix TeamCity Code Style (#3045) 2022-05-01 13:06:32 -05:00
Charles Kerr 88a0b292d9
fixup: fix fd regression in tr_open_files (#3036)
Fixes #3032.
2022-04-30 23:30:49 -05:00
Charles Kerr 4cc952f0ca
fixup! fixup! fix: ensure all bytes read / written to file (#2682) (#2780) (#3035)
fix spurious tr_error being set when reading up to eof

Fix error introduced in the previous fixup :P
2022-04-30 18:43:32 -05:00
Charles Kerr c8f5cff564
fixup! fixup! fix: ensure all bytes read / written to file (#2682) (#2780) (#3033)
fix spurious tr_error being set when reading up to EOF.

This regression generated invalid error messages when no error occurred.
2022-04-30 16:57:11 -05:00
Charles Kerr e4221916b1
fix: invalid tr_peerMsgsImpl::prefetchCount value (#3024)
* fix: invalid tr_peerMsgsImpl::prefetchCount value

This count could get corrupted due to imprecise bookkeeping when
processing peers' cancel messages. This PR replaces the field with
a `prefetched` flag in the struct that represents a peer request.

This approach has simpler code, simpler logic, and is harder to break.
2022-04-29 12:44:22 -05:00
Charles Kerr d487a5d8d7
refactor: make tr_swarm.peers a std::vector (#3017) 2022-04-29 08:32:15 -05:00
Charles Kerr 5dbe1f4669
refactor: replace tr_fdlimit with tr_open_files (#3016) 2022-04-28 21:35:47 -05:00
Charles Kerr a400682247
refactor: remove unused tr_torrent fields (#3013)
* refactor: remove unused field tr_torrent.prefetchMagnetMetadata

* refactor: remove unused field tr_torrent.dhtAnnounce6InProgress

* refactor: remove unused field tr_torrent.dhtAnnounceInProgress

* refactor: fold etaULSpeed and etaDLSpeed into one field

* refactor: re-arrange fields to avoid padding
2022-04-28 11:52:07 -05:00
Charles Kerr 5e769fbc55
refactor: make tr_recentHistory a template class (#3012)
This gives more flexibility on the size of the count bins, so we can save space on smaller counts
2022-04-28 10:52:26 -05:00
maxz d8c5c65725
Specify the umask and IPC socket permission as strings. (#2984)
* Support specifying the umask as a string representing an octal number.

* Save the umask as a string representing an octal number.

* Support specifying the IPC socket permission as a string representing an octal number.

* Save the IPC socket permission as a string representing an octal number.

* Add a `base` parameter to `tr_parseNum()` for specifying the radix.
2022-04-28 09:16:19 -05:00
Charles Kerr 7c2477dddf
refactor: reduce field padding in some structs (#3006)
* refactor: use smaller integral types in tr_bandwidth

* refactor: re-arrange tr_torrent fields to avoid padding

* refactor: re-arrange tr_torrent fields to avoid padding

* refactor: re-arrange tr_announcer fields to avoid padding
2022-04-28 08:44:24 -05:00
Charles Kerr bf655a921d
refactor: use smaller integral types in some structs (#3005) 2022-04-27 20:06:51 -05:00
Charles Kerr fca85c2f4d
refactor: add Handshakes helper class in peer-mgr (#3002) 2022-04-27 12:20:55 -05:00
Charles Kerr 304fffa6b3
refactor: intern tr_torrent.bandwidth_group_ (#3000)
Most use cases involve either (a) using the default group or (b) sharing
a group with other torrents. In both cases, using a tr_quark is cheaper
than a std::string.
2022-04-27 10:41:28 -05:00
Charles Kerr a818ac9b13
perf: limit the scope of bitfield assertions (#2994)
Fixes #2830.
2022-04-26 19:51:24 -05:00
Charles Kerr 0025363ede
perf: faster file priorities (#2992) 2022-04-26 11:11:21 -05:00
Charles Kerr ca13842c84
refactor: make tr_torrent::verify_state_ private (#2982) 2022-04-24 22:43:26 -05:00
Charles Kerr aa2bb367ab
chore: iwyu cleanup (#2981) 2022-04-24 20:49:52 -05:00
qu1ck 07dc81170a
Fix fields handling in session-get (#2972) 2022-04-24 14:34:32 -05:00
Charles Kerr d4e1b32e38
fix: corruptin when downloading webseeds (#2978)
Fixes #2909.
2022-04-24 12:46:44 -05:00
Charles Kerr 0a3018d706
refactor: decouple peer limits from fdlimit (#2969) 2022-04-22 16:15:06 -05:00
Charles Kerr 1ebac744a5
build: re-enable cert-err33-c clang-tidy warning (#2968)
* refactor: re-enable cert-err33-c clang-tidy warning

* refactor: use fmt::chrono in transmission-remote

* refactor: use fmt::chrono in transmission-show

* refactor: use fmt::chrono in GTK details dialog

* refactor: use fmt::chrono in tr_session

* refactor: remove tr_localtime_r

* refactor: remove tr_gmtime_r
2022-04-22 14:56:54 -05:00
Charles Kerr ed897f93f2
refactor: remove evbuffer_free_to_str() (#2967) 2022-04-22 13:05:49 -05:00