diff --git a/src/main/interlink.c b/src/main/interlink.c index 56cd3a26..c4e5f8f3 100644 --- a/src/main/interlink.c +++ b/src/main/interlink.c @@ -386,19 +386,18 @@ bind_to_af_unix(void) setsock_reuse_addr(s_info_listen.fd); - if (bind(s_info_listen.fd, s_info_listen.addr, s_info_listen.size) < 0) { - if (errno != EADDRINUSE) - report_af_unix_error("bind()", errno); - - if (++attempts <= MAX_BIND_TRIES) { - elinks_usleep(BIND_TRIES_DELAY * attempts); - close(s_info_listen.fd); - - } else { - goto free_and_error; - } - } else { + if (bind(s_info_listen.fd, s_info_listen.addr, s_info_listen.size) >= 0) break; + + if (errno != EADDRINUSE) + report_af_unix_error("bind()", errno); + + if (++attempts <= MAX_BIND_TRIES) { + elinks_usleep(BIND_TRIES_DELAY * attempts); + close(s_info_listen.fd); + + } else { + goto free_and_error; } }