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
a92e0e85
Commit
a92e0e85
authored
Nov 12, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/nfs: add "noexcept"
parent
9d47b220
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
132 additions
and
130 deletions
+132
-130
NfsInputPlugin.cxx
src/input/plugins/NfsInputPlugin.cxx
+7
-7
Base.cxx
src/lib/nfs/Base.cxx
+1
-1
Base.hxx
src/lib/nfs/Base.hxx
+1
-1
Blocking.cxx
src/lib/nfs/Blocking.cxx
+5
-5
Blocking.hxx
src/lib/nfs/Blocking.hxx
+9
-9
Callback.hxx
src/lib/nfs/Callback.hxx
+2
-2
Connection.cxx
src/lib/nfs/Connection.cxx
+27
-26
Connection.hxx
src/lib/nfs/Connection.hxx
+25
-25
FileReader.cxx
src/lib/nfs/FileReader.cxx
+13
-13
FileReader.hxx
src/lib/nfs/FileReader.hxx
+17
-17
Lease.hxx
src/lib/nfs/Lease.hxx
+3
-3
Manager.cxx
src/lib/nfs/Manager.cxx
+3
-3
Manager.hxx
src/lib/nfs/Manager.hxx
+6
-6
NfsStorage.cxx
src/storage/plugins/NfsStorage.cxx
+13
-12
No files found.
src/input/plugins/NfsInputPlugin.cxx
View file @
a92e0e85
...
@@ -72,9 +72,9 @@ protected:
...
@@ -72,9 +72,9 @@ protected:
private
:
private
:
/* virtual methods from NfsFileReader */
/* virtual methods from NfsFileReader */
void
OnNfsFileOpen
(
uint64_t
size
)
override
;
void
OnNfsFileOpen
(
uint64_t
size
)
noexcept
override
;
void
OnNfsFileRead
(
const
void
*
data
,
size_t
size
)
override
;
void
OnNfsFileRead
(
const
void
*
data
,
size_t
size
)
noexcept
override
;
void
OnNfsFileError
(
std
::
exception_ptr
&&
e
)
override
;
void
OnNfsFileError
(
std
::
exception_ptr
&&
e
)
noexcept
override
;
};
};
void
void
...
@@ -141,7 +141,7 @@ NfsInputStream::DoSeek(offset_type new_offset)
...
@@ -141,7 +141,7 @@ NfsInputStream::DoSeek(offset_type new_offset)
}
}
void
void
NfsInputStream
::
OnNfsFileOpen
(
uint64_t
_size
)
NfsInputStream
::
OnNfsFileOpen
(
uint64_t
_size
)
noexcept
{
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
...
@@ -161,7 +161,7 @@ NfsInputStream::OnNfsFileOpen(uint64_t _size)
...
@@ -161,7 +161,7 @@ NfsInputStream::OnNfsFileOpen(uint64_t _size)
}
}
void
void
NfsInputStream
::
OnNfsFileRead
(
const
void
*
data
,
size_t
data_size
)
NfsInputStream
::
OnNfsFileRead
(
const
void
*
data
,
size_t
data_size
)
noexcept
{
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
assert
(
!
IsBufferFull
());
assert
(
!
IsBufferFull
());
...
@@ -174,7 +174,7 @@ NfsInputStream::OnNfsFileRead(const void *data, size_t data_size)
...
@@ -174,7 +174,7 @@ NfsInputStream::OnNfsFileRead(const void *data, size_t data_size)
}
}
void
void
NfsInputStream
::
OnNfsFileError
(
std
::
exception_ptr
&&
e
)
NfsInputStream
::
OnNfsFileError
(
std
::
exception_ptr
&&
e
)
noexcept
{
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
...
@@ -211,7 +211,7 @@ input_nfs_init(EventLoop &event_loop, const ConfigBlock &)
...
@@ -211,7 +211,7 @@ input_nfs_init(EventLoop &event_loop, const ConfigBlock &)
}
}
static
void
static
void
input_nfs_finish
()
input_nfs_finish
()
noexcept
{
{
nfs_finish
();
nfs_finish
();
}
}
...
...
src/lib/nfs/Base.cxx
View file @
a92e0e85
...
@@ -28,7 +28,7 @@ static char nfs_base_export_name[256];
...
@@ -28,7 +28,7 @@ static char nfs_base_export_name[256];
static
size_t
nfs_base_export_name_length
;
static
size_t
nfs_base_export_name_length
;
void
void
nfs_set_base
(
const
char
*
server
,
const
char
*
export_name
)
nfs_set_base
(
const
char
*
server
,
const
char
*
export_name
)
noexcept
{
{
assert
(
server
!=
nullptr
);
assert
(
server
!=
nullptr
);
assert
(
export_name
!=
nullptr
);
assert
(
export_name
!=
nullptr
);
...
...
src/lib/nfs/Base.hxx
View file @
a92e0e85
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
* This is a kludge that is not truly thread-safe.
* This is a kludge that is not truly thread-safe.
*/
*/
void
void
nfs_set_base
(
const
char
*
server
,
const
char
*
export_name
);
nfs_set_base
(
const
char
*
server
,
const
char
*
export_name
)
noexcept
;
/**
/**
* Check if the given server and path are inside the "base"
* Check if the given server and path are inside the "base"
...
...
src/lib/nfs/Blocking.cxx
View file @
a92e0e85
...
@@ -42,7 +42,7 @@ BlockingNfsOperation::Run()
...
@@ -42,7 +42,7 @@ BlockingNfsOperation::Run()
}
}
void
void
BlockingNfsOperation
::
OnNfsConnectionReady
()
BlockingNfsOperation
::
OnNfsConnectionReady
()
noexcept
{
{
try
{
try
{
Start
();
Start
();
...
@@ -54,21 +54,21 @@ BlockingNfsOperation::OnNfsConnectionReady()
...
@@ -54,21 +54,21 @@ BlockingNfsOperation::OnNfsConnectionReady()
}
}
void
void
BlockingNfsOperation
::
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
BlockingNfsOperation
::
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
noexcept
{
{
error
=
std
::
move
(
e
);
error
=
std
::
move
(
e
);
LockSetFinished
();
LockSetFinished
();
}
}
void
void
BlockingNfsOperation
::
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
BlockingNfsOperation
::
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
noexcept
{
{
error
=
std
::
move
(
e
);
error
=
std
::
move
(
e
);
LockSetFinished
();
LockSetFinished
();
}
}
void
void
BlockingNfsOperation
::
OnNfsCallback
(
unsigned
status
,
void
*
data
)
BlockingNfsOperation
::
OnNfsCallback
(
unsigned
status
,
void
*
data
)
noexcept
{
{
connection
.
RemoveLease
(
*
this
);
connection
.
RemoveLease
(
*
this
);
...
@@ -77,7 +77,7 @@ BlockingNfsOperation::OnNfsCallback(unsigned status, void *data)
...
@@ -77,7 +77,7 @@ BlockingNfsOperation::OnNfsCallback(unsigned status, void *data)
}
}
void
void
BlockingNfsOperation
::
OnNfsError
(
std
::
exception_ptr
&&
e
)
BlockingNfsOperation
::
OnNfsError
(
std
::
exception_ptr
&&
e
)
noexcept
{
{
connection
.
RemoveLease
(
*
this
);
connection
.
RemoveLease
(
*
this
);
...
...
src/lib/nfs/Blocking.hxx
View file @
a92e0e85
...
@@ -50,7 +50,7 @@ protected:
...
@@ -50,7 +50,7 @@ protected:
NfsConnection
&
connection
;
NfsConnection
&
connection
;
public
:
public
:
BlockingNfsOperation
(
NfsConnection
&
_connection
)
BlockingNfsOperation
(
NfsConnection
&
_connection
)
noexcept
:
finished
(
false
),
connection
(
_connection
)
{}
:
finished
(
false
),
connection
(
_connection
)
{}
/**
/**
...
@@ -59,7 +59,7 @@ public:
...
@@ -59,7 +59,7 @@ public:
void
Run
();
void
Run
();
private
:
private
:
bool
LockWaitFinished
()
{
bool
LockWaitFinished
()
noexcept
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
while
(
!
finished
)
while
(
!
finished
)
if
(
!
cond
.
timed_wait
(
mutex
,
timeout
))
if
(
!
cond
.
timed_wait
(
mutex
,
timeout
))
...
@@ -72,24 +72,24 @@ private:
...
@@ -72,24 +72,24 @@ private:
* Mark the operation as "finished" and wake up the waiting
* Mark the operation as "finished" and wake up the waiting
* thread.
* thread.
*/
*/
void
LockSetFinished
()
{
void
LockSetFinished
()
noexcept
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
finished
=
true
;
finished
=
true
;
cond
.
signal
();
cond
.
signal
();
}
}
/* virtual methods from NfsLease */
/* virtual methods from NfsLease */
void
OnNfsConnectionReady
()
final
;
void
OnNfsConnectionReady
()
noexcept
final
;
void
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
final
;
void
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
noexcept
final
;
void
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
final
;
void
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
noexcept
final
;
/* virtual methods from NfsCallback */
/* virtual methods from NfsCallback */
void
OnNfsCallback
(
unsigned
status
,
void
*
data
)
final
;
void
OnNfsCallback
(
unsigned
status
,
void
*
data
)
noexcept
final
;
void
OnNfsError
(
std
::
exception_ptr
&&
e
)
final
;
void
OnNfsError
(
std
::
exception_ptr
&&
e
)
noexcept
final
;
protected
:
protected
:
virtual
void
Start
()
=
0
;
virtual
void
Start
()
=
0
;
virtual
void
HandleResult
(
unsigned
status
,
void
*
data
)
=
0
;
virtual
void
HandleResult
(
unsigned
status
,
void
*
data
)
noexcept
=
0
;
};
};
#endif
#endif
src/lib/nfs/Callback.hxx
View file @
a92e0e85
...
@@ -34,12 +34,12 @@ public:
...
@@ -34,12 +34,12 @@ public:
/**
/**
* The operation completed successfully.
* The operation completed successfully.
*/
*/
virtual
void
OnNfsCallback
(
unsigned
status
,
void
*
data
)
=
0
;
virtual
void
OnNfsCallback
(
unsigned
status
,
void
*
data
)
noexcept
=
0
;
/**
/**
* An error has occurred.
* An error has occurred.
*/
*/
virtual
void
OnNfsError
(
std
::
exception_ptr
&&
e
)
=
0
;
virtual
void
OnNfsError
(
std
::
exception_ptr
&&
e
)
noexcept
=
0
;
};
};
#endif
#endif
src/lib/nfs/Connection.cxx
View file @
a92e0e85
...
@@ -98,7 +98,7 @@ NfsConnection::CancellableCallback::Read(nfs_context *ctx, struct nfsfh *fh,
...
@@ -98,7 +98,7 @@ NfsConnection::CancellableCallback::Read(nfs_context *ctx, struct nfsfh *fh,
}
}
inline
void
inline
void
NfsConnection
::
CancellableCallback
::
CancelAndScheduleClose
(
struct
nfsfh
*
fh
)
NfsConnection
::
CancellableCallback
::
CancelAndScheduleClose
(
struct
nfsfh
*
fh
)
noexcept
{
{
assert
(
connection
.
GetEventLoop
().
IsInside
());
assert
(
connection
.
GetEventLoop
().
IsInside
());
assert
(
!
open
);
assert
(
!
open
);
...
@@ -110,7 +110,7 @@ NfsConnection::CancellableCallback::CancelAndScheduleClose(struct nfsfh *fh)
...
@@ -110,7 +110,7 @@ NfsConnection::CancellableCallback::CancelAndScheduleClose(struct nfsfh *fh)
}
}
inline
void
inline
void
NfsConnection
::
CancellableCallback
::
PrepareDestroyContext
()
NfsConnection
::
CancellableCallback
::
PrepareDestroyContext
()
noexcept
{
{
assert
(
IsCancelled
());
assert
(
IsCancelled
());
...
@@ -121,7 +121,7 @@ NfsConnection::CancellableCallback::PrepareDestroyContext()
...
@@ -121,7 +121,7 @@ NfsConnection::CancellableCallback::PrepareDestroyContext()
}
}
inline
void
inline
void
NfsConnection
::
CancellableCallback
::
Callback
(
int
err
,
void
*
data
)
NfsConnection
::
CancellableCallback
::
Callback
(
int
err
,
void
*
data
)
noexcept
{
{
assert
(
connection
.
GetEventLoop
().
IsInside
());
assert
(
connection
.
GetEventLoop
().
IsInside
());
...
@@ -157,27 +157,28 @@ NfsConnection::CancellableCallback::Callback(int err, void *data)
...
@@ -157,27 +157,28 @@ NfsConnection::CancellableCallback::Callback(int err, void *data)
void
void
NfsConnection
::
CancellableCallback
::
Callback
(
int
err
,
NfsConnection
::
CancellableCallback
::
Callback
(
int
err
,
gcc_unused
struct
nfs_context
*
nfs
,
gcc_unused
struct
nfs_context
*
nfs
,
void
*
data
,
void
*
private_data
)
void
*
data
,
void
*
private_data
)
noexcept
{
{
CancellableCallback
&
c
=
*
(
CancellableCallback
*
)
private_data
;
CancellableCallback
&
c
=
*
(
CancellableCallback
*
)
private_data
;
c
.
Callback
(
err
,
data
);
c
.
Callback
(
err
,
data
);
}
}
static
constexpr
unsigned
static
constexpr
unsigned
libnfs_to_events
(
int
i
)
libnfs_to_events
(
int
i
)
noexcept
{
{
return
((
i
&
POLLIN
)
?
SocketMonitor
::
READ
:
0
)
|
return
((
i
&
POLLIN
)
?
SocketMonitor
::
READ
:
0
)
|
((
i
&
POLLOUT
)
?
SocketMonitor
::
WRITE
:
0
);
((
i
&
POLLOUT
)
?
SocketMonitor
::
WRITE
:
0
);
}
}
static
constexpr
int
static
constexpr
int
events_to_libnfs
(
unsigned
i
)
events_to_libnfs
(
unsigned
i
)
noexcept
{
{
return
((
i
&
SocketMonitor
::
READ
)
?
POLLIN
:
0
)
|
return
((
i
&
SocketMonitor
::
READ
)
?
POLLIN
:
0
)
|
((
i
&
SocketMonitor
::
WRITE
)
?
POLLOUT
:
0
);
((
i
&
SocketMonitor
::
WRITE
)
?
POLLOUT
:
0
);
}
}
NfsConnection
::~
NfsConnection
()
NfsConnection
::~
NfsConnection
()
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
assert
(
new_leases
.
empty
());
assert
(
new_leases
.
empty
());
...
@@ -190,7 +191,7 @@ NfsConnection::~NfsConnection()
...
@@ -190,7 +191,7 @@ NfsConnection::~NfsConnection()
}
}
void
void
NfsConnection
::
AddLease
(
NfsLease
&
lease
)
NfsConnection
::
AddLease
(
NfsLease
&
lease
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -200,7 +201,7 @@ NfsConnection::AddLease(NfsLease &lease)
...
@@ -200,7 +201,7 @@ NfsConnection::AddLease(NfsLease &lease)
}
}
void
void
NfsConnection
::
RemoveLease
(
NfsLease
&
lease
)
NfsConnection
::
RemoveLease
(
NfsLease
&
lease
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -243,7 +244,7 @@ NfsConnection::OpenDirectory(const char *path, NfsCallback &callback)
...
@@ -243,7 +244,7 @@ NfsConnection::OpenDirectory(const char *path, NfsCallback &callback)
}
}
const
struct
nfsdirent
*
const
struct
nfsdirent
*
NfsConnection
::
ReadDirectory
(
struct
nfsdir
*
dir
)
NfsConnection
::
ReadDirectory
(
struct
nfsdir
*
dir
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -251,7 +252,7 @@ NfsConnection::ReadDirectory(struct nfsdir *dir)
...
@@ -251,7 +252,7 @@ NfsConnection::ReadDirectory(struct nfsdir *dir)
}
}
void
void
NfsConnection
::
CloseDirectory
(
struct
nfsdir
*
dir
)
NfsConnection
::
CloseDirectory
(
struct
nfsdir
*
dir
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -311,18 +312,18 @@ NfsConnection::Read(struct nfsfh *fh, uint64_t offset, size_t size,
...
@@ -311,18 +312,18 @@ NfsConnection::Read(struct nfsfh *fh, uint64_t offset, size_t size,
}
}
void
void
NfsConnection
::
Cancel
(
NfsCallback
&
callback
)
NfsConnection
::
Cancel
(
NfsCallback
&
callback
)
noexcept
{
{
callbacks
.
Cancel
(
callback
);
callbacks
.
Cancel
(
callback
);
}
}
static
void
static
void
DummyCallback
(
int
,
struct
nfs_context
*
,
void
*
,
void
*
)
DummyCallback
(
int
,
struct
nfs_context
*
,
void
*
,
void
*
)
noexcept
{
{
}
}
inline
void
inline
void
NfsConnection
::
InternalClose
(
struct
nfsfh
*
fh
)
NfsConnection
::
InternalClose
(
struct
nfsfh
*
fh
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
assert
(
context
!=
nullptr
);
assert
(
context
!=
nullptr
);
...
@@ -332,7 +333,7 @@ NfsConnection::InternalClose(struct nfsfh *fh)
...
@@ -332,7 +333,7 @@ NfsConnection::InternalClose(struct nfsfh *fh)
}
}
void
void
NfsConnection
::
Close
(
struct
nfsfh
*
fh
)
NfsConnection
::
Close
(
struct
nfsfh
*
fh
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -341,14 +342,14 @@ NfsConnection::Close(struct nfsfh *fh)
...
@@ -341,14 +342,14 @@ NfsConnection::Close(struct nfsfh *fh)
}
}
void
void
NfsConnection
::
CancelAndClose
(
struct
nfsfh
*
fh
,
NfsCallback
&
callback
)
NfsConnection
::
CancelAndClose
(
struct
nfsfh
*
fh
,
NfsCallback
&
callback
)
noexcept
{
{
CancellableCallback
&
cancel
=
callbacks
.
Get
(
callback
);
CancellableCallback
&
cancel
=
callbacks
.
Get
(
callback
);
cancel
.
CancelAndScheduleClose
(
fh
);
cancel
.
CancelAndScheduleClose
(
fh
);
}
}
void
void
NfsConnection
::
DestroyContext
()
NfsConnection
::
DestroyContext
()
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
assert
(
context
!=
nullptr
);
assert
(
context
!=
nullptr
);
...
@@ -379,7 +380,7 @@ NfsConnection::DestroyContext()
...
@@ -379,7 +380,7 @@ NfsConnection::DestroyContext()
}
}
inline
void
inline
void
NfsConnection
::
DeferClose
(
struct
nfsfh
*
fh
)
NfsConnection
::
DeferClose
(
struct
nfsfh
*
fh
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
assert
(
in_event
);
assert
(
in_event
);
...
@@ -391,7 +392,7 @@ NfsConnection::DeferClose(struct nfsfh *fh)
...
@@ -391,7 +392,7 @@ NfsConnection::DeferClose(struct nfsfh *fh)
}
}
void
void
NfsConnection
::
ScheduleSocket
()
NfsConnection
::
ScheduleSocket
()
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
assert
(
context
!=
nullptr
);
assert
(
context
!=
nullptr
);
...
@@ -421,7 +422,7 @@ NfsConnection::ScheduleSocket()
...
@@ -421,7 +422,7 @@ NfsConnection::ScheduleSocket()
}
}
inline
int
inline
int
NfsConnection
::
Service
(
unsigned
flags
)
NfsConnection
::
Service
(
unsigned
flags
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
assert
(
context
!=
nullptr
);
assert
(
context
!=
nullptr
);
...
@@ -518,7 +519,7 @@ NfsConnection::OnSocketReady(unsigned flags) noexcept
...
@@ -518,7 +519,7 @@ NfsConnection::OnSocketReady(unsigned flags) noexcept
inline
void
inline
void
NfsConnection
::
MountCallback
(
int
status
,
gcc_unused
nfs_context
*
nfs
,
NfsConnection
::
MountCallback
(
int
status
,
gcc_unused
nfs_context
*
nfs
,
gcc_unused
void
*
data
)
gcc_unused
void
*
data
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
assert
(
context
==
nfs
);
assert
(
context
==
nfs
);
...
@@ -538,7 +539,7 @@ NfsConnection::MountCallback(int status, gcc_unused nfs_context *nfs,
...
@@ -538,7 +539,7 @@ NfsConnection::MountCallback(int status, gcc_unused nfs_context *nfs,
void
void
NfsConnection
::
MountCallback
(
int
status
,
nfs_context
*
nfs
,
void
*
data
,
NfsConnection
::
MountCallback
(
int
status
,
nfs_context
*
nfs
,
void
*
data
,
void
*
private_data
)
void
*
private_data
)
noexcept
{
{
NfsConnection
*
c
=
(
NfsConnection
*
)
private_data
;
NfsConnection
*
c
=
(
NfsConnection
*
)
private_data
;
...
@@ -579,7 +580,7 @@ NfsConnection::MountInternal()
...
@@ -579,7 +580,7 @@ NfsConnection::MountInternal()
}
}
void
void
NfsConnection
::
BroadcastMountSuccess
()
NfsConnection
::
BroadcastMountSuccess
()
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -591,7 +592,7 @@ NfsConnection::BroadcastMountSuccess()
...
@@ -591,7 +592,7 @@ NfsConnection::BroadcastMountSuccess()
}
}
void
void
NfsConnection
::
BroadcastMountError
(
std
::
exception_ptr
&&
e
)
NfsConnection
::
BroadcastMountError
(
std
::
exception_ptr
&&
e
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -605,7 +606,7 @@ NfsConnection::BroadcastMountError(std::exception_ptr &&e)
...
@@ -605,7 +606,7 @@ NfsConnection::BroadcastMountError(std::exception_ptr &&e)
}
}
void
void
NfsConnection
::
BroadcastError
(
std
::
exception_ptr
&&
e
)
NfsConnection
::
BroadcastError
(
std
::
exception_ptr
&&
e
)
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -619,7 +620,7 @@ NfsConnection::BroadcastError(std::exception_ptr &&e)
...
@@ -619,7 +620,7 @@ NfsConnection::BroadcastError(std::exception_ptr &&e)
}
}
void
void
NfsConnection
::
OnMountTimeout
()
NfsConnection
::
OnMountTimeout
()
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
assert
(
!
mount_finished
);
assert
(
!
mount_finished
);
...
...
src/lib/nfs/Connection.hxx
View file @
a92e0e85
...
@@ -60,7 +60,7 @@ class NfsConnection : SocketMonitor {
...
@@ -60,7 +60,7 @@ class NfsConnection : SocketMonitor {
public
:
public
:
explicit
CancellableCallback
(
NfsCallback
&
_callback
,
explicit
CancellableCallback
(
NfsCallback
&
_callback
,
NfsConnection
&
_connection
,
NfsConnection
&
_connection
,
bool
_open
)
bool
_open
)
noexcept
:
CancellablePointer
<
NfsCallback
>
(
_callback
),
:
CancellablePointer
<
NfsCallback
>
(
_callback
),
connection
(
_connection
),
connection
(
_connection
),
open
(
_open
),
close_fh
(
nullptr
)
{}
open
(
_open
),
close_fh
(
nullptr
)
{}
...
@@ -76,19 +76,19 @@ class NfsConnection : SocketMonitor {
...
@@ -76,19 +76,19 @@ class NfsConnection : SocketMonitor {
* Cancel the operation and schedule a call to
* Cancel the operation and schedule a call to
* nfs_close_async() with the given file handle.
* nfs_close_async() with the given file handle.
*/
*/
void
CancelAndScheduleClose
(
struct
nfsfh
*
fh
);
void
CancelAndScheduleClose
(
struct
nfsfh
*
fh
)
noexcept
;
/**
/**
* Called by NfsConnection::DestroyContext() right
* Called by NfsConnection::DestroyContext() right
* before nfs_destroy_context(). This object is given
* before nfs_destroy_context(). This object is given
* a chance to prepare for the latter.
* a chance to prepare for the latter.
*/
*/
void
PrepareDestroyContext
();
void
PrepareDestroyContext
()
noexcept
;
private
:
private
:
static
void
Callback
(
int
err
,
struct
nfs_context
*
nfs
,
static
void
Callback
(
int
err
,
struct
nfs_context
*
nfs
,
void
*
data
,
void
*
private_data
);
void
*
data
,
void
*
private_data
)
noexcept
;
void
Callback
(
int
err
,
void
*
data
);
void
Callback
(
int
err
,
void
*
data
)
noexcept
;
};
};
DeferEvent
defer_new_lease
;
DeferEvent
defer_new_lease
;
...
@@ -148,7 +148,7 @@ public:
...
@@ -148,7 +148,7 @@ public:
/**
/**
* Must be run from EventLoop's thread.
* Must be run from EventLoop's thread.
*/
*/
~
NfsConnection
();
~
NfsConnection
()
noexcept
;
gcc_pure
gcc_pure
const
char
*
GetServer
()
const
noexcept
{
const
char
*
GetServer
()
const
noexcept
{
...
@@ -171,14 +171,14 @@ public:
...
@@ -171,14 +171,14 @@ public:
* This method is thread-safe. However, #NfsLease's methods
* This method is thread-safe. However, #NfsLease's methods
* will be invoked from within the #EventLoop's thread.
* will be invoked from within the #EventLoop's thread.
*/
*/
void
AddLease
(
NfsLease
&
lease
);
void
AddLease
(
NfsLease
&
lease
)
noexcept
;
void
RemoveLease
(
NfsLease
&
lease
);
void
RemoveLease
(
NfsLease
&
lease
)
noexcept
;
void
Stat
(
const
char
*
path
,
NfsCallback
&
callback
);
void
Stat
(
const
char
*
path
,
NfsCallback
&
callback
);
void
OpenDirectory
(
const
char
*
path
,
NfsCallback
&
callback
);
void
OpenDirectory
(
const
char
*
path
,
NfsCallback
&
callback
);
const
struct
nfsdirent
*
ReadDirectory
(
struct
nfsdir
*
dir
);
const
struct
nfsdirent
*
ReadDirectory
(
struct
nfsdir
*
dir
)
noexcept
;
void
CloseDirectory
(
struct
nfsdir
*
dir
);
void
CloseDirectory
(
struct
nfsdir
*
dir
)
noexcept
;
/**
/**
* Throws std::runtime_error on error.
* Throws std::runtime_error on error.
...
@@ -193,48 +193,48 @@ public:
...
@@ -193,48 +193,48 @@ public:
void
Read
(
struct
nfsfh
*
fh
,
uint64_t
offset
,
size_t
size
,
void
Read
(
struct
nfsfh
*
fh
,
uint64_t
offset
,
size_t
size
,
NfsCallback
&
callback
);
NfsCallback
&
callback
);
void
Cancel
(
NfsCallback
&
callback
);
void
Cancel
(
NfsCallback
&
callback
)
noexcept
;
void
Close
(
struct
nfsfh
*
fh
);
void
Close
(
struct
nfsfh
*
fh
)
noexcept
;
void
CancelAndClose
(
struct
nfsfh
*
fh
,
NfsCallback
&
callback
);
void
CancelAndClose
(
struct
nfsfh
*
fh
,
NfsCallback
&
callback
)
noexcept
;
protected
:
protected
:
virtual
void
OnNfsConnectionError
(
std
::
exception_ptr
&&
e
)
=
0
;
virtual
void
OnNfsConnectionError
(
std
::
exception_ptr
&&
e
)
noexcept
=
0
;
private
:
private
:
void
DestroyContext
();
void
DestroyContext
()
noexcept
;
/**
/**
* Wrapper for nfs_close_async().
* Wrapper for nfs_close_async().
*/
*/
void
InternalClose
(
struct
nfsfh
*
fh
);
void
InternalClose
(
struct
nfsfh
*
fh
)
noexcept
;
/**
/**
* Invoke nfs_close_async() after nfs_service() returns.
* Invoke nfs_close_async() after nfs_service() returns.
*/
*/
void
DeferClose
(
struct
nfsfh
*
fh
);
void
DeferClose
(
struct
nfsfh
*
fh
)
noexcept
;
void
MountInternal
();
void
MountInternal
();
void
BroadcastMountSuccess
();
void
BroadcastMountSuccess
()
noexcept
;
void
BroadcastMountError
(
std
::
exception_ptr
&&
e
);
void
BroadcastMountError
(
std
::
exception_ptr
&&
e
)
noexcept
;
void
BroadcastError
(
std
::
exception_ptr
&&
e
);
void
BroadcastError
(
std
::
exception_ptr
&&
e
)
noexcept
;
static
void
MountCallback
(
int
status
,
nfs_context
*
nfs
,
void
*
data
,
static
void
MountCallback
(
int
status
,
nfs_context
*
nfs
,
void
*
data
,
void
*
private_data
);
void
*
private_data
)
noexcept
;
void
MountCallback
(
int
status
,
nfs_context
*
nfs
,
void
*
data
);
void
MountCallback
(
int
status
,
nfs_context
*
nfs
,
void
*
data
)
noexcept
;
void
ScheduleSocket
();
void
ScheduleSocket
()
noexcept
;
/**
/**
* Wrapper for nfs_service().
* Wrapper for nfs_service().
*/
*/
int
Service
(
unsigned
flags
);
int
Service
(
unsigned
flags
)
noexcept
;
/* virtual methods from SocketMonitor */
/* virtual methods from SocketMonitor */
bool
OnSocketReady
(
unsigned
flags
)
noexcept
override
;
bool
OnSocketReady
(
unsigned
flags
)
noexcept
override
;
/* callback for #mount_timeout_event */
/* callback for #mount_timeout_event */
void
OnMountTimeout
();
void
OnMountTimeout
()
noexcept
;
/* DeferEvent callback */
/* DeferEvent callback */
void
RunDeferred
()
noexcept
;
void
RunDeferred
()
noexcept
;
...
...
src/lib/nfs/FileReader.cxx
View file @
a92e0e85
...
@@ -32,18 +32,18 @@
...
@@ -32,18 +32,18 @@
#include <fcntl.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/stat.h>
NfsFileReader
::
NfsFileReader
()
NfsFileReader
::
NfsFileReader
()
noexcept
:
defer_open
(
nfs_get_event_loop
(),
BIND_THIS_METHOD
(
OnDeferredOpen
))
:
defer_open
(
nfs_get_event_loop
(),
BIND_THIS_METHOD
(
OnDeferredOpen
))
{
{
}
}
NfsFileReader
::~
NfsFileReader
()
NfsFileReader
::~
NfsFileReader
()
noexcept
{
{
assert
(
state
==
State
::
INITIAL
);
assert
(
state
==
State
::
INITIAL
);
}
}
void
void
NfsFileReader
::
Close
()
NfsFileReader
::
Close
()
noexcept
{
{
if
(
state
==
State
::
INITIAL
)
if
(
state
==
State
::
INITIAL
)
return
;
return
;
...
@@ -61,7 +61,7 @@ NfsFileReader::Close()
...
@@ -61,7 +61,7 @@ NfsFileReader::Close()
}
}
void
void
NfsFileReader
::
CancelOrClose
()
NfsFileReader
::
CancelOrClose
()
noexcept
{
{
assert
(
state
!=
State
::
INITIAL
&&
assert
(
state
!=
State
::
INITIAL
&&
state
!=
State
::
DEFER
);
state
!=
State
::
DEFER
);
...
@@ -83,7 +83,7 @@ NfsFileReader::CancelOrClose()
...
@@ -83,7 +83,7 @@ NfsFileReader::CancelOrClose()
}
}
void
void
NfsFileReader
::
DeferClose
()
NfsFileReader
::
DeferClose
()
noexcept
{
{
BlockingCall
(
GetEventLoop
(),
[
this
](){
Close
();
});
BlockingCall
(
GetEventLoop
(),
[
this
](){
Close
();
});
}
}
...
@@ -135,7 +135,7 @@ NfsFileReader::Read(uint64_t offset, size_t size)
...
@@ -135,7 +135,7 @@ NfsFileReader::Read(uint64_t offset, size_t size)
}
}
void
void
NfsFileReader
::
CancelRead
()
NfsFileReader
::
CancelRead
()
noexcept
{
{
if
(
state
==
State
::
READ
)
{
if
(
state
==
State
::
READ
)
{
connection
->
Cancel
(
*
this
);
connection
->
Cancel
(
*
this
);
...
@@ -144,7 +144,7 @@ NfsFileReader::CancelRead()
...
@@ -144,7 +144,7 @@ NfsFileReader::CancelRead()
}
}
void
void
NfsFileReader
::
OnNfsConnectionReady
()
NfsFileReader
::
OnNfsConnectionReady
()
noexcept
{
{
assert
(
state
==
State
::
MOUNT
);
assert
(
state
==
State
::
MOUNT
);
...
@@ -159,7 +159,7 @@ NfsFileReader::OnNfsConnectionReady()
...
@@ -159,7 +159,7 @@ NfsFileReader::OnNfsConnectionReady()
}
}
void
void
NfsFileReader
::
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
NfsFileReader
::
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
noexcept
{
{
assert
(
state
==
State
::
MOUNT
);
assert
(
state
==
State
::
MOUNT
);
...
@@ -169,7 +169,7 @@ NfsFileReader::OnNfsConnectionFailed(std::exception_ptr e)
...
@@ -169,7 +169,7 @@ NfsFileReader::OnNfsConnectionFailed(std::exception_ptr e)
}
}
void
void
NfsFileReader
::
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
NfsFileReader
::
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
noexcept
{
{
assert
(
state
>
State
::
MOUNT
);
assert
(
state
>
State
::
MOUNT
);
...
@@ -179,7 +179,7 @@ NfsFileReader::OnNfsConnectionDisconnected(std::exception_ptr e)
...
@@ -179,7 +179,7 @@ NfsFileReader::OnNfsConnectionDisconnected(std::exception_ptr e)
}
}
inline
void
inline
void
NfsFileReader
::
OpenCallback
(
nfsfh
*
_fh
)
NfsFileReader
::
OpenCallback
(
nfsfh
*
_fh
)
noexcept
{
{
assert
(
state
==
State
::
OPEN
);
assert
(
state
==
State
::
OPEN
);
assert
(
connection
!=
nullptr
);
assert
(
connection
!=
nullptr
);
...
@@ -198,7 +198,7 @@ NfsFileReader::OpenCallback(nfsfh *_fh)
...
@@ -198,7 +198,7 @@ NfsFileReader::OpenCallback(nfsfh *_fh)
}
}
inline
void
inline
void
NfsFileReader
::
StatCallback
(
const
struct
stat
*
st
)
NfsFileReader
::
StatCallback
(
const
struct
stat
*
st
)
noexcept
{
{
assert
(
state
==
State
::
STAT
);
assert
(
state
==
State
::
STAT
);
assert
(
connection
!=
nullptr
);
assert
(
connection
!=
nullptr
);
...
@@ -216,7 +216,7 @@ NfsFileReader::StatCallback(const struct stat *st)
...
@@ -216,7 +216,7 @@ NfsFileReader::StatCallback(const struct stat *st)
}
}
void
void
NfsFileReader
::
OnNfsCallback
(
unsigned
status
,
void
*
data
)
NfsFileReader
::
OnNfsCallback
(
unsigned
status
,
void
*
data
)
noexcept
{
{
switch
(
state
)
{
switch
(
state
)
{
case
State
:
:
INITIAL
:
case
State
:
:
INITIAL
:
...
@@ -242,7 +242,7 @@ NfsFileReader::OnNfsCallback(unsigned status, void *data)
...
@@ -242,7 +242,7 @@ NfsFileReader::OnNfsCallback(unsigned status, void *data)
}
}
void
void
NfsFileReader
::
OnNfsError
(
std
::
exception_ptr
&&
e
)
NfsFileReader
::
OnNfsError
(
std
::
exception_ptr
&&
e
)
noexcept
{
{
switch
(
state
)
{
switch
(
state
)
{
case
State
:
:
INITIAL
:
case
State
:
:
INITIAL
:
...
...
src/lib/nfs/FileReader.hxx
View file @
a92e0e85
...
@@ -66,15 +66,15 @@ class NfsFileReader : NfsLease, NfsCallback {
...
@@ -66,15 +66,15 @@ class NfsFileReader : NfsLease, NfsCallback {
DeferEvent
defer_open
;
DeferEvent
defer_open
;
public
:
public
:
NfsFileReader
();
NfsFileReader
()
noexcept
;
~
NfsFileReader
();
~
NfsFileReader
()
noexcept
;
EventLoop
&
GetEventLoop
()
noexcept
{
EventLoop
&
GetEventLoop
()
noexcept
{
return
defer_open
.
GetEventLoop
();
return
defer_open
.
GetEventLoop
();
}
}
void
Close
();
void
Close
()
noexcept
;
void
DeferClose
();
void
DeferClose
()
noexcept
;
/**
/**
* Open the file. This method is thread-safe.
* Open the file. This method is thread-safe.
...
@@ -101,9 +101,9 @@ public:
...
@@ -101,9 +101,9 @@ public:
* This method is not thread-safe and must be called from
* This method is not thread-safe and must be called from
* within the I/O thread.
* within the I/O thread.
*/
*/
void
CancelRead
();
void
CancelRead
()
noexcept
;
bool
IsIdle
()
const
{
bool
IsIdle
()
const
noexcept
{
return
state
==
State
::
IDLE
;
return
state
==
State
::
IDLE
;
}
}
...
@@ -115,40 +115,40 @@ protected:
...
@@ -115,40 +115,40 @@ protected:
*
*
* This method will be called from within the I/O thread.
* This method will be called from within the I/O thread.
*/
*/
virtual
void
OnNfsFileOpen
(
uint64_t
size
)
=
0
;
virtual
void
OnNfsFileOpen
(
uint64_t
size
)
noexcept
=
0
;
/**
/**
* A Read() has completed successfully.
* A Read() has completed successfully.
*
*
* This method will be called from within the I/O thread.
* This method will be called from within the I/O thread.
*/
*/
virtual
void
OnNfsFileRead
(
const
void
*
data
,
size_t
size
)
=
0
;
virtual
void
OnNfsFileRead
(
const
void
*
data
,
size_t
size
)
noexcept
=
0
;
/**
/**
* An error has occurred, which can be either while waiting
* An error has occurred, which can be either while waiting
* for OnNfsFileOpen(), or while waiting for OnNfsFileRead(),
* for OnNfsFileOpen(), or while waiting for OnNfsFileRead(),
* or if disconnected while idle.
* or if disconnected while idle.
*/
*/
virtual
void
OnNfsFileError
(
std
::
exception_ptr
&&
e
)
=
0
;
virtual
void
OnNfsFileError
(
std
::
exception_ptr
&&
e
)
noexcept
=
0
;
private
:
private
:
/**
/**
* Cancel the current operation, if any. The NfsLease must be
* Cancel the current operation, if any. The NfsLease must be
* unregistered already.
* unregistered already.
*/
*/
void
CancelOrClose
();
void
CancelOrClose
()
noexcept
;
void
OpenCallback
(
nfsfh
*
_fh
);
void
OpenCallback
(
nfsfh
*
_fh
)
noexcept
;
void
StatCallback
(
const
struct
stat
*
st
);
void
StatCallback
(
const
struct
stat
*
st
)
noexcept
;
/* virtual methods from NfsLease */
/* virtual methods from NfsLease */
void
OnNfsConnectionReady
()
final
;
void
OnNfsConnectionReady
()
noexcept
final
;
void
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
final
;
void
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
noexcept
final
;
void
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
final
;
void
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
noexcept
final
;
/* virtual methods from NfsCallback */
/* virtual methods from NfsCallback */
void
OnNfsCallback
(
unsigned
status
,
void
*
data
)
final
;
void
OnNfsCallback
(
unsigned
status
,
void
*
data
)
noexcept
final
;
void
OnNfsError
(
std
::
exception_ptr
&&
e
)
final
;
void
OnNfsError
(
std
::
exception_ptr
&&
e
)
noexcept
final
;
/* DeferEvent callback */
/* DeferEvent callback */
void
OnDeferredOpen
()
noexcept
;
void
OnDeferredOpen
()
noexcept
;
...
...
src/lib/nfs/Lease.hxx
View file @
a92e0e85
...
@@ -30,19 +30,19 @@ public:
...
@@ -30,19 +30,19 @@ public:
* The #NfsConnection has successfully mounted the server's
* The #NfsConnection has successfully mounted the server's
* export and is ready for regular operation.
* export and is ready for regular operation.
*/
*/
virtual
void
OnNfsConnectionReady
()
=
0
;
virtual
void
OnNfsConnectionReady
()
noexcept
=
0
;
/**
/**
* The #NfsConnection has failed to mount the server's export.
* The #NfsConnection has failed to mount the server's export.
* This is being called instead of OnNfsConnectionReady().
* This is being called instead of OnNfsConnectionReady().
*/
*/
virtual
void
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
=
0
;
virtual
void
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
noexcept
=
0
;
/**
/**
* The #NfsConnection has failed after OnNfsConnectionReady()
* The #NfsConnection has failed after OnNfsConnectionReady()
* had been called already.
* had been called already.
*/
*/
virtual
void
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
=
0
;
virtual
void
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
noexcept
=
0
;
};
};
#endif
#endif
src/lib/nfs/Manager.cxx
View file @
a92e0e85
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include <string.h>
#include <string.h>
void
void
NfsManager
::
ManagedConnection
::
OnNfsConnectionError
(
std
::
exception_ptr
&&
e
)
NfsManager
::
ManagedConnection
::
OnNfsConnectionError
(
std
::
exception_ptr
&&
e
)
noexcept
{
{
FormatError
(
e
,
"NFS error on %s:%s"
,
GetServer
(),
GetExportName
());
FormatError
(
e
,
"NFS error on %s:%s"
,
GetServer
(),
GetExportName
());
...
@@ -72,7 +72,7 @@ NfsManager::Compare::operator()(const ManagedConnection &a,
...
@@ -72,7 +72,7 @@ NfsManager::Compare::operator()(const ManagedConnection &a,
return
result
<
0
;
return
result
<
0
;
}
}
NfsManager
::~
NfsManager
()
NfsManager
::~
NfsManager
()
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -102,7 +102,7 @@ NfsManager::GetConnection(const char *server, const char *export_name) noexcept
...
@@ -102,7 +102,7 @@ NfsManager::GetConnection(const char *server, const char *export_name) noexcept
}
}
void
void
NfsManager
::
CollectGarbage
()
NfsManager
::
CollectGarbage
()
noexcept
{
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
...
src/lib/nfs/Manager.hxx
View file @
a92e0e85
...
@@ -47,13 +47,13 @@ class NfsManager final : IdleMonitor {
...
@@ -47,13 +47,13 @@ class NfsManager final : IdleMonitor {
public
:
public
:
ManagedConnection
(
NfsManager
&
_manager
,
EventLoop
&
_loop
,
ManagedConnection
(
NfsManager
&
_manager
,
EventLoop
&
_loop
,
const
char
*
_server
,
const
char
*
_server
,
const
char
*
_export_name
)
const
char
*
_export_name
)
noexcept
:
NfsConnection
(
_loop
,
_server
,
_export_name
),
:
NfsConnection
(
_loop
,
_server
,
_export_name
),
manager
(
_manager
)
{}
manager
(
_manager
)
{}
protected
:
protected
:
/* virtual methods from NfsConnection */
/* virtual methods from NfsConnection */
void
OnNfsConnectionError
(
std
::
exception_ptr
&&
e
)
override
;
void
OnNfsConnectionError
(
std
::
exception_ptr
&&
e
)
noexcept
override
;
};
};
struct
Compare
{
struct
Compare
{
...
@@ -89,13 +89,13 @@ class NfsManager final : IdleMonitor {
...
@@ -89,13 +89,13 @@ class NfsManager final : IdleMonitor {
List
garbage
;
List
garbage
;
public
:
public
:
NfsManager
(
EventLoop
&
_loop
)
explicit
NfsManager
(
EventLoop
&
_loop
)
noexcept
:
IdleMonitor
(
_loop
)
{}
:
IdleMonitor
(
_loop
)
{}
/**
/**
* Must be run from EventLoop's thread.
* Must be run from EventLoop's thread.
*/
*/
~
NfsManager
();
~
NfsManager
()
noexcept
;
using
IdleMonitor
::
GetEventLoop
;
using
IdleMonitor
::
GetEventLoop
;
...
@@ -104,7 +104,7 @@ public:
...
@@ -104,7 +104,7 @@ public:
const
char
*
export_name
)
noexcept
;
const
char
*
export_name
)
noexcept
;
private
:
private
:
void
ScheduleDelete
(
ManagedConnection
&
c
)
{
void
ScheduleDelete
(
ManagedConnection
&
c
)
noexcept
{
connections
.
erase
(
connections
.
iterator_to
(
c
));
connections
.
erase
(
connections
.
iterator_to
(
c
));
garbage
.
push_front
(
c
);
garbage
.
push_front
(
c
);
IdleMonitor
::
Schedule
();
IdleMonitor
::
Schedule
();
...
@@ -113,7 +113,7 @@ private:
...
@@ -113,7 +113,7 @@ private:
/**
/**
* Delete all connections on the #garbage list.
* Delete all connections on the #garbage list.
*/
*/
void
CollectGarbage
();
void
CollectGarbage
()
noexcept
;
/* virtual methods from IdleMonitor */
/* virtual methods from IdleMonitor */
void
OnIdle
()
noexcept
override
;
void
OnIdle
()
noexcept
override
;
...
...
src/storage/plugins/NfsStorage.cxx
View file @
a92e0e85
...
@@ -95,20 +95,20 @@ public:
...
@@ -95,20 +95,20 @@ public:
const
char
*
MapToRelativeUTF8
(
const
char
*
uri_utf8
)
const
noexcept
override
;
const
char
*
MapToRelativeUTF8
(
const
char
*
uri_utf8
)
const
noexcept
override
;
/* virtual methods from NfsLease */
/* virtual methods from NfsLease */
void
OnNfsConnectionReady
()
final
{
void
OnNfsConnectionReady
()
noexcept
final
{
assert
(
state
==
State
::
CONNECTING
);
assert
(
state
==
State
::
CONNECTING
);
SetState
(
State
::
READY
);
SetState
(
State
::
READY
);
}
}
void
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
final
{
void
OnNfsConnectionFailed
(
std
::
exception_ptr
e
)
noexcept
final
{
assert
(
state
==
State
::
CONNECTING
);
assert
(
state
==
State
::
CONNECTING
);
SetState
(
State
::
DELAY
,
std
::
move
(
e
));
SetState
(
State
::
DELAY
,
std
::
move
(
e
));
reconnect_timer
.
Schedule
(
std
::
chrono
::
minutes
(
1
));
reconnect_timer
.
Schedule
(
std
::
chrono
::
minutes
(
1
));
}
}
void
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
final
{
void
OnNfsConnectionDisconnected
(
std
::
exception_ptr
e
)
noexcept
final
{
assert
(
state
==
State
::
READY
);
assert
(
state
==
State
::
READY
);
SetState
(
State
::
DELAY
,
std
::
move
(
e
));
SetState
(
State
::
DELAY
,
std
::
move
(
e
));
...
@@ -129,11 +129,11 @@ public:
...
@@ -129,11 +129,11 @@ public:
}
}
private
:
private
:
EventLoop
&
GetEventLoop
()
{
EventLoop
&
GetEventLoop
()
noexcept
{
return
defer_connect
.
GetEventLoop
();
return
defer_connect
.
GetEventLoop
();
}
}
void
SetState
(
State
_state
)
{
void
SetState
(
State
_state
)
noexcept
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
...
@@ -141,7 +141,7 @@ private:
...
@@ -141,7 +141,7 @@ private:
cond
.
broadcast
();
cond
.
broadcast
();
}
}
void
SetState
(
State
_state
,
std
::
exception_ptr
&&
e
)
{
void
SetState
(
State
_state
,
std
::
exception_ptr
&&
e
)
noexcept
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
...
@@ -150,7 +150,7 @@ private:
...
@@ -150,7 +150,7 @@ private:
cond
.
broadcast
();
cond
.
broadcast
();
}
}
void
Connect
()
{
void
Connect
()
noexcept
{
assert
(
state
!=
State
::
READY
);
assert
(
state
!=
State
::
READY
);
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
...
@@ -161,7 +161,7 @@ private:
...
@@ -161,7 +161,7 @@ private:
SetState
(
State
::
CONNECTING
);
SetState
(
State
::
CONNECTING
);
}
}
void
EnsureConnected
()
{
void
EnsureConnected
()
noexcept
{
if
(
state
!=
State
::
READY
)
if
(
state
!=
State
::
READY
)
Connect
();
Connect
();
}
}
...
@@ -191,7 +191,7 @@ private:
...
@@ -191,7 +191,7 @@ private:
}
}
}
}
void
Disconnect
()
{
void
Disconnect
()
noexcept
{
assert
(
GetEventLoop
().
IsInside
());
assert
(
GetEventLoop
().
IsInside
());
switch
(
state
)
{
switch
(
state
)
{
...
@@ -243,7 +243,7 @@ NfsStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
...
@@ -243,7 +243,7 @@ NfsStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
}
}
static
void
static
void
Copy
(
StorageFileInfo
&
info
,
const
struct
stat
&
st
)
Copy
(
StorageFileInfo
&
info
,
const
struct
stat
&
st
)
noexcept
{
{
if
(
S_ISREG
(
st
.
st_mode
))
if
(
S_ISREG
(
st
.
st_mode
))
info
.
type
=
StorageFileInfo
::
Type
::
REGULAR
;
info
.
type
=
StorageFileInfo
::
Type
::
REGULAR
;
...
@@ -275,7 +275,7 @@ protected:
...
@@ -275,7 +275,7 @@ protected:
connection
.
Stat
(
path
,
*
this
);
connection
.
Stat
(
path
,
*
this
);
}
}
void
HandleResult
(
gcc_unused
unsigned
status
,
void
*
data
)
override
{
void
HandleResult
(
gcc_unused
unsigned
status
,
void
*
data
)
noexcept
override
{
Copy
(
info
,
*
(
const
struct
stat
*
)
data
);
Copy
(
info
,
*
(
const
struct
stat
*
)
data
);
}
}
};
};
...
@@ -343,7 +343,8 @@ protected:
...
@@ -343,7 +343,8 @@ protected:
connection
.
OpenDirectory
(
path
,
*
this
);
connection
.
OpenDirectory
(
path
,
*
this
);
}
}
void
HandleResult
(
gcc_unused
unsigned
status
,
void
*
data
)
override
{
void
HandleResult
(
gcc_unused
unsigned
status
,
void
*
data
)
noexcept
override
{
struct
nfsdir
*
const
dir
=
(
struct
nfsdir
*
)
data
;
struct
nfsdir
*
const
dir
=
(
struct
nfsdir
*
)
data
;
CollectEntries
(
dir
);
CollectEntries
(
dir
);
...
...
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