aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-10-01 22:15:06 +0200
committerMax Kellermann <max@duempel.org>2014-10-01 22:15:06 +0200
commit10cc87e422e09f437f86f56074dc2e018ed75bf1 (patch)
tree8089f17074a307a060fa0ecb55fdafc7c46a30be /src
parent0470f648c6512d7a8a6fc5f66e760dfc85f2c8aa (diff)
downloadmpd-10cc87e422e09f437f86f56074dc2e018ed75bf1.tar.gz
mpd-10cc87e422e09f437f86f56074dc2e018ed75bf1.tar.xz
mpd-10cc87e422e09f437f86f56074dc2e018ed75bf1.zip
lib/nfs/Connection: remove Mutex
All locks are currenly held from only a single thread (the IOThread) and thus we don't need the Mutex.
Diffstat (limited to 'src')
-rw-r--r--src/lib/nfs/Connection.cxx27
-rw-r--r--src/lib/nfs/Connection.hxx3
2 files changed, 12 insertions, 18 deletions
diff --git a/src/lib/nfs/Connection.cxx b/src/lib/nfs/Connection.cxx
index c07598189..89ef24312 100644
--- a/src/lib/nfs/Connection.cxx
+++ b/src/lib/nfs/Connection.cxx
@@ -135,10 +135,9 @@ NfsConnection::~NfsConnection()
void
NfsConnection::AddLease(NfsLease &lease)
{
- {
- const ScopeLock protect(mutex);
- new_leases.push_back(&lease);
- }
+ assert(GetEventLoop().IsInside());
+
+ new_leases.push_back(&lease);
DeferredMonitor::Schedule();
}
@@ -146,7 +145,7 @@ NfsConnection::AddLease(NfsLease &lease)
void
NfsConnection::RemoveLease(NfsLease &lease)
{
- const ScopeLock protect(mutex);
+ assert(GetEventLoop().IsInside());
new_leases.remove(&lease);
active_leases.remove(&lease);
@@ -220,6 +219,7 @@ NfsConnection::Close(struct nfsfh *fh)
void
NfsConnection::DestroyContext()
{
+ assert(GetEventLoop().IsInside());
assert(context != nullptr);
if (SocketMonitor::IsDefined())
@@ -271,8 +271,6 @@ NfsConnection::OnSocketReady(unsigned flags)
in_service = false;
if (!was_mounted && mount_finished) {
- const ScopeLock protect(mutex);
-
if (postponed_mount_error.IsDefined()) {
DestroyContext();
closed = true;
@@ -285,8 +283,6 @@ NfsConnection::OnSocketReady(unsigned flags)
error.Format(nfs_domain, "NFS connection has failed: %s",
nfs_get_error(context));
- const ScopeLock protect(mutex);
-
DestroyContext();
closed = true;
@@ -303,8 +299,6 @@ NfsConnection::OnSocketReady(unsigned flags)
error.Format(nfs_domain,
"NFS socket disappeared: %s", msg);
- const ScopeLock protect(mutex);
-
DestroyContext();
closed = true;
@@ -379,6 +373,8 @@ NfsConnection::MountInternal(Error &error)
void
NfsConnection::BroadcastMountSuccess()
{
+ assert(GetEventLoop().IsInside());
+
while (!new_leases.empty()) {
auto i = new_leases.begin();
active_leases.splice(active_leases.end(), new_leases, i);
@@ -389,6 +385,8 @@ NfsConnection::BroadcastMountSuccess()
void
NfsConnection::BroadcastMountError(Error &&error)
{
+ assert(GetEventLoop().IsInside());
+
while (!new_leases.empty()) {
auto l = new_leases.front();
new_leases.pop_front();
@@ -401,6 +399,8 @@ NfsConnection::BroadcastMountError(Error &&error)
void
NfsConnection::BroadcastError(Error &&error)
{
+ assert(GetEventLoop().IsInside());
+
while (!active_leases.empty()) {
auto l = active_leases.front();
active_leases.pop_front();
@@ -416,14 +416,11 @@ NfsConnection::RunDeferred()
{
Error error;
if (!MountInternal(error)) {
- const ScopeLock protect(mutex);
BroadcastMountError(std::move(error));
return;
}
}
- if (mount_finished) {
- const ScopeLock protect(mutex);
+ if (mount_finished)
BroadcastMountSuccess();
- }
}
diff --git a/src/lib/nfs/Connection.hxx b/src/lib/nfs/Connection.hxx
index 020dc6302..f6e5d2949 100644
--- a/src/lib/nfs/Connection.hxx
+++ b/src/lib/nfs/Connection.hxx
@@ -22,7 +22,6 @@
#include "Lease.hxx"
#include "Cancellable.hxx"
-#include "thread/Mutex.hxx"
#include "event/SocketMonitor.hxx"
#include "event/DeferredMonitor.hxx"
#include "util/Error.hxx"
@@ -64,8 +63,6 @@ class NfsConnection : SocketMonitor, DeferredMonitor {
nfs_context *context;
- Mutex mutex;
-
typedef std::list<NfsLease *> LeaseList;
LeaseList new_leases, active_leases;