From 5e43d0a92f1900c7daeb3c87b5a152498a89fc8d Mon Sep 17 00:00:00 2001 From: Earl Chew Date: Tue, 9 May 2017 21:43:31 -0700 Subject: [PATCH] Allow autoreconnect to be disabled Signed-off-by: Earl Chew --- include/nfsc/libnfs.h | 1 + lib/libnfs-win32.def | 1 + lib/libnfs.c | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/nfsc/libnfs.h b/include/nfsc/libnfs.h index ff7350e..0ac9dda 100644 --- a/include/nfsc/libnfs.h +++ b/include/nfsc/libnfs.h @@ -232,6 +232,7 @@ EXTERN void nfs_set_pagecache_ttl(struct nfs_context *nfs, uint32_t v); EXTERN void nfs_set_readahead(struct nfs_context *nfs, uint32_t v); EXTERN void nfs_set_debug(struct nfs_context *nfs, int level); EXTERN void nfs_set_dircache(struct nfs_context *nfs, int enabled); +EXTERN void nfs_set_autoreconnect(struct nfs_context *nfs, int enabled); /* * Invalidate the pagecache diff --git a/lib/libnfs-win32.def b/lib/libnfs-win32.def index af0f3e8..c7714bb 100644 --- a/lib/libnfs-win32.def +++ b/lib/libnfs-win32.def @@ -69,6 +69,7 @@ nfs_rmdir nfs_rmdir_async nfs_service nfs_set_auth +nfs_set_autoreconnect nfs_set_debug nfs_set_dircache nfs_set_gid diff --git a/lib/libnfs.c b/lib/libnfs.c index 77d9534..99c57d3 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -145,6 +145,7 @@ struct nfs_context { uint64_t writemax; char *cwd; int dircache_enabled; + int auto_reconnect_enabled; struct nfsdir *dircache; uint16_t mask; @@ -354,6 +355,8 @@ static int nfs_set_context_args(struct nfs_context *nfs, const char *arg, const nfs->auto_traverse_mounts = atoi(val); } else if (!strcmp(arg, "dircache")) { nfs_set_dircache(nfs, atoi(val)); + } else if (!strcmp(arg, "autoreconnect")) { + nfs_set_autoreconnect(nfs, atoi(val)); #ifdef HAVE_SO_BINDTODEVICE } else if (!strcmp(arg, "if")) { nfs_set_interface(nfs, val); @@ -523,6 +526,7 @@ struct nfs_context *nfs_init_context(void) nfs->mask = 022; nfs->auto_traverse_mounts = 1; nfs->dircache_enabled = 1; + nfs->auto_reconnect_enabled = 1; return nfs; } @@ -1016,7 +1020,8 @@ static void nfs_mount_9_cb(struct rpc_context *rpc, int status, void *command_da /* NFS TCP connections should be autoreconnected after sessions have * been torn down (due to inactivity or error) */ - rpc_set_autoreconnect(rpc); + if (nfs->auto_reconnect_enabled) + rpc_set_autoreconnect(rpc); args.fsroot = nfs->rootfh; if (rpc_nfs3_fsinfo_async(rpc, nfs_mount_10_cb, &args, data) != 0) { @@ -5536,6 +5541,10 @@ void nfs_set_dircache(struct nfs_context *nfs, int enabled) { nfs->dircache_enabled = enabled; } +void nfs_set_autoreconnect(struct nfs_context *nfs, int enabled) { + nfs->auto_reconnect_enabled = enabled; +} + void nfs_set_error(struct nfs_context *nfs, char *error_string, ...) { va_list ap;