about summary refs log tree commit diff
path: root/sunrpc/bindrsvprt.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-05-23 19:05:24 +0000
committerUlrich Drepper <drepper@redhat.com>2005-05-23 19:05:24 +0000
commit8fd2bb35c717887dea88a12382d2f3d20f434a7a (patch)
tree556dd7b82112724c3dca6c1aa61c39b499e5773d /sunrpc/bindrsvprt.c
parentc179df4e9301ba09589aef60a038e259df70b5b9 (diff)
downloadglibc-8fd2bb35c717887dea88a12382d2f3d20f434a7a.tar.gz
glibc-8fd2bb35c717887dea88a12382d2f3d20f434a7a.tar.xz
glibc-8fd2bb35c717887dea88a12382d2f3d20f434a7a.zip
* sunrpc/bindrsvprt.c (LOWPORT): Apparently some mountd
	implementations are broken and don't accept ports < 512.
Diffstat (limited to 'sunrpc/bindrsvprt.c')
-rw-r--r--sunrpc/bindrsvprt.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sunrpc/bindrsvprt.c b/sunrpc/bindrsvprt.c
index 671f229aae..f58d3b2a8b 100644
--- a/sunrpc/bindrsvprt.c
+++ b/sunrpc/bindrsvprt.c
@@ -43,13 +43,12 @@
 int
 bindresvport (int sd, struct sockaddr_in *sin)
 {
-  int res;
   static short port;
   struct sockaddr_in myaddr;
   int i;
 
 #define STARTPORT 600
-#define LOWPORT 200
+#define LOWPORT 512
 #define ENDPORT (IPPORT_RESERVED - 1)
 #define NPORTS	(ENDPORT - STARTPORT + 1)
   static short startport = STARTPORT;
@@ -70,12 +69,13 @@ bindresvport (int sd, struct sockaddr_in *sin)
     {
       port = (__getpid () % NPORTS) + STARTPORT;
     }
-  res = -1;
-  __set_errno (EADDRINUSE);
+
+  /* Initialize to make gcc happy.  */
+  int res = -1;
 
   int nports = ENDPORT - startport + 1;
  again:
-  for (i = 0; i < nports && res < 0 && errno == EADDRINUSE; ++i)
+  for (i = 0; i < nports; ++i)
     {
       sin->sin_port = htons (port++);
       if (port > ENDPORT)
@@ -83,6 +83,8 @@ bindresvport (int sd, struct sockaddr_in *sin)
 	  port = startport;
 	}
       res = __bind (sd, sin, sizeof (struct sockaddr_in));
+      if (res >= 0 || errno != EADDRINUSE)
+	break;
     }
 
   if (i == nports && startport != LOWPORT)