From a92e0e85401adf7fd26ecc876c94239dc2dd1240 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Nov 2017 18:09:07 +0100 Subject: [PATCH] lib/nfs: add "noexcept" --- src/input/plugins/NfsInputPlugin.cxx | 14 ++++---- src/lib/nfs/Base.cxx | 2 +- src/lib/nfs/Base.hxx | 2 +- src/lib/nfs/Blocking.cxx | 10 +++--- src/lib/nfs/Blocking.hxx | 18 +++++----- src/lib/nfs/Callback.hxx | 4 +-- src/lib/nfs/Connection.cxx | 53 ++++++++++++++-------------- src/lib/nfs/Connection.hxx | 50 +++++++++++++------------- src/lib/nfs/FileReader.cxx | 26 +++++++------- src/lib/nfs/FileReader.hxx | 34 +++++++++--------- src/lib/nfs/Lease.hxx | 6 ++-- src/lib/nfs/Manager.cxx | 6 ++-- src/lib/nfs/Manager.hxx | 12 +++---- src/storage/plugins/NfsStorage.cxx | 25 ++++++------- 14 files changed, 132 insertions(+), 130 deletions(-) diff --git a/src/input/plugins/NfsInputPlugin.cxx b/src/input/plugins/NfsInputPlugin.cxx index c91a88f83..fd49b3aa5 100644 --- a/src/input/plugins/NfsInputPlugin.cxx +++ b/src/input/plugins/NfsInputPlugin.cxx @@ -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 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 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 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(); } diff --git a/src/lib/nfs/Base.cxx b/src/lib/nfs/Base.cxx index 5e67cb5f4..d07a242f5 100644 --- a/src/lib/nfs/Base.cxx +++ b/src/lib/nfs/Base.cxx @@ -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); diff --git a/src/lib/nfs/Base.hxx b/src/lib/nfs/Base.hxx index 78d25da72..e3dd65238 100644 --- a/src/lib/nfs/Base.hxx +++ b/src/lib/nfs/Base.hxx @@ -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" diff --git a/src/lib/nfs/Blocking.cxx b/src/lib/nfs/Blocking.cxx index 73eed45bf..6a98518f9 100644 --- a/src/lib/nfs/Blocking.cxx +++ b/src/lib/nfs/Blocking.cxx @@ -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); diff --git a/src/lib/nfs/Blocking.hxx b/src/lib/nfs/Blocking.hxx index 7afd45d6b..511929930 100644 --- a/src/lib/nfs/Blocking.hxx +++ b/src/lib/nfs/Blocking.hxx @@ -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 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 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 diff --git a/src/lib/nfs/Callback.hxx b/src/lib/nfs/Callback.hxx index 18bba6343..6a9478272 100644 --- a/src/lib/nfs/Callback.hxx +++ b/src/lib/nfs/Callback.hxx @@ -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 diff --git a/src/lib/nfs/Connection.cxx b/src/lib/nfs/Connection.cxx index ca7ff5470..15b73224a 100644 --- a/src/lib/nfs/Connection.cxx +++ b/src/lib/nfs/Connection.cxx @@ -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); diff --git a/src/lib/nfs/Connection.hxx b/src/lib/nfs/Connection.hxx index 5a9864564..8dee93e10 100644 --- a/src/lib/nfs/Connection.hxx +++ b/src/lib/nfs/Connection.hxx @@ -60,7 +60,7 @@ class NfsConnection : SocketMonitor { public: explicit CancellableCallback(NfsCallback &_callback, NfsConnection &_connection, - bool _open) + bool _open) noexcept :CancellablePointer(_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; diff --git a/src/lib/nfs/FileReader.cxx b/src/lib/nfs/FileReader.cxx index 39fc77e58..984f5518d 100644 --- a/src/lib/nfs/FileReader.cxx +++ b/src/lib/nfs/FileReader.cxx @@ -32,18 +32,18 @@ #include #include -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: diff --git a/src/lib/nfs/FileReader.hxx b/src/lib/nfs/FileReader.hxx index d3546e9f9..18d0cf1c3 100644 --- a/src/lib/nfs/FileReader.hxx +++ b/src/lib/nfs/FileReader.hxx @@ -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; diff --git a/src/lib/nfs/Lease.hxx b/src/lib/nfs/Lease.hxx index 469f36798..fca93aba5 100644 --- a/src/lib/nfs/Lease.hxx +++ b/src/lib/nfs/Lease.hxx @@ -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 diff --git a/src/lib/nfs/Manager.cxx b/src/lib/nfs/Manager.cxx index ae8fd79b1..672077ea4 100644 --- a/src/lib/nfs/Manager.cxx +++ b/src/lib/nfs/Manager.cxx @@ -26,7 +26,7 @@ #include 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()); diff --git a/src/lib/nfs/Manager.hxx b/src/lib/nfs/Manager.hxx index 5341fcc90..120c65c9e 100644 --- a/src/lib/nfs/Manager.hxx +++ b/src/lib/nfs/Manager.hxx @@ -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; diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx index 4ccd9934b..e28ef1189 100644 --- a/src/storage/plugins/NfsStorage.cxx +++ b/src/storage/plugins/NfsStorage.cxx @@ -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 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 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);