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
82da364b
Commit
82da364b
authored
Dec 14, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/nfs/Connection: implement mount timeout
parent
7fa91ec1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
NEWS
NEWS
+1
-0
Connection.cxx
src/lib/nfs/Connection.cxx
+24
-0
Connection.hxx
src/lib/nfs/Connection.hxx
+7
-2
No files found.
NEWS
View file @
82da364b
...
...
@@ -3,6 +3,7 @@ ver 0.19.7 (not yet released)
- nfs: fix crash while canceling a failing file open operation
- nfs: fix memory leak on connection failure
- nfs: fix reconnect after mount failure
- nfs: implement mount timeout (60 seconds)
* playlist
- don't skip non-existent songs in "listplaylist"
* fix memory allocator bug on Windows
...
...
src/lib/nfs/Connection.cxx
View file @
82da364b
...
...
@@ -34,6 +34,8 @@ extern "C" {
#include <poll.h>
/* for POLLIN, POLLOUT */
static
constexpr
unsigned
NFS_MOUNT_TIMEOUT
=
60
;
inline
bool
NfsConnection
::
CancellableCallback
::
Stat
(
nfs_context
*
ctx
,
const
char
*
path
,
...
...
@@ -379,6 +381,11 @@ NfsConnection::DestroyContext()
in_destroy
=
true
;
#endif
if
(
!
mount_finished
)
{
assert
(
TimeoutMonitor
::
IsActive
());
TimeoutMonitor
::
Cancel
();
}
/* cancel pending DeferredMonitor that was scheduled to notify
new leases */
DeferredMonitor
::
Cancel
();
...
...
@@ -528,6 +535,9 @@ NfsConnection::MountCallback(int status, gcc_unused nfs_context *nfs,
mount_finished
=
true
;
assert
(
TimeoutMonitor
::
IsActive
()
||
in_destroy
);
TimeoutMonitor
::
Cancel
();
if
(
status
<
0
)
{
postponed_mount_error
.
Format
(
nfs_domain
,
status
,
"nfs_mount_async() failed: %s"
,
...
...
@@ -560,6 +570,8 @@ NfsConnection::MountInternal(Error &error)
postponed_mount_error
.
Clear
();
mount_finished
=
false
;
TimeoutMonitor
::
ScheduleSeconds
(
NFS_MOUNT_TIMEOUT
);
#ifndef NDEBUG
in_service
=
false
;
in_event
=
false
;
...
...
@@ -621,6 +633,18 @@ NfsConnection::BroadcastError(Error &&error)
}
void
NfsConnection
::
OnTimeout
()
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
!
mount_finished
);
mount_finished
=
true
;
DestroyContext
();
BroadcastMountError
(
Error
(
nfs_domain
,
"Mount timeout"
));
}
void
NfsConnection
::
RunDeferred
()
{
assert
(
GetEventLoop
().
IsInside
());
...
...
src/lib/nfs/Connection.hxx
View file @
82da364b
...
...
@@ -23,6 +23,7 @@
#include "Lease.hxx"
#include "Cancellable.hxx"
#include "event/SocketMonitor.hxx"
#include "event/TimeoutMonitor.hxx"
#include "event/DeferredMonitor.hxx"
#include "util/Error.hxx"
...
...
@@ -40,7 +41,7 @@ class NfsCallback;
/**
* An asynchronous connection to a NFS server.
*/
class
NfsConnection
:
SocketMonitor
,
DeferredMonitor
{
class
NfsConnection
:
SocketMonitor
,
TimeoutMonitor
,
DeferredMonitor
{
class
CancellableCallback
:
public
CancellablePointer
<
NfsCallback
>
{
NfsConnection
&
connection
;
...
...
@@ -142,7 +143,8 @@ public:
gcc_nonnull_all
NfsConnection
(
EventLoop
&
_loop
,
const
char
*
_server
,
const
char
*
_export_name
)
:
SocketMonitor
(
_loop
),
DeferredMonitor
(
_loop
),
:
SocketMonitor
(
_loop
),
TimeoutMonitor
(
_loop
),
DeferredMonitor
(
_loop
),
server
(
_server
),
export_name
(
_export_name
),
context
(
nullptr
)
{}
...
...
@@ -227,6 +229,9 @@ private:
/* virtual methods from SocketMonitor */
virtual
bool
OnSocketReady
(
unsigned
flags
)
override
;
/* virtual methods from TimeoutMonitor */
void
OnTimeout
()
final
;
/* virtual methods from DeferredMonitor */
virtual
void
RunDeferred
()
override
;
};
...
...
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