mirror of
https://github.com/zhaojh329/rtty.git
synced 2026-02-27 09:53:17 +08:00
Fix auto-reconnect when domain name resolution fails
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
@@ -187,11 +187,11 @@ int tcp_connect(struct ev_loop *loop, const char *host, int port,
|
||||
if (ret) {
|
||||
if (ret == EAI_SYSTEM) {
|
||||
log_err("getaddrinfo failed: %s\n", strerror(errno));
|
||||
return -1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
log_err("getaddrinfo failed: %s\n", gai_strerror(ret));
|
||||
return -1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||
@@ -211,5 +211,8 @@ int tcp_connect(struct ev_loop *loop, const char *host, int port,
|
||||
|
||||
free_addrinfo:
|
||||
freeaddrinfo(result);
|
||||
fail:
|
||||
if (sock < 0)
|
||||
on_connected(-1, arg);
|
||||
return sock;
|
||||
}
|
||||
|
||||
@@ -772,13 +772,13 @@ int rtty_start(struct rtty *rtty)
|
||||
|
||||
ev_init(&rtty->tmr, rtty_timer_cb);
|
||||
|
||||
INIT_LIST_HEAD(&rtty->ttys);
|
||||
INIT_LIST_HEAD(&rtty->http_conns);
|
||||
|
||||
if (tcp_connect(rtty->loop, rtty->host, rtty->port, on_net_connected, rtty) < 0
|
||||
&& !rtty->reconnect)
|
||||
return -1;
|
||||
|
||||
INIT_LIST_HEAD(&rtty->ttys);
|
||||
INIT_LIST_HEAD(&rtty->http_conns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user