Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
GSoC
GSoC2017
dbtdsilva
libcloudstorage
Commits
2391be9e
Commit
2391be9e
authored
Aug 22, 2017
by
Paweł Wegner
Browse files
Removed invalid is_cancelled calls.
parent
cc9eb72e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/CloudProvider/MegaNz.cpp
View file @
2391be9e
...
...
@@ -456,8 +456,6 @@ AuthorizeRequest::Pointer MegaNz::authorizeAsync() {
shared_from_this
(),
[
=
](
AuthorizeRequest
::
Pointer
r
,
AuthorizeRequest
::
AuthorizeCompleted
complete
)
{
auto
fetch
=
[
=
]()
{
if
(
r
->
is_cancelled
())
return
complete
(
Error
{
IHttpRequest
::
Aborted
,
""
});
auto
fetch_nodes_listener
=
std
::
make_shared
<
RequestListener
>
(
[
=
](
EitherError
<
void
>
e
,
Listener
*
)
{
if
(
!
e
.
left
())
authorized_
=
true
;
...
...
@@ -826,10 +824,6 @@ void MegaNz::ensureAuthorized(typename Request<T>::Ptr r,
if
(
e
.
left
())
{
on_error
(
e
.
left
());
r
->
done
(
e
.
left
());
}
else
if
(
r
->
is_cancelled
())
{
Error
e
{
IHttpRequest
::
Aborted
,
""
};
on_error
(
e
);
r
->
done
(
e
);
}
else
on_success
();
};
...
...
src/Request/AuthorizeRequest.cpp
View file @
2391be9e
...
...
@@ -29,7 +29,7 @@ namespace cloudstorage {
AuthorizeRequest
::
AuthorizeRequest
(
std
::
shared_ptr
<
CloudProvider
>
p
,
AuthorizationFlow
callback
)
:
Request
(
p
),
state_
(
provider
()
->
auth
()
->
state
())
{
:
Request
(
p
),
state_
(
provider
()
->
auth
()
->
state
())
,
server_cancelled_
()
{
if
(
!
provider
()
->
auth_callback
())
throw
std
::
logic_error
(
"CloudProvider's callback can't be null."
);
set
([
=
](
Request
::
Ptr
request
)
{
...
...
@@ -62,6 +62,7 @@ AuthorizeRequest::~AuthorizeRequest() { cancel(); }
void
AuthorizeRequest
::
sendCancel
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
lock_
);
auto
auth_server
=
std
::
move
(
auth_server_
);
server_cancelled_
=
true
;
lock
.
unlock
();
if
(
auth_server
)
{
class
Connection
:
public
IHttpServer
::
IConnection
{
...
...
@@ -104,11 +105,12 @@ void AuthorizeRequest::cancel() {
}
void
AuthorizeRequest
::
set_server
(
std
::
shared_ptr
<
IHttpServer
>
p
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lock_
);
auth_server_
=
p
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
lock_
);
auth_server_
=
p
;
if
(
p
&&
server_cancelled_
)
{
lock
.
unlock
();
sendCancel
();
}
if
(
p
&&
is_cancelled
())
sendCancel
();
}
void
AuthorizeRequest
::
oauth2Authorization
(
AuthorizeCompleted
complete
)
{
...
...
src/Request/AuthorizeRequest.h
View file @
2391be9e
...
...
@@ -48,6 +48,7 @@ class AuthorizeRequest : public Request<EitherError<void>> {
private:
std
::
string
state_
;
std
::
mutex
lock_
;
bool
server_cancelled_
;
std
::
shared_ptr
<
IHttpServer
>
auth_server_
;
};
...
...
src/Request/Request.cpp
View file @
2391be9e
...
...
@@ -144,24 +144,19 @@ void Request<T>::reauthorize(AuthorizeCompleted c) {
auto
p
=
provider
();
if
(
!
p
)
return
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
p
->
current_authorization_mutex_
);
if
(
is_cancelled
())
{
lock
.
unlock
();
c
(
Error
{
IHttpRequest
::
Aborted
,
""
});
}
else
{
p
->
auth_callbacks_
[
this
].
push_back
(
c
);
if
(
!
p
->
current_authorization_
)
{
{
auto
r
=
p
->
authorizeAsync
();
p
->
current_authorization_
=
r
;
lock
.
unlock
();
r
->
run
();
}
lock
.
lock
();
p
->
auth_callbacks_
[
this
].
push_back
(
c
);
if
(
!
p
->
current_authorization_
)
{
{
auto
r
=
p
->
authorizeAsync
();
p
->
current_authorization_
=
r
;
lock
.
unlock
();
r
->
run
();
}
auto
r
=
p
->
current_authorization_
;
lock
.
unlock
();
if
(
r
)
subrequest
(
r
);
lock
.
lock
();
}
auto
r
=
p
->
current_authorization_
;
lock
.
unlock
();
if
(
r
)
subrequest
(
r
);
}
template
<
class
T
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment