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