Add a comment to explain that the loop around the call to bind(2)

is not a hack, but it has a clear purpose.
This commit is contained in:
yar 2004-07-30 17:18:57 +00:00
parent 24912a0c07
commit 8839880434

View File

@ -1821,6 +1821,15 @@ getdatasock(char *mode)
data_source.su_port = htons(dataport);
(void) seteuid((uid_t)0);
for (tries = 1; ; tries++) {
/*
* We should loop here since it's possible that
* another ftpd instance has passed this point and is
* trying to open a data connection in active mode now.
* Until the other connection is opened, we'll be getting
* EADDRINUSE because no SOCK_STREAM sockets in the system
* can share both local and remote addresses, localIP:20
* and *:* in this case.
*/
if (bind(s, (struct sockaddr *)&data_source,
data_source.su_len) >= 0)
break;