Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7640609b
Commit
7640609b
authored
Jan 24, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/tidal: retry if session is expired
parent
e8e6357b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
TidalInputPlugin.cxx
src/input/plugins/TidalInputPlugin.cxx
+33
-0
No files found.
src/input/plugins/TidalInputPlugin.cxx
View file @
7640609b
...
...
@@ -21,6 +21,7 @@
#include "TidalInputPlugin.hxx"
#include "TidalSessionManager.hxx"
#include "TidalTrackRequest.hxx"
#include "TidalError.hxx"
#include "CurlInputPlugin.hxx"
#include "PluginUnavailable.hxx"
#include "input/ProxyInputStream.hxx"
...
...
@@ -29,6 +30,7 @@
#include "config/Block.hxx"
#include "thread/Mutex.hxx"
#include "util/Domain.hxx"
#include "util/Exception.hxx"
#include "util/StringCompare.hxx"
#include "Log.hxx"
...
...
@@ -48,6 +50,12 @@ class TidalInputStream final
std
::
exception_ptr
error
;
/**
* Retry to login if TidalError::IsInvalidSession() returns
* true?
*/
bool
retry_login
=
true
;
public
:
TidalInputStream
(
const
char
*
_uri
,
const
char
*
_track_id
,
Mutex
&
_mutex
,
Cond
&
_cond
)
noexcept
...
...
@@ -119,11 +127,36 @@ TidalInputStream::OnTidalTrackSuccess(std::string url) noexcept
}
}
gcc_pure
static
bool
IsInvalidSession
(
std
::
exception_ptr
e
)
noexcept
{
try
{
std
::
rethrow_exception
(
e
);
}
catch
(
const
TidalError
&
te
)
{
return
te
.
IsInvalidSession
();
}
catch
(...)
{
return
false
;
}
}
void
TidalInputStream
::
OnTidalTrackError
(
std
::
exception_ptr
e
)
noexcept
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
if
(
retry_login
&&
IsInvalidSession
(
e
))
{
/* the session has expired - obtain a new session id
by logging in again */
FormatInfo
(
tidal_domain
,
"Session expired ('%s'), retrying to log in"
,
GetFullMessage
(
e
).
c_str
());
retry_login
=
false
;
tidal_session
->
AddLoginHandler
(
*
this
);
return
;
}
Failed
(
e
);
}
...
...
Write
Preview
Markdown
is supported
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