Skip to contentSkip to conversation

mount command: rename connect_to helper

PATCH New Chuck Lever 1 participant 1 message Feb 18, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 8/17 mount command: rename connect_to helper

Clean up: rename connect_to().

The get_socket() function uses a helper called connect_to() that wraps the connect(2) system call with logic that establishes a connection timeout. The name "connect_to()" is confusing though, as it suggests we are invoking some other system interface rather than a locally defined function.

---

 utils/mount/network.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
utils/mount/network.c +8 -5
index a893a4a..da0eb1a 100644
@@ -257,10 +257,13 @@ static int __nfs_gs_err_connect(const int socket, const struct sockaddr *saddr,
 /*
  * Attempt to connect a socket, but time out after "timeout" seconds.
  *
- * On error return, caller closes the socket.
+ * Returns zero if successful, or -1 if an error occurred.
+ * On error return, caller must close the socket.
  */
-static int connect_to(int fd, struct sockaddr *addr,
-			socklen_t addrlen, time_t timeout)
+static int __nfs_gs_connect_with_timeout(const int fd,
+						const struct sockaddr *addr,
+						const socklen_t addrlen,
+						const time_t timeout)
 {
 	int ret, saved;
 	fd_set rset, wset;
@@ -329,8 +332,8 @@ static int get_socket(struct sockaddr_in *saddr, unsigned int p_prot,
 			return __nfs_gs_err_bind(so, p_prot, errno);
 	}
 	if (type == SOCK_STREAM || conn) {
-		if (connect_to(so, (struct sockaddr *)saddr, namelen,
-								timeout) < 0)
+		if (__nfs_gs_connect_with_timeout(so, (struct sockaddr *)saddr,
+							namelen, timeout) < 0)
 			return __nfs_gs_err_connect(so, (struct sockaddr *)saddr,
 							errno);
 	}