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
2e471dae
Commit
2e471dae
authored
Aug 29, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage/nfs: migrate from TimeoutMonitor to TimerEvent
parent
7ae57a35
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
NfsStorage.cxx
src/storage/plugins/NfsStorage.cxx
+11
-8
No files found.
src/storage/plugins/NfsStorage.cxx
View file @
2e471dae
...
...
@@ -34,7 +34,7 @@
#include "event/Loop.hxx"
#include "event/Call.hxx"
#include "event/DeferredMonitor.hxx"
#include "event/Time
outMonitor
.hxx"
#include "event/Time
rEvent
.hxx"
#include "util/StringCompare.hxx"
extern
"C"
{
...
...
@@ -49,7 +49,7 @@ extern "C" {
#include <fcntl.h>
class
NfsStorage
final
:
public
Storage
,
NfsLease
,
DeferredMonitor
,
TimeoutMonitor
{
:
public
Storage
,
NfsLease
,
DeferredMonitor
{
enum
class
State
{
INITIAL
,
CONNECTING
,
READY
,
DELAY
,
...
...
@@ -61,6 +61,8 @@ class NfsStorage final
NfsConnection
*
connection
;
TimerEvent
reconnect_timer
;
Mutex
mutex
;
Cond
cond
;
State
state
;
...
...
@@ -69,10 +71,11 @@ class NfsStorage final
public
:
NfsStorage
(
EventLoop
&
_loop
,
const
char
*
_base
,
std
::
string
&&
_server
,
std
::
string
&&
_export_name
)
:
DeferredMonitor
(
_loop
),
TimeoutMonitor
(
_loop
),
:
DeferredMonitor
(
_loop
),
base
(
_base
),
server
(
std
::
move
(
_server
)),
export_name
(
std
::
move
(
_export_name
)),
reconnect_timer
(
_loop
,
BIND_THIS_METHOD
(
OnReconnectTimer
)),
state
(
State
::
INITIAL
)
{
nfs_init
(
_loop
);
}
...
...
@@ -102,14 +105,14 @@ public:
assert
(
state
==
State
::
CONNECTING
);
SetState
(
State
::
DELAY
,
std
::
move
(
e
));
TimeoutMonitor
::
Schedule
(
std
::
chrono
::
minutes
(
1
));
reconnect_timer
.
Schedule
(
std
::
chrono
::
minutes
(
1
));
}
void
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
final
{
assert
(
state
==
State
::
READY
);
SetState
(
State
::
DELAY
,
std
::
move
(
e
));
TimeoutMonitor
::
Schedule
(
std
::
chrono
::
seconds
(
5
));
reconnect_timer
.
Schedule
(
std
::
chrono
::
seconds
(
5
));
}
/* virtual methods from DeferredMonitor */
...
...
@@ -118,8 +121,8 @@ public:
Connect
();
}
/*
virtual methods from TimeoutMonito
r */
void
On
Timeout
()
final
{
/*
callback for #reconnect_time
r */
void
On
ReconnectTimer
()
{
assert
(
state
==
State
::
DELAY
);
Connect
();
...
...
@@ -203,7 +206,7 @@ private:
break
;
case
State
:
:
DELAY
:
TimeoutMonitor
::
Cancel
();
reconnect_timer
.
Cancel
();
SetState
(
State
::
INITIAL
);
break
;
}
...
...
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