diff options
author | Peter Anvin <hpa@tazenda.sc.orionmulti.com> | 2005-10-13 15:20:41 -0700 |
---|---|---|
committer | Peter Anvin <hpa@tazenda.sc.orionmulti.com> | 2005-10-13 15:20:41 -0700 |
commit | ccb6289984f7046145f399c1bfd6566fe8ee11d0 (patch) | |
tree | 40e41d402ee0ba18fb91088e994f55568b1af727 | |
parent | 4187af0e6f0c79e3892bc55ea1bf7b594f00381e (diff) | |
download | tftp-hpa-ccb6289984f7046145f399c1bfd6566fe8ee11d0.tar.gz |
Actually do loop...
-rw-r--r-- | tftpd/tftpd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c index 30d20a3..5e2a26e 100644 --- a/tftpd/tftpd.c +++ b/tftpd/tftpd.c @@ -288,10 +288,12 @@ pick_port_bind(int sockfd, struct sockaddr_in *myaddr) myaddr->sin_port = htons(port); if (bind(sockfd, (struct sockaddr *)myaddr, sizeof *myaddr) < 0) { - if ( portrange && (errno == EINVAL || errno == EADDRINUSE) ) - continue; /* Should not happen in normal operation, but try again */ + /* Some versions of Linux return EINVAL instead of EADDRINUSE */ + if ( !portrange || !(errno != EINVAL && errno != EADDRINUSE) ) + return -1; - return -1; + /* Normally, we shouldn't have to loop, but some situations involving + aborted transfers make it possible. */ } else { return 0; } |