Correct the logic when to loop for the port range

This commit is contained in:
H. Peter Anvin 2006-02-16 09:29:35 -08:00
parent 8890d206f4
commit b3892e801f

View file

@ -289,7 +289,7 @@ pick_port_bind(int sockfd, struct sockaddr_in *myaddr)
if (bind(sockfd, (struct sockaddr *)myaddr, sizeof *myaddr) < 0) {
/* Some versions of Linux return EINVAL instead of EADDRINUSE */
if ( !portrange || !(errno != EINVAL && errno != EADDRINUSE) )
if ( !(portrange && (errno == EINVAL || errno == EADDRINUSE)) )
return -1;
/* Normally, we shouldn't have to loop, but some situations involving