Merge lp:~michihenning/storage-framework/add-cancel-on-destroy into lp:storage-framework/devel
- add-cancel-on-destroy
- Merge into devel
Status: | Merged |
---|---|
Approved by: | James Henstridge |
Approved revision: | 67 |
Merged at revision: | 64 |
Proposed branch: | lp:~michihenning/storage-framework/add-cancel-on-destroy |
Merge into: | lp:storage-framework/devel |
Diff against target: |
177 lines (+30/-5) 10 files modified
include/unity/storage/internal/ItemMetadata.h (+1/-0) include/unity/storage/provider/internal/ProviderInterface.h (+1/-0) include/unity/storage/provider/internal/TempfileUploadJobImpl.h (+1/-0) include/unity/storage/qt/client/Exceptions.h (+3/-0) include/unity/storage/qt/client/internal/remote_client/UploaderImpl.h (+3/-0) src/qt/client/internal/local_client/DownloaderImpl.cpp (+3/-0) src/qt/client/internal/local_client/ItemImpl.cpp (+1/-0) src/qt/client/internal/local_client/UploaderImpl.cpp (+4/-0) src/qt/client/internal/remote_client/DownloaderImpl.cpp (+2/-2) src/qt/client/internal/remote_client/UploaderImpl.cpp (+11/-3) |
To merge this branch: | bzr merge lp:~michihenning/storage-framework/add-cancel-on-destroy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
unity-api-1-bot | continuous-integration | Approve | |
James Henstridge | Approve | ||
Review via email:
|
Commit message
Send cancel message to server if uploader is destroyed without a prior call to
cancel() or finish_upload().
Description of the change
Send cancel message to server if uploader is destroyed without a prior
call to cancel() or finish_upload().
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
- 65. By Michi Henning
-
Suppressed a bunch more compiler warnings from Arm builds.
- 66. By Michi Henning
-
Suppressed one more compiler warning.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:65
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:66
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Henstridge (jamesh) wrote : | # |
I've left an inline comment.
While reading the surrounding code, I think I spotted a bug in UploaderImpl:
Has it really made the code clearer to have these make_ready_
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michi Henning (michihenning) wrote : | # |
Thanks for spotting that bug, it now sets the future via the QFutureInterface.
The QFuture overloads in make_future.h are a little dangerous because it's easy to accidentally return a new future instead of instead of setting the one inside the QFutureInterface.
I'll have a look at cleaning this up in a separate MR.
- 67. By Michi Henning
-
Set future via the promise in the handler rather than returning a new ready future.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Henstridge (jamesh) wrote : | # |
Looks good!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Henstridge (jamesh) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:67
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'include/unity/storage/internal/ItemMetadata.h' | |||
2 | --- include/unity/storage/internal/ItemMetadata.h 2016-08-11 04:37:13 +0000 | |||
3 | +++ include/unity/storage/internal/ItemMetadata.h 2016-08-26 02:52:25 +0000 | |||
4 | @@ -21,6 +21,7 @@ | |||
5 | 21 | #include <unity/storage/common.h> | 21 | #include <unity/storage/common.h> |
6 | 22 | 22 | ||
7 | 23 | #pragma GCC diagnostic push | 23 | #pragma GCC diagnostic push |
8 | 24 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
9 | 24 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | 25 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
10 | 25 | #pragma GCC diagnostic ignored "-Wswitch-default" | 26 | #pragma GCC diagnostic ignored "-Wswitch-default" |
11 | 26 | #include <QMap> | 27 | #include <QMap> |
12 | 27 | 28 | ||
13 | === modified file 'include/unity/storage/provider/internal/ProviderInterface.h' | |||
14 | --- include/unity/storage/provider/internal/ProviderInterface.h 2016-08-03 03:55:20 +0000 | |||
15 | +++ include/unity/storage/provider/internal/ProviderInterface.h 2016-08-26 02:52:25 +0000 | |||
16 | @@ -22,6 +22,7 @@ | |||
17 | 22 | #include <unity/storage/provider/internal/Handler.h> | 22 | #include <unity/storage/provider/internal/Handler.h> |
18 | 23 | 23 | ||
19 | 24 | #pragma GCC diagnostic push | 24 | #pragma GCC diagnostic push |
20 | 25 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
21 | 25 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | 26 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
22 | 26 | #pragma GCC diagnostic ignored "-Wswitch-default" | 27 | #pragma GCC diagnostic ignored "-Wswitch-default" |
23 | 27 | #include <QObject> | 28 | #include <QObject> |
24 | 28 | 29 | ||
25 | === modified file 'include/unity/storage/provider/internal/TempfileUploadJobImpl.h' | |||
26 | --- include/unity/storage/provider/internal/TempfileUploadJobImpl.h 2016-08-23 09:09:22 +0000 | |||
27 | +++ include/unity/storage/provider/internal/TempfileUploadJobImpl.h 2016-08-26 02:52:25 +0000 | |||
28 | @@ -21,6 +21,7 @@ | |||
29 | 21 | #include <unity/storage/provider/internal/UploadJobImpl.h> | 21 | #include <unity/storage/provider/internal/UploadJobImpl.h> |
30 | 22 | 22 | ||
31 | 23 | #pragma GCC diagnostic push | 23 | #pragma GCC diagnostic push |
32 | 24 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
33 | 24 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | 25 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
34 | 25 | #include <QLocalSocket> | 26 | #include <QLocalSocket> |
35 | 26 | #include <QTemporaryFile> | 27 | #include <QTemporaryFile> |
36 | 27 | 28 | ||
37 | === modified file 'include/unity/storage/qt/client/Exceptions.h' | |||
38 | --- include/unity/storage/qt/client/Exceptions.h 2016-08-05 05:37:23 +0000 | |||
39 | +++ include/unity/storage/qt/client/Exceptions.h 2016-08-26 02:52:25 +0000 | |||
40 | @@ -20,7 +20,10 @@ | |||
41 | 20 | 20 | ||
42 | 21 | #include <unity/storage/visibility.h> | 21 | #include <unity/storage/visibility.h> |
43 | 22 | 22 | ||
44 | 23 | #pragma GCC diagnostic push | ||
45 | 24 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
46 | 23 | #include <QException> | 25 | #include <QException> |
47 | 26 | #pragma GCC diagnostic pop | ||
48 | 24 | #include <QString> | 27 | #include <QString> |
49 | 25 | 28 | ||
50 | 26 | namespace unity | 29 | namespace unity |
51 | 27 | 30 | ||
52 | === modified file 'include/unity/storage/qt/client/internal/remote_client/UploaderImpl.h' | |||
53 | --- include/unity/storage/qt/client/internal/remote_client/UploaderImpl.h 2016-08-03 03:20:39 +0000 | |||
54 | +++ include/unity/storage/qt/client/internal/remote_client/UploaderImpl.h 2016-08-26 02:52:25 +0000 | |||
55 | @@ -65,12 +65,15 @@ | |||
56 | 65 | std::shared_ptr<ProviderInterface> const& provider); | 65 | std::shared_ptr<ProviderInterface> const& provider); |
57 | 66 | 66 | ||
58 | 67 | private: | 67 | private: |
59 | 68 | enum State { uploading, finalized }; | ||
60 | 69 | |||
61 | 68 | QString upload_id_; | 70 | QString upload_id_; |
62 | 69 | QDBusUnixFileDescriptor fd_; | 71 | QDBusUnixFileDescriptor fd_; |
63 | 70 | QString old_etag_; | 72 | QString old_etag_; |
64 | 71 | std::shared_ptr<Root> root_; | 73 | std::shared_ptr<Root> root_; |
65 | 72 | std::shared_ptr<ProviderInterface> provider_; | 74 | std::shared_ptr<ProviderInterface> provider_; |
66 | 73 | std::shared_ptr<QLocalSocket> write_socket_; | 75 | std::shared_ptr<QLocalSocket> write_socket_; |
67 | 76 | State state_; | ||
68 | 74 | }; | 77 | }; |
69 | 75 | 78 | ||
70 | 76 | } // namespace remote_client | 79 | } // namespace remote_client |
71 | 77 | 80 | ||
72 | === modified file 'src/qt/client/internal/local_client/DownloaderImpl.cpp' | |||
73 | --- src/qt/client/internal/local_client/DownloaderImpl.cpp 2016-08-11 01:34:55 +0000 | |||
74 | +++ src/qt/client/internal/local_client/DownloaderImpl.cpp 2016-08-26 02:52:25 +0000 | |||
75 | @@ -23,7 +23,10 @@ | |||
76 | 23 | #include <unity/storage/qt/client/File.h> | 23 | #include <unity/storage/qt/client/File.h> |
77 | 24 | #include <unity/storage/qt/client/internal/make_future.h> | 24 | #include <unity/storage/qt/client/internal/make_future.h> |
78 | 25 | 25 | ||
79 | 26 | #pragma GCC diagnostic push | ||
80 | 27 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
81 | 26 | #include <QLocalSocket> | 28 | #include <QLocalSocket> |
82 | 29 | #pragma GCC diagnostic pop | ||
83 | 27 | 30 | ||
84 | 28 | #include <cassert> | 31 | #include <cassert> |
85 | 29 | 32 | ||
86 | 30 | 33 | ||
87 | === modified file 'src/qt/client/internal/local_client/ItemImpl.cpp' | |||
88 | --- src/qt/client/internal/local_client/ItemImpl.cpp 2016-08-03 06:09:59 +0000 | |||
89 | +++ src/qt/client/internal/local_client/ItemImpl.cpp 2016-08-26 02:52:25 +0000 | |||
90 | @@ -30,6 +30,7 @@ | |||
91 | 30 | 30 | ||
92 | 31 | #include <boost/algorithm/string/predicate.hpp> | 31 | #include <boost/algorithm/string/predicate.hpp> |
93 | 32 | #pragma GCC diagnostic push | 32 | #pragma GCC diagnostic push |
94 | 33 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
95 | 33 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | 34 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
96 | 34 | #include <QtConcurrent> | 35 | #include <QtConcurrent> |
97 | 35 | #pragma GCC diagnostic pop | 36 | #pragma GCC diagnostic pop |
98 | 36 | 37 | ||
99 | === modified file 'src/qt/client/internal/local_client/UploaderImpl.cpp' | |||
100 | --- src/qt/client/internal/local_client/UploaderImpl.cpp 2016-08-25 05:18:37 +0000 | |||
101 | +++ src/qt/client/internal/local_client/UploaderImpl.cpp 2016-08-26 02:52:25 +0000 | |||
102 | @@ -25,7 +25,11 @@ | |||
103 | 25 | #include <unity/storage/qt/client/internal/local_client/tmpfile_prefix.h> | 25 | #include <unity/storage/qt/client/internal/local_client/tmpfile_prefix.h> |
104 | 26 | #include <unity/storage/qt/client/internal/make_future.h> | 26 | #include <unity/storage/qt/client/internal/make_future.h> |
105 | 27 | 27 | ||
106 | 28 | |||
107 | 29 | #pragma GCC diagnostic push | ||
108 | 30 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
109 | 28 | #include <QLocalSocket> | 31 | #include <QLocalSocket> |
110 | 32 | #pragma GCC diagnostic pop | ||
111 | 29 | 33 | ||
112 | 30 | #include <cassert> | 34 | #include <cassert> |
113 | 31 | 35 | ||
114 | 32 | 36 | ||
115 | === modified file 'src/qt/client/internal/remote_client/DownloaderImpl.cpp' | |||
116 | --- src/qt/client/internal/remote_client/DownloaderImpl.cpp 2016-08-03 04:13:28 +0000 | |||
117 | +++ src/qt/client/internal/remote_client/DownloaderImpl.cpp 2016-08-26 02:52:25 +0000 | |||
118 | @@ -79,9 +79,9 @@ | |||
119 | 79 | { | 79 | { |
120 | 80 | auto reply = provider_->FinishDownload(download_id_); | 80 | auto reply = provider_->FinishDownload(download_id_); |
121 | 81 | 81 | ||
123 | 82 | auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>&) | 82 | auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf) |
124 | 83 | { | 83 | { |
126 | 84 | make_ready_future(); | 84 | make_ready_future(qf); |
127 | 85 | }; | 85 | }; |
128 | 86 | 86 | ||
129 | 87 | auto handler = new Handler<void>(this, reply, process_reply); | 87 | auto handler = new Handler<void>(this, reply, process_reply); |
130 | 88 | 88 | ||
131 | === modified file 'src/qt/client/internal/remote_client/UploaderImpl.cpp' | |||
132 | --- src/qt/client/internal/remote_client/UploaderImpl.cpp 2016-08-09 02:25:13 +0000 | |||
133 | +++ src/qt/client/internal/remote_client/UploaderImpl.cpp 2016-08-26 02:52:25 +0000 | |||
134 | @@ -54,6 +54,7 @@ | |||
135 | 54 | , root_(root.lock()) | 54 | , root_(root.lock()) |
136 | 55 | , provider_(provider) | 55 | , provider_(provider) |
137 | 56 | , write_socket_(new QLocalSocket) | 56 | , write_socket_(new QLocalSocket) |
138 | 57 | , state_(uploading) | ||
139 | 57 | { | 58 | { |
140 | 58 | assert(!upload_id.isEmpty()); | 59 | assert(!upload_id.isEmpty()); |
141 | 59 | assert(fd.isValid()); | 60 | assert(fd.isValid()); |
142 | @@ -66,7 +67,10 @@ | |||
143 | 66 | 67 | ||
144 | 67 | UploaderImpl::~UploaderImpl() | 68 | UploaderImpl::~UploaderImpl() |
145 | 68 | { | 69 | { |
147 | 69 | write_socket_->abort(); | 70 | if (state_ == uploading) |
148 | 71 | { | ||
149 | 72 | provider_->CancelUpload(upload_id_); | ||
150 | 73 | } | ||
151 | 70 | } | 74 | } |
152 | 71 | 75 | ||
153 | 72 | shared_ptr<QLocalSocket> UploaderImpl::socket() const | 76 | shared_ptr<QLocalSocket> UploaderImpl::socket() const |
154 | @@ -76,6 +80,8 @@ | |||
155 | 76 | 80 | ||
156 | 77 | QFuture<shared_ptr<File>> UploaderImpl::finish_upload() | 81 | QFuture<shared_ptr<File>> UploaderImpl::finish_upload() |
157 | 78 | { | 82 | { |
158 | 83 | state_ = finalized; | ||
159 | 84 | |||
160 | 79 | auto reply = provider_->FinishUpload(upload_id_); | 85 | auto reply = provider_->FinishUpload(upload_id_); |
161 | 80 | auto process_reply = [this](decltype(reply) const& reply, QFutureInterface<shared_ptr<File>>& qf) | 86 | auto process_reply = [this](decltype(reply) const& reply, QFutureInterface<shared_ptr<File>>& qf) |
162 | 81 | { | 87 | { |
163 | @@ -107,10 +113,12 @@ | |||
164 | 107 | 113 | ||
165 | 108 | QFuture<void> UploaderImpl::cancel() noexcept | 114 | QFuture<void> UploaderImpl::cancel() noexcept |
166 | 109 | { | 115 | { |
167 | 116 | state_ = finalized; | ||
168 | 117 | |||
169 | 110 | auto reply = provider_->CancelUpload(upload_id_); | 118 | auto reply = provider_->CancelUpload(upload_id_); |
171 | 111 | auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>&) | 119 | auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf) |
172 | 112 | { | 120 | { |
174 | 113 | make_ready_future(); | 121 | make_ready_future(qf); |
175 | 114 | }; | 122 | }; |
176 | 115 | 123 | ||
177 | 116 | write_socket_->abort(); | 124 | write_socket_->abort(); |
PASSED: Continuous integration, rev:64 /jenkins. canonical. com/unity- api-1/job/ lp-storage- framework- ci/97/ /jenkins. canonical. com/unity- api-1/job/ build/498 /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/504 /jenkins. canonical. com/unity- api-1/job/ build-1- sourcepkg/ release= vivid+overlay/ 409 /jenkins. canonical. com/unity- api-1/job/ build-1- sourcepkg/ release= xenial+ overlay/ 409 /jenkins. canonical. com/unity- api-1/job/ build-1- sourcepkg/ release= yakkety/ 409 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= yakkety/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= yakkety/ 339/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-storage- framework- ci/97/rebuild
https:/