Attempt at fixing bind() bug

This will prevent the bind() wrapper to loop forever in some cases. I
could nor reproduc the issue, but this removes the only infinite loop I
could find.

Signed-off-by: Michel Pollet <buserror@gmail.com>
This commit is contained in:
Michel Pollet
2016-09-30 16:26:50 +01:00
committed by Patrick J Cherry
parent e3360a3a1b
commit 76e0476113

View File

@@ -100,7 +100,7 @@ int sock_try_bind( int fd, const struct sockaddr* sa )
{ {
int bind_result; int bind_result;
char s_address[256]; char s_address[256];
int retry = 1; int retry = 10;
sockaddr_address_string( sa, &s_address[0], 256 ); sockaddr_address_string( sa, &s_address[0], 256 );
@@ -126,8 +126,11 @@ int sock_try_bind( int fd, const struct sockaddr* sa )
* will cope with it. * will cope with it.
*/ */
case EADDRNOTAVAIL: case EADDRNOTAVAIL:
debug( "retrying" ); retry--;
sleep( 1 ); if (retry) {
debug( "retrying" );
sleep( 1 );
}
continue; continue;
case EADDRINUSE: case EADDRINUSE:
warn( "%s in use, giving up.", s_address ); warn( "%s in use, giving up.", s_address );