Blame SOURCES/autofs-5.1.1-fix-create_client-RPC-client-handling.patch

7f6688
autofs-5.1.1 - fix create_client() RPC client handling
7f6688
7f6688
From: Ian Kent <raven@themaw.net>
7f6688
7f6688
The autofs socket minimization strategy is to reuse the socket
7f6688
descriptor when creating an RPC client for the same protocol.
7f6688
7f6688
But in create_client() there is a case where the socket descriptor
7f6688
can be obtained from RPC client, the RPC client destroyed, but
7f6688
not cleared in the persistent data structure.
7f6688
7f6688
In create_client(), once an attempt is done to get the socket
7f6688
descriptor, the RPC client should always be destroyed and cleared
7f6688
in the persistent data structure.
7f6688
7f6688
Signed-off-by: Ian Kent <raven@themaw.net>
7f6688
---
7f6688
 CHANGELOG      |    1 +
7f6688
 lib/rpc_subs.c |   21 ++++++++-------------
7f6688
 2 files changed, 9 insertions(+), 13 deletions(-)
7f6688
7f6688
--- autofs-5.0.7.orig/CHANGELOG
7f6688
+++ autofs-5.0.7/CHANGELOG
7f6688
@@ -295,6 +295,7 @@
7f6688
 - fix prefix option handling in expand_entry().
7f6688
 - fix sublink option not set from defaults.
7f6688
 - fix error return in do_nfs_mount().
7f6688
+- fix create_client() RPC client handling.
7f6688
 
7f6688
 25/07/2012 autofs-5.0.7
7f6688
 =======================
7f6688
--- autofs-5.0.7.orig/lib/rpc_subs.c
7f6688
+++ autofs-5.0.7/lib/rpc_subs.c
7f6688
@@ -663,14 +663,12 @@ static int create_client(struct conn_inf
7f6688
 	*client = NULL;
7f6688
 
7f6688
 	if (info->client) {
7f6688
-		if (!clnt_control(info->client, CLGET_FD, (char *) &fd)) {
7f6688
-			fd = RPC_ANYSOCK;
7f6688
-			clnt_destroy(info->client);
7f6688
-			info->client = NULL;
7f6688
-		} else {
7f6688
+		if (clnt_control(info->client, CLGET_FD, (char *) &fd))
7f6688
 			clnt_control(info->client, CLSET_FD_NCLOSE, NULL);
7f6688
-			clnt_destroy(info->client);
7f6688
-		}
7f6688
+		else
7f6688
+			fd = RPC_ANYSOCK;
7f6688
+		clnt_destroy(info->client);
7f6688
+		info->client = NULL;
7f6688
 	}
7f6688
 
7f6688
 	if (info->addr) {
7f6688
@@ -686,7 +684,7 @@ static int create_client(struct conn_inf
7f6688
 			goto out_close;
7f6688
 		}
7f6688
 
7f6688
-		if (!info->client && fd != RPC_ANYSOCK) {
7f6688
+		if (fd != RPC_ANYSOCK) {
7f6688
 			close(fd);
7f6688
 			fd = RPC_ANYSOCK;
7f6688
 		}
7f6688
@@ -704,7 +702,6 @@ static int create_client(struct conn_inf
7f6688
 	if (ret) {
7f6688
 		error(LOGOPT_ANY,
7f6688
 		      "hostname lookup failed: %s", gai_strerror(ret));
7f6688
-		info->client = NULL;
7f6688
 		goto out_close;
7f6688
 	}
7f6688
 
7f6688
@@ -723,7 +720,7 @@ static int create_client(struct conn_inf
7f6688
 			goto out_close;
7f6688
 		}
7f6688
 
7f6688
-		if (!info->client && fd != RPC_ANYSOCK) {
7f6688
+		if (fd != RPC_ANYSOCK) {
7f6688
 			close(fd);
7f6688
 			fd = RPC_ANYSOCK;
7f6688
 		}
7f6688
@@ -735,7 +732,6 @@ static int create_client(struct conn_inf
7f6688
 
7f6688
 done:
7f6688
 	if (!*client) {
7f6688
-		info->client = NULL;
7f6688
 		ret = -ENOTCONN;
7f6688
 		goto out_close;
7f6688
 	}
7f6688
@@ -743,7 +739,6 @@ done:
7f6688
 	/* Close socket fd on destroy, as is default for rpcowned fds */
7f6688
 	if  (!clnt_control(*client, CLSET_FD_CLOSE, NULL)) {
7f6688
 		clnt_destroy(*client);
7f6688
-		info->client = NULL;
7f6688
 		ret = -ENOTCONN;
7f6688
 		goto out_close;
7f6688
 	}
7f6688
@@ -751,7 +746,7 @@ done:
7f6688
 	return 0;
7f6688
 
7f6688
 out_close:
7f6688
-	if (fd != -1)
7f6688
+	if (fd != RPC_ANYSOCK)
7f6688
 		close(fd);
7f6688
 	return ret;
7f6688
 }