[PATCH] Fix retry= to handle lack of reserved port situation In the case of several (>500) mounts running at the same time with -o tcp, the number of attempts that succeed is about 300-500 because it run out of priviledged port (they are busy in TIME_WAIT state). Signed-off-by: Flavio Leitner --- support/nfs/conn.c | 6 ++++++ utils/mount/nfsmount.c | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/support/nfs/conn.c b/support/nfs/conn.c index 29dbb82..315d766 100644 --- a/support/nfs/conn.c +++ b/support/nfs/conn.c @@ -200,6 +200,12 @@ CLIENT *mnt_openclnt(clnt_addr_t *mnt_se /* contact the mount daemon via TCP */ mnt_saddr->sin_port = htons((u_short)mnt_pmap->pm_port); *msock = get_socket(mnt_saddr, mnt_pmap->pm_prot, TRUE, FALSE); + if (*msock == RPC_ANYSOCK && + rpc_createerr.cf_error.re_errno == EADDRINUSE) { + /* Bubble up the error to see how it should be handled. */ + rpc_createerr.cf_stat = RPC_TIMEDOUT; + return NULL; + } switch (mnt_pmap->pm_prot) { case IPPROTO_UDP: diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c index 815064a..a2ae520 100644 --- a/utils/mount/nfsmount.c +++ b/utils/mount/nfsmount.c @@ -1178,9 +1178,13 @@ #endif perror(_("nfs socket")); goto fail; } - if (bindresvport(fsock, 0) < 0) { - perror(_("nfs bindresvport")); - goto fail; + while (bindresvport(fsock, 0) < 0) { + t = time(NULL); + if (t > timeout || errno != EADDRINUSE) { + perror(_("nfs bindresvport")); + goto fail; + } + sleep(10); } } -- 1.4.1