From 43da1686da1dce765d26629d114bf7711905aa8c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 31 Aug 2014 19:24:38 +0200 Subject: [PATCH] nfs/Connection: check for disappearing libnfs socket --- src/lib/nfs/Connection.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib/nfs/Connection.cxx b/src/lib/nfs/Connection.cxx index 64458fec6..d37817a86 100644 --- a/src/lib/nfs/Connection.cxx +++ b/src/lib/nfs/Connection.cxx @@ -299,6 +299,24 @@ NfsConnection::OnSocketReady(unsigned flags) DestroyContext(); closed = true; + BroadcastError(std::move(error)); + } else if (SocketMonitor::IsDefined() && nfs_get_fd(context) < 0) { + /* this happens when rpc_reconnect_requeue() is called + after the connection broke, but autoreconnet was + disabled - nfs_service() returns 0 */ + Error error; + const char *msg = nfs_get_error(context); + if (msg == nullptr) + error.Set(nfs_domain, "NFS socket disappeared"); + else + error.Format(nfs_domain, + "NFS socket disappeared: %s", msg); + + const ScopeLock protect(mutex); + + DestroyContext(); + closed = true; + BroadcastError(std::move(error)); }