From 76e04761138f47efe974c2c1a33984b7ebd29273 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Fri, 30 Sep 2016 16:26:50 +0100 Subject: [PATCH] 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 --- src/common/sockutil.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/sockutil.c b/src/common/sockutil.c index 1377958..a924026 100644 --- a/src/common/sockutil.c +++ b/src/common/sockutil.c @@ -100,7 +100,7 @@ int sock_try_bind( int fd, const struct sockaddr* sa ) { int bind_result; char s_address[256]; - int retry = 1; + int retry = 10; 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. */ case EADDRNOTAVAIL: - debug( "retrying" ); - sleep( 1 ); + retry--; + if (retry) { + debug( "retrying" ); + sleep( 1 ); + } continue; case EADDRINUSE: warn( "%s in use, giving up.", s_address );