Commit Graph

526 Commits

Author SHA1 Message Date
arvidn 6785046c2f introduce a download_priority_t type, for uniform an type-safe piece- and file priorities 2017-11-02 08:20:21 +01:00
arvidn 80ac90727b remove some questionable code from disk_io_thread when deleting files for a torrent and extend transfer test to cover deleting files while seeding 2017-10-25 19:00:54 +02:00
Alden Torres b380bf8059 minor and general code cleanup/refactor 2017-10-25 09:58:47 +02:00
arvidn 98effc8d88 minor disk_io_job piece_hash cleanup 2017-10-22 16:49:25 +02:00
arvidn 8adcfdbf41 make disk_buffer_holder know the size of the bufer it holds, to fix buffer overrun in chained_buffer
fix
2017-10-13 21:07:31 +02:00
arvidn 68f05d6380 fix some warnings and integer overflow with torrents that are too big 2017-09-28 14:59:28 -07:00
arvidn c66f4cc62a fix some warnings, mostly 0 -> nullptr 2017-09-28 07:33:10 -07:00
arvidn 93bb84d94c some random cleanup 2017-09-13 08:28:46 +02:00
arvidn 55228756e5 make disk job flags type safe 2017-09-10 08:56:52 +02:00
arvidn fe1c395579 merged RC_1_1 into master 2017-09-03 13:57:19 +02:00
Steven Siloti 621da10e60 hold an owning reference to storage objects in try_flush_write_blocks
It is possible for all other references to a storage object to be
destroyed while try_flush_write_blocks is running. If the storage is
destroyed then find_piece will crash when trying to re-aquire the
shared_ptr. To prevent this, keep the storage alive by holding a
shared_ptr to it in try_flush_write_blocks.

Normally the fence job when stopping a torrent would prevent the storage
object from being destroyed until all flush jobs are complete.
try_flush_write_blocks can be run after every disk job though so it has
the potential to "stradle the fence".

If the associated torrent does get unloaded then it is expected that
find_piece will return NULL thus causing the entry to be ignored.
2017-08-30 12:45:06 +02:00
Steven Siloti 2365611507 remove support for using a pool allocator for disk buffers (#2257) 2017-08-19 11:04:39 +02:00
arvidn 322007bb6a make save_state_flags a strong type 2017-07-30 09:06:41 -07:00
arvidn c4afb5e949 use a dedicated class template for flags types instead of enum class. It's more backwards compatible and improves ergonomics 2017-07-15 01:15:57 -07:00
Alden Torres 10bfe18ebe added consts and minor code formatting 2017-07-03 16:58:49 -04:00
arvidn ff454a92d4 unify some operation-enums and strings to use operation_t 2017-06-18 07:31:45 -04:00
arvidn 3215deb2c5 make io_service::work accounting more accurate in asio-debugging=on 2017-06-14 07:01:06 -04:00
arvidn 147d996160 make the job action enum an enum class 2017-06-11 23:53:58 +02:00
arvidn 4de9f6a75b remove requester parameter to disk read jobs 2017-06-08 12:38:25 +02:00
Arvid Norberg 5344761da4 make flags to move_storage a proper enum class (#2043) 2017-06-01 04:15:15 -04:00
arvidn ffaabd846c make file open mode flags be an enum class for type-safety 2017-05-28 11:16:59 -04:00
arvidn 392f284566 remove some unused stats gathering state in disk_io_thread 2017-05-23 08:16:25 -04:00
arvidn e79a7a08b9 fix race condition in storage tick handling in disk_io_thread 2017-05-18 10:21:34 -04:00
arvidn af495da56b use std::function instead of the fileop interface for readwritev() 2017-05-02 08:07:29 -04:00
arvidn 749d0da875 make iovec_t an alias for span<char>, in preparation for removing it altogether in favour of span 2017-04-30 11:49:08 -04:00
arvidn b553cb32f7 fix storage destruction order issue 2017-04-22 17:30:31 -04:00
arvidn 04c76249b6 merged RC_1_1 into master 2017-04-21 01:21:31 -04:00
arvidn 227830e757 fix memory leak in the disk cache. if a cached_piece_entry would stick around in a ghost list (ARC), it would keep the torrent object itself alive. when aborting read jobs, the outstanding_read flag need to be cleared on the piece. When reclaiming a block for a piece that should be deleted (not just evicted) it need to know that. This patch adds an additional bit to cached_piece_entry to communicate this 2017-04-19 22:30:27 -04:00
arvidn 2d6268b580 fix double free in disk cache 2017-04-17 19:54:05 -04:00
arvidn df299fcb00 use boost::variant for disk_io_job in/out parameter, to support holding a proper disk io buffer handle and string 2017-04-17 15:08:27 -04:00
arvidn 480bde9333 change formatting of namespace declarations 2017-04-12 14:26:35 -04:00
Arvid Norberg c35718d322 use unsigned integer for file and storage flags (#1895)
use unsigned integer for file and storage flags
2017-04-09 01:28:46 -04:00
Arvid Norberg 13b16a63a3 use unsigned type for file flags. make file_pool private to disk_io_thread (#1894)
use unsigned type for file flags. make file_pool private to disk_io_thread. move close_file_interval logic to the disk thread. don't expose file in public interface, and make pool_file_status properly public (not part of file_pool and renamed to open_file_status), this is exposed in public interface via torrent_handle::file_status()
2017-04-08 18:24:50 -04:00
arvidn 86f67bd9d9 return a reference instead of pointer to file_storage in storage_interface 2017-04-07 20:27:38 -04:00
arvidn 51c42adc3e steps towars making file_pool private to disk_io_thread 2017-04-07 08:38:35 -04:00
arvidn 206a80acfb optimize construction of disk io storage objects 2017-03-23 17:45:11 -04:00
arvidn 3a1379ef1e merged RC_1_1 into master 2017-03-14 12:55:13 -04:00
arvidn dec8c853e3 fix default file pool size on windows 2017-03-09 23:26:53 -05:00
arvidn 5cb12318c5 fix bug where settings_pack::file_pool_size setting was not being honored 2017-03-09 08:18:10 -05:00
Alden Torres de6f2a9d88 fixing sign-conversion warnings, part 11, created aux::array and refactor (#1649)
fixing sign-conversion warnings, part 11, created aux::array and refactor
2017-02-04 22:05:53 -05:00
Alden Torres d36c598eeb fixing sign-conversion warnings, part 10 (#1642)
fixing sign-conversion warnings, part 10
2017-01-30 20:31:32 -05:00
Arvid Norberg 29db3de6c0 wrap most instances of throw, and terminate on builds where exceptions are disabled (#1639)
wrap most instances of throw, and terminate on builds where exceptions are disabled
2017-01-29 15:37:42 -05:00
Alden Torres 2437b3c134 created aux::typed_span and related refactor 2017-01-28 23:28:38 -05:00
Alden Torres 3803661863 moved alloca.hpp to private aux_ and size refactor (#1634)
moved alloca.hpp to private aux_ and size refactor
2017-01-27 12:43:34 -05:00
Alden Torres 070e85090b more std:: prefix, consts, auto refactor, formatting 2017-01-26 08:30:20 -05:00
arvidn d03540e3b3 move disk_job_fence to its own file 2017-01-22 01:20:27 -05:00
Alden Torres ef9d1ecd7f fixing sign-conversion warnings, part 6 2017-01-17 20:51:26 -05:00
Arvid Norberg 3d06371f31 factor out some common storage utilities out of storage.cpp (#1515)
factor out some common storage utilities out of storage.cpp
2017-01-11 00:42:10 -05:00
Arvid Norberg 1cf3689578 simplify disk thread a little bit (#1504)
simplify disk thread a little bit
2017-01-08 19:22:59 -05:00
Steven Siloti 2ed4bee1cb remove racey assert
We arn't holding any mutex here so the fence could have already been cleared
by the disk io threads.
2017-01-07 02:54:12 -05:00
Arvid Norberg 57f52adc88 various cleanup (#1497)
* various cleanup

* fix

* cleanup
2017-01-06 01:39:01 -05:00
arvidn 41dbb47123 compact block_cache_reference by using storage_index_t instead of pointer. make sure storage object is kept alive by block_cache_references 2017-01-02 13:45:16 -05:00
arvidn e99d907c72 fix assert 2017-01-02 00:01:43 -05:00
arvidn 4ebc344e48 make disk_io_thread responsible for the storage object. torrents refer to it by index 2017-01-01 13:54:39 -05:00
arvidn 23a7e8d40a hide the block_cache_reference from disk_buffer_holder 2016-12-31 10:31:54 -05:00
Arvid Norberg af126fe507 make buffer_allocator_interface an implementation detail of the disk_io_thread (#1463)
make buffer_allocator_interface an implementation detail of the disk_io_thread by using disk_buffer_holder in the disk interface. make chained_buffer use holders instead of free deleter functions and userdata to support putting disk_buffer_holder objects in there. Also make the session buffers be held by holders
2016-12-28 17:47:18 -08:00
Andrei Kurushin 1ec5c69dcd minor code corrections (#1430)
use compact span cast. extend split_path api with only_first_part flag. use single loadlibrary and getprocaddress for IP helper
2016-12-26 22:45:48 -08:00
arvidn 192ef4962b simplify the buffer_allocator_interface 2016-12-26 08:36:50 -08:00
arvidn 5ed0086b51 removed mmap_cache feature 2016-12-25 21:12:49 -08:00
Arvid Norberg 3f1084d63d strengthened type safety in handling of piece and file indices (#1409)
strengthened type safety in handling of piece and file indices
2016-12-22 10:42:33 -05:00
Alden Torres 22b596945e enable /W4 warnings for msvc 2016-12-13 19:36:14 -05:00
Alden Torres a05f0ba8a4 refactor for more modern struct initialization and use of api 2016-12-12 02:15:27 -05:00
Alden Torres 3a92908f39 formatting, added std:: and spaces 2016-12-10 23:11:43 -05:00
Alden Torres dd7179fb10 added a few consts to arguments and local variables 2016-12-10 18:19:14 -05:00
Alden Torres 37cbdc5b37 fixing shorten-64-to-32 warnings, part 1 2016-12-05 00:22:17 -05:00
Alden Torres d5c4cd7280 fixed sign-compare warnings and some refactor (#1354)
fixed sign-compare warnings and some refactor. make sequence_number backed by std::int64_t
2016-11-27 08:46:53 -05:00
Arvid Norberg 54f052a97b allocation slot type (#1352)
use a specialized type for allocation slot indices
2016-11-26 03:09:01 -05:00
Arvid Norberg 15ab8f387b cleaning up of disk_interface and improving type safety (#1353)
cleaned up disk_interface and improved type safety. removed unused disk status code disk_check_aborted, and removed status code return value for async_hash
2016-11-26 01:51:47 -05:00
Alden Torres c30027e4a1 more integral type conversion warning fixes, now only needs shorten-64-to-32 (#1349)
more integral type conversion warning fixes, now only needs shorten-64-to-32
2016-11-25 11:17:25 -05:00
arvidn 1d5f42d6d0 convert remaining disk io jobs 2016-11-23 19:02:05 -05:00
arvidn f08501b869 update callback interface for async_check_files and async_flush_piece 2016-11-23 19:02:05 -05:00
arvidn d8662533d5 update callback signature for async_move_storage and async_release_files 2016-11-23 19:02:05 -05:00
arvidn fc9dabe1ab start chipping away at removing disk_io_job from the disk_interface 2016-11-23 19:02:05 -05:00
arvidn d5b76d2237 move block_cache_reference out of disk_io_job header 2016-11-20 10:34:42 -05:00
arvidn 5b3a730b1f steps towards removing disk_io_job from disk_interface 2016-11-20 10:34:42 -05:00
Alden Torres 9e1305ed75 auto loop, consts and minor cleanup refactor 2016-11-15 19:54:38 -05:00
arvidn 14236993ea collapse logic in piece_manager into storage directly 2016-11-13 02:53:16 -05:00
arvidn ccd539f977 pull check resume data logic out of piece_manager into disk_io_thread and simplify it 2016-11-12 18:03:18 -05:00
arvidn 11ca69b9fc simplify disk_io_thread interface by setting the number of threads via settings rather than a separate function 2016-11-06 23:07:09 -05:00
arvidn 3ff89f29d7 remove explicit ticking of storage from the torrent. instead make the disk_io_thread do it automatically 2016-11-06 10:26:10 -05:00
arvidn c72053a75c remove unused clear_read_cache function 2016-11-05 21:39:45 -04:00
arvidn 2a999e1ea7 merge RC_1_1 into master 2016-11-03 23:58:35 -04:00
Arvid Norberg f5c7a49d61 remove incorrect deleted-storages assert and add some more test coverage in test_metadata_extensions (#1286) 2016-11-03 19:39:42 -04:00
Arvid Norberg 09cbd0a51d remove deprecated disk_io_thread operations (#1284) 2016-11-02 01:01:27 -04:00
Arvid Norberg b61ebca14a moved async-load-torrent feature out of disk-io-thread (#1282)
moved async-load-torrent feature out of disk-io-thread into a generic worker thread
2016-11-02 01:01:04 -04:00
Arvid Norberg 1c2a8fb96e move coalescing of reclaim block from disk_io_thread to session_impl (#1281) 2016-10-31 23:48:30 -04:00
Arvid Norberg 8daa200d11 simplify interaction with disk_io_thread by removing the uncork interface (#1271)
simplify the interaction with the disk_io_thread by removing the uncork interface. This should be turned into a transparent part of peer_connection instead and remove cork logic from peer_connection
2016-10-30 18:21:07 -04:00
arvidn b97bb84a9f merge RC_1_1 into master 2016-10-29 14:25:57 -04:00
Arvid Norberg d1a59879cb deprecate mmap_cache (#1269)
deprecated mmap_cache feature
2016-10-29 13:42:42 -04:00
Alden Torres dac0b9ec64 more use of nullptr, minor refactor and formatting (#1267) 2016-10-28 12:28:27 -04:00
arvidn 500bb24dba merged RC_1_1 into master 2016-10-26 23:30:58 -04:00
Steven Siloti f5366bd816 use span for scatter/gather lists (#1260)
use span for gather/scatter buffers. remove explicit size parameter from file_op
2016-10-26 20:40:56 -04:00
Alden Torres 6751a1eeb1 removed spaces in template types and more c++11 auto/loop refactor 2016-10-26 00:08:00 -04:00
Alden Torres 4eebd0c68a minor refactor, compilation fix when DEBUG_DISK_THREAD and missing convert_to_native (#1256) 2016-10-25 20:46:23 -04:00
Steven Siloti cf7db392b6 assert that offset didn't change while hashing 2016-10-25 07:59:02 -04:00
Steven Siloti f36b9a805a avoid concurrent access to hash offset
Since partial_hash::offset is not an atomic it is technically UD to access it
concurrently from multiple threads.
2016-10-25 07:59:02 -04:00
Steven Siloti 241e9fd25a add assert to detect index out-of-range 2016-10-25 07:59:02 -04:00
Alden Torres 8bdbaec872 minor cleanup refactor (#1252) 2016-10-24 20:19:01 -04:00
Arvid Norberg 5341be1e84 more improvement to error/exception handling (#1247)
improvement to error/exception handling
2016-10-22 22:00:47 -04:00
Steven Siloti a6e5ba8804 return a span from TORRENT_ALLOCA (#1244)
return a span from TORRENT_ALLOCA

Unfortunately this requires moving the variable declaration inside the macro.
Due to alloca’s unique properties pretty much the only safe way to call it is
in a simple assign-to-pointer expression. Therefor we need to use a temporary
pointer to store the value returned from alloca before we can call span’s ctor.

This also causes double evaluation of the size parameter which is unfortunate,
but no current callers of TORRENT_ALLOCA have a problem with this. Passing
expressions with side effects to macros is bad mojo anyways.
2016-10-22 14:43:40 -04:00