Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable Nfs autoreconnect #19513

Merged
merged 1 commit into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions xbmc/filesystem/NFSFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int CNfsConnection::getContextForExport(const std::string &exportname)
{
struct contextTimeout tmp;
CSingleLock lock(openContextLock);
setTimeout(m_pNfsContext);
setOptions(m_pNfsContext);
tmp.pContext = m_pNfsContext;
tmp.lastAccessedTime = XbmcThreads::SystemClockMillis();
m_openContextMap[exportname] = tmp; //add context to list of all contexts
Expand Down Expand Up @@ -433,7 +433,7 @@ int CNfsConnection::stat(const CURL &url, NFSSTAT *statbuff)

if(pTmpContext)
{
setTimeout(pTmpContext);
setOptions(pTmpContext);
//we connect to the directory of the path. This will be the "root" path of this connection then.
//So all fileoperations are relative to this mountpoint...
nfsRet = nfs_mount(pTmpContext, m_resolvedHostName.c_str(), exportPath.c_str());
Expand Down Expand Up @@ -474,12 +474,14 @@ void CNfsConnection::AddIdleConnection()
}


void CNfsConnection::setTimeout(struct nfs_context* context)
void CNfsConnection::setOptions(struct nfs_context* context)
{
#ifdef HAS_NFS_SET_TIMEOUT
uint32_t timeout = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_nfsTimeout;
nfs_set_timeout(context, timeout > 0 ? timeout * 1000 : -1);
#endif
int retries = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_nfsRetries;
nfs_set_autoreconnect(context, retries);
}

CNfsConnection gNfsConnection;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/NFSFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CNfsConnection : public CCriticalSection
void destroyContext(const std::string &exportName);
void resolveHost(const CURL &url);//resolve hostname by dnslookup
void keepAlive(const std::string& _exportPath, struct nfsfh* _pFileHandle);
static void setTimeout(struct nfs_context* context);
static void setOptions(struct nfs_context* context);
};

extern CNfsConnection gNfsConnection;
Expand Down
5 changes: 5 additions & 0 deletions xbmc/settings/AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ void CAdvancedSettings::Initialize()
m_userAgent = g_sysinfo.GetUserAgent();

m_nfsTimeout = 5;
m_nfsRetries = -1;

m_initialized = true;
}
Expand Down Expand Up @@ -519,6 +520,10 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
CLog::Log(LOGWARNING, "nfstimeout unsupported");
#endif
}
if (network->FirstChildElement("nfsretries"))
{
XMLUtils::GetInt(network, "nfsretries", m_nfsRetries, -1, 30);
}
}

// Dump contents of copied AS.xml to debug log
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/AdvancedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler

std::string m_userAgent;
uint32_t m_nfsTimeout;
int m_nfsRetries;

private:
void Initialize();
Expand Down