From: Neil Brown Date: Thu, 22 Feb 2007 04:34:45 +0000 (+1100) Subject: Fix showmount bugs. X-Git-Tag: nfs-utils-1-0-11~2 X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=commitdiff_plain;h=66d8e2870b8d3e91c27a66ebc85e012a3cda9c69;hp=944011f65513aa4c1b69fa92e0f51b8aef7c1cbc Fix showmount bugs. When doing a nonblocked connect, we need to select for 'write', not 'read'. Also, when a tcp socket has been connected, we should use clnttcp_create to make a tcp client, not clntudp_bufcreate !! --- diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c index 9979621..f3ac671 100644 --- a/utils/showmount/showmount.c +++ b/utils/showmount/showmount.c @@ -118,7 +118,7 @@ static int connect_nb(int fd, struct sockaddr_in *addr, struct timeval *tout) FD_ZERO(&rset); FD_SET(fd, &rset); - ret = select(fd + 1, &rset, NULL, NULL, tout); + ret = select(fd + 1, NULL, &rset, NULL, tout); if (ret <= 0) { if (ret == 0) ret = -ETIMEDOUT; @@ -185,6 +185,9 @@ static unsigned short getport(struct sockaddr_in *addr, rpc_createerr.cf_error.re_errno = errno; return 0; } + client = clnttcp_create(&saddr, + PMAPPROG, PMAPVERS, &sock, + 0, 0); } else { /* * bind to any unused port. If we left this up to the rpc @@ -213,10 +216,10 @@ static unsigned short getport(struct sockaddr_in *addr, sock = RPC_ANYSOCK; /* FALLTHROUGH */ } + client = clntudp_bufcreate(&saddr, PMAPPROG, PMAPVERS, + tout, &sock, send_sz, recv_sz); } - client = clntudp_bufcreate(&saddr, PMAPPROG, PMAPVERS, - tout, &sock, send_sz, recv_sz); if (!client) { close(sock); rpc_createerr.cf_stat = RPC_RPCBFAILURE;