Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2018-02-05 21:27:55 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-02-05 21:32:13 +0300
commit34f031982fbf9ce6eb23e47f7f0aeede175cd596 (patch)
tree8f4d2f770742a8f7f1d1128d791d1c3f6b4d170c /winsup/cygwin/net.cc
parent9dc34cea28d55c91a5b751530daf39a697cd1794 (diff)
Cygwin: bindresvport_sa: Ignore incoming port number
Ignore port number just like glibc, otherwise suffer EADDRINUSE in subsequent connect calls. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc16
1 files changed, 4 insertions, 12 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 8969e7c6f..b6890121a 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -2467,7 +2467,6 @@ cygwin_bindresvport_sa (int fd, struct sockaddr *sa)
struct sockaddr_storage sst;
struct sockaddr_in *sin = NULL;
struct sockaddr_in6 *sin6 = NULL;
- in_port_t port;
socklen_t salen;
int ret = -1;
@@ -2489,27 +2488,20 @@ cygwin_bindresvport_sa (int fd, struct sockaddr *sa)
case AF_INET:
salen = sizeof (struct sockaddr_in);
sin = (struct sockaddr_in *) sa;
- port = sin->sin_port;
break;
case AF_INET6:
salen = sizeof (struct sockaddr_in6);
sin6 = (struct sockaddr_in6 *) sa;
- port = sin6->sin6_port;
break;
default:
set_errno (EPFNOSUPPORT);
__leave;
}
- /* If a non-zero port number is given, try this first. If that succeeds,
- or if the error message is serious, return. */
- if (port)
- {
- ret = fh->bind (sa, salen);
- if (!ret || (get_errno () != EADDRINUSE && get_errno () != EINVAL))
- __leave;
- }
-
+ /* Originally we tried to use the incoming port number first here,
+ but that may lead to EADDRINUSE scenarios when calling bindresvport
+ on the client side. So we ignore any port value that the caller
+ supplies, just like glibc. */
LONG myport;
for (int i = 0; i < NUM_PORTS; i++)