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
60589fc1
Commit
60589fc1
authored
Sep 02, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/nfs: auto-reconnect if failed while paused
parent
51213160
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
1 deletion
+46
-1
NfsInputPlugin.cxx
src/input/plugins/NfsInputPlugin.cxx
+46
-1
No files found.
src/input/plugins/NfsInputPlugin.cxx
View file @
60589fc1
...
...
@@ -51,13 +51,16 @@ static const size_t NFS_RESUME_AT = 384 * 1024;
class
NfsInputStream
final
:
public
AsyncInputStream
,
NfsFileReader
{
uint64_t
next_offset
;
bool
reconnect_on_resume
,
reconnecting
;
public
:
NfsInputStream
(
const
char
*
_uri
,
Mutex
&
_mutex
,
Cond
&
_cond
,
void
*
_buffer
)
:
AsyncInputStream
(
_uri
,
_mutex
,
_cond
,
_buffer
,
NFS_MAX_BUFFERED
,
NFS_RESUME_AT
)
{}
NFS_RESUME_AT
),
reconnect_on_resume
(
false
),
reconnecting
(
false
)
{}
virtual
~
NfsInputStream
()
{
DeferClose
();
...
...
@@ -118,6 +121,28 @@ NfsInputStream::DoRead()
void
NfsInputStream
::
DoResume
()
{
if
(
reconnect_on_resume
)
{
/* the NFS connection has died while this stream was
"paused" - attempt to reconnect */
reconnect_on_resume
=
false
;
reconnecting
=
true
;
mutex
.
unlock
();
NfsFileReader
::
Close
();
Error
error
;
bool
success
=
NfsFileReader
::
Open
(
GetURI
(),
error
);
mutex
.
lock
();
if
(
!
success
)
{
postponed_error
=
std
::
move
(
error
);
cond
.
broadcast
();
}
return
;
}
assert
(
NfsFileReader
::
IsIdle
());
DoRead
();
...
...
@@ -140,6 +165,14 @@ NfsInputStream::OnNfsFileOpen(uint64_t _size)
{
const
ScopeLock
protect
(
mutex
);
if
(
reconnecting
)
{
/* reconnect has succeeded */
reconnecting
=
false
;
DoRead
();
return
;
}
size
=
_size
;
seekable
=
true
;
next_offset
=
0
;
...
...
@@ -164,6 +197,18 @@ void
NfsInputStream
::
OnNfsFileError
(
Error
&&
error
)
{
const
ScopeLock
protect
(
mutex
);
if
(
IsPaused
())
{
/* while we're paused, don't report this error to the
client just yet (it might just be timeout, maybe
playback has been paused for quite some time) -
wait until the stream gets resumed and try to
reconnect, to give it another chance */
reconnect_on_resume
=
true
;
return
;
}
postponed_error
=
std
::
move
(
error
);
if
(
IsSeekPending
())
...
...
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