Commit graph

77 commits

Author SHA1 Message Date
sledgehammer999
e2748ec3ac Remove deprecated feature of separate DHT port. 2014-07-16 00:17:21 +03:00
sledgehammer999
d6d20074be Merge pull request #1447 from BrunoReX/hibernation
Add option to hibernate computer in Auto-Shutdown menu
2014-07-06 23:11:29 +03:00
Bruno Barbieri
00e09435b2 Add option to hibernate computer in Auto-Shutdown menu 2014-07-06 06:13:36 -03:00
Ivan Sorokin
6dabf50781 Speedup and fix a bug in torrent moving.
This commit implements a map where qbittorrent store a state of
current torrent movings. This commit speed up
torrents moving a bit and also fix a bug when qbittorrent doesn't do
cleanup action when a single torrent is moved several times without
waiting for a previous move to complete.

How it worked before.

Libtorrent has a function torrent_handle::move_storage() that allows to move a
torrent to a specific directory. This function is asynchorous. It means that
this function quits instantaneously and when the actual operation
completes the alert 'storage_moved_alert' or
'storage_moved_failed_alert' will be sent. The storage_moved_alert contains a
torrent_handle and a new path to where the torrent is moved.

During handling of storage_moved_alert, qbittorrent needs not only new path,
but also an old path to perform some of cleanup actions (like removing an old
folder if it is empty). This was achieved by storing a value named
'previous save path' in TorrentPersistentData. A previous save path is
written when move_storage() is issued and is read when
storage_moved_alert is received.

Problems.

This mechanism has two negative aspects:

1. TorrentPersistentData is very slow. As torrent_handle::move_storage() is asynchoronous,
TorrentPersistentData is responsible for more that 99.8% of time
QTorrentHandle::move_storage(). This percent could be higher when there
are lots of torrents and lower when there are few of them.

2. TorrentPersistentData stores only one previous path. But many
move_storage()'s could be issued without waiting for previous to
complete. Subsequent move_storage()'s overwrites previous save path of a
previous move.

A fix.

The fix is simple. Before issueing move_storage() the oldPath is stored in
a special map called 'torrentMoveStates'. When a storage_moved_alert
is received the map is consulted and an alert is handled.

When user moves torrent when previous moving have not yet finished, the
new location is saved in a field 'queuedPath' the same map. When
torrent moving is completed (or failed) qbittorrent attemps to perform
move again to the queued location.

Future direction.

This fix removes one slow read and one slow write to
TorrentPersistentData on torrent moving, but there is still exists
TorrentPersistentData::saveSavePath in handleStorageMovedAlert(), so
overall time for UI hang should be reduced only threefold. A speeding up
TorrentPersistentData should be addressed in a separate commit.

I don't know if I should clean up torrentMoveStates when torrent is
deleted. In any case, torrent could be deleted when corresponding alert
is in alert queue. So if we decide to clean up torrentMoveStates, then
we should not treat receiving alert from unknown torrent as a error.
2014-06-23 11:21:24 +04:00
Ivan Sorokin
1244a46cbb Extract alert handling to separate functions. 2014-06-04 11:08:31 +04:00
Ivan Sorokin
c2a23f2265 use stats_alert in TorrentSpeedMonitor
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-02 00:35:27 +04:00
Ivan Sorokin
6f38616193 extract torrent statistics from torrent speed monitor to separate file 2014-06-02 00:31:45 +04:00
Ivan Sorokin
b50d7331c7 use post_status_update()
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-02 00:31:45 +04:00
Ivan Sorokin
eb46326d23 use set_alert_dispatch instead of timer to get an alerts from libtorrent
libtorrent allows setting a custom dispatch handler that is invoked in
libtorrent thread when new alerts are incoming. QAlertDispatcher is a
class that allows to translate these alerts to UI thread.

The concept is very simple:

1. On initialization QAlertDispatcher constructor calls set_alert_dispatch() passing
 QAlertDispatcher::dispatch as argument.

2. On deinitialization destructor calls set_alert_dispatch() passing a empty
 function. (line 25) libtorrent handles thos and switches back to queuing
 alerts in queue.

3. QAlertDispatcher::dispatch() adds alert to queue and notifies UI thread that new
 alerts are incoming. Enqueuing is done in function enqueueToMainThread().
 The invariant of class is the following:

    if alert queue is not empty, in message loop of UI thread contains a queued
    invocation of deliverSignal().

4. When message loop is pumped UI thread execute deliverSignal() function.
 It emit appropriate signal and if queue is still not empty (for example
 if slot doesn't grab alerts) rewind enqueuing to main thread.

This is a idea. But here is some details.

1. When QAlertDispatcher is destoyed, libtorrent still can call
QAlertDispatcher::dispatch a few times after destruction. This is
handled by passing a "tag". A tag is a object that references QAlertDispatch.
Tag could be invalidated. So on destruction QAlertDispatcher invalidates a tag
and then unsubscribes from alerts. When QAlertDispatcher::dispatch is called
with invalid tag it simply discard an alert.

    Therefore we could drop a few alerts during unsubscription. So we unsubscribe
    only at exit when missing some alerts is not a problem.

2. Another problem is in QBtSession::saveFastResumeData(). It pumps alert
queue synchronously. My first attempt was to destroy QAlertDispatcher
and then pump libtorrent queue. But as I was afraid of losing alerts I
supported synchronous querying of alerts in QAlertDispatcher.
(QAlertDispatcher::getPendingAlerts)

Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2014-06-02 00:31:45 +04:00
Ivan Sorokin
329b754197 cache torrent_status 2014-06-02 00:31:42 +04:00
Ivan Sorokin
bbc4080a5d fewer calls to hash() 2014-05-25 12:32:09 +04:00
sledgehammer999
ef3f7d18c9 Fix compilation with Qt5. 2014-05-04 15:28:54 +03:00
sledgehammer999
77329a2609 Launch external programs async and don't block. Closes #1252. 2014-01-26 14:28:58 +02:00
arvidn
c1c824bcf7 don't use deprecated libtorrent functions 2014-01-01 10:04:22 -08:00
arvidn
3b4f9d2eeb fix libtorrent 1.0 compatibility 2013-12-31 17:00:14 -08:00
Nick Tiskov
687e7a1343 Collect and save alltime UL/DL samples 2013-11-17 02:05:44 +04:00
sledgehammer999
b4dca951b2 Drop libtorrent 0.15.x support. 2013-10-23 22:19:58 +03:00
sledgehammer999
1c128c65f0 Don't use deprecated function when adding magnets. 2013-10-22 22:29:25 +03:00
sledgehammer999
14310f9b05 Improve loading of magnet metadata in the background.
Conflicts:
	src/qtlibtorrent/qbtsession.cpp
2013-10-06 13:49:23 +03:00
sledgehammer999
a1a5fb065e Backup/recover torrent persistent data into each individual .fastresume file. This should mitigate the problem of users losing their torrents' settings/savepath/label after qbt wasn't shutdown cleanly. 2013-10-01 01:57:34 +03:00
sledgehammer999
08138307da Refactor code for reporting listen failure/success. 2013-09-19 23:43:21 +03:00
sledgehammer999
eeb43d6bfd Increase the log size to accomodate for users with many torrents (>100). 2013-09-19 23:41:04 +03:00
Nick Tiskov
b6c59fd70b Do not mark articles read if download has failed
This change includes: always try to download unread articles matching ruleset already present in list (aka redownload failed items)
2013-07-18 00:21:20 +04:00
tungnian lee
2de8b9112d more clean up for feature selecting a random port when starts up 2013-06-30 15:15:43 +03:00
tungnian lee
75e28bb3e6 Made changes for clean up and fix the problem that a new ramdon port is set every time a setting is saved. 2013-06-30 15:15:42 +03:00
Christophe Dumez
13e57fb9dd Merge pull request #471 from daimor/master
Correctly handle HTTP responses with gzipped encoded content.
2013-03-10 11:08:57 -07:00
Nick Tiskov
3309706964 Allow clearing of execution log and peer ban log 2013-03-10 20:31:46 +04:00
Dmitry Maslennikov
e017ba6863 add cookies for redirect, cookies for auto download torrent from rss, add support gzip 2013-03-10 19:15:33 +04:00
sledgehammer999
3e979931d0 Make a setter for defaultSave path in qbtsession and do some other optimizations to avoid potential pitfalls. 2012-12-01 14:48:08 +02:00
Christophe Dumez
806ab07865 Import new trackers from magnet link in case of duplicate torrent (closes #111) 2012-09-23 11:09:01 +03:00
Driim
23ea811095 Add setting to copy .torrent files for finished downloads (closes issue #22)
Patch edited by Christophe Dumez.
2012-08-21 20:10:53 +03:00
Christophe Dumez
74079b2c86 Support custom save path / label for RSS feeds using magnet links 2012-06-24 16:48:40 +03:00
Christophe Dumez
5a65580169 Add support for RSS feeds using magnet links (Closes #1016379) 2012-06-24 10:27:32 +03:00
Christian Kandeler
55a6bc3855 Check for magnet links in watched folders.
Look for files ending with ".magnet" and interpret their contents as a
magnet link.
This allows scripts to collect magnet links from the web and let
qBittorrent download them non-interactively.
2012-05-30 22:28:53 +03:00
Christophe Dumez
d55f3b5aff RSS: Better cookies support 2012-05-20 16:03:10 +03:00
Christophe Dumez
c502edf9e1 Brand new torrent addition dialog 2012-05-15 19:57:31 +03:00
Christophe Dumez
a53a70742d Drop support for libtorrent v0.14.x 2012-02-18 16:44:20 +02:00
Christophe Dumez
6d9e519cdc Fix important memory usage problem in log tab 2011-06-20 22:28:55 +03:00
Christophe Dumez
65883317c3 FEATURE: Proxy can be disabled for peer connections 2011-05-01 11:22:17 +00:00
Christophe Dumez
c85cb8799e FEATURE: qBittorrent can update dynamic DNS services (DynDNS, no-ip) 2011-04-15 13:02:39 +00:00
Christophe Dumez
3154461f28 Fix initialization problem with some private trackers 2011-04-13 17:18:56 +00:00
Christophe Dumez
da32321f10 FEATURE: Added UPnP/NAT-PMP port forward for the Web UI port 2011-04-12 19:50:05 +00:00
Christophe Dumez
c63503aaa6 Use ConsoleKit to shutdown the system instead of HAL (deprecated)
use UPower to suspend the system instead of HAL (deprecated)
Rewrote computer shutdown/suspend code to avoid data loss
2011-04-05 16:22:16 +00:00
Christophe Dumez
82e41f36ee FEATURE: Added per-torrent ratio limiting (Christian Kandeler) 2011-03-07 19:26:44 +00:00
Christophe Dumez
d06e0b639e Fix compilation with Qt 4.6 2011-03-03 19:20:49 +00:00
Christophe Dumez
c2e5ecaaa0 BUGFIX: Fix compilation with namespaced Qt (Christian Kandeler) 2011-02-27 15:41:05 +00:00
Christophe Dumez
79cdad47f1 Code optimization 2011-02-26 19:56:15 +00:00
Christophe Dumez
c05e6ba580 Fix compilation error on Windows
Fix possible encoding problem on Windows (torrent creation tool)
Fix compilation with boost >= v1.46
2011-02-26 15:04:15 +00:00
Christophe Dumez
2da5e03741 Share ratio can now go over 100 2011-02-24 17:36:20 +00:00
Christophe Dumez
8238c13dc0 Performance improvement on ARM 2011-01-25 17:04:55 +00:00