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:
Yaroslav Tykhiy 2004-07-30 17:18:57 +00:00
parent 0feabab576
commit 9ec7612a2f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132891

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;