diff options
author | Timo Sirainen <cras@irssi.org> | 2000-07-02 11:56:38 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-07-02 11:56:38 +0000 |
commit | 2f97b822fb43a0ef652429986ad14c6ed2988538 (patch) | |
tree | ad37ca3535f940921a1e5e42d35e7701f95ae372 /src | |
parent | c15f655bca27a1509ff4b1bca8bbf409259995fb (diff) | |
download | irssi-2f97b822fb43a0ef652429986ad14c6ed2988538.zip |
"Temporary error in nameserver" shouldn't remove server reconnections.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@412 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/core/network.c | 15 | ||||
-rw-r--r-- | src/core/network.h | 3 | ||||
-rw-r--r-- | src/core/server.c | 14 |
3 files changed, 24 insertions, 8 deletions
diff --git a/src/core/network.c b/src/core/network.c index e034e609..5a6e276a 100644 --- a/src/core/network.c +++ b/src/core/network.c @@ -340,7 +340,7 @@ int net_gethostbyname(const char *addr, IPADDR *ip) freeaddrinfo(ai); #else hp = gethostbyname(addr); - if (hp == NULL) return -1; + if (hp == NULL) return h_errno; ip->family = AF_INET; memcpy(&ip->addr, hp->h_addr, 4); @@ -467,7 +467,7 @@ const char *net_gethosterror(int error) return gai_strerror(error); #else - switch (h_errno) { + switch (error) { case HOST_NOT_FOUND: return _("Host not found"); case NO_ADDRESS: @@ -483,6 +483,17 @@ const char *net_gethosterror(int error) #endif } +/* return TRUE if host lookup failed because it didn't exist (ie. not + some error with name server) */ +int net_hosterror_notfound(int error) +{ +#ifdef HAVE_IPV6 + return error != 1 && (error == EAI_NONAME || error == EAI_NODATA); +#else + return error == HOST_NOT_FOUND || error == NO_ADDRESS; +#endif +} + int is_ipv4_address(const char *host) { while (*host != '\0') { diff --git a/src/core/network.h b/src/core/network.h index b7e6a30f..613434c4 100644 --- a/src/core/network.h +++ b/src/core/network.h @@ -58,6 +58,9 @@ int net_gethostbyname(const char *addr, IPADDR *ip); int net_gethostbyaddr(IPADDR *ip, char **name); /* get error of net_gethostname() */ const char *net_gethosterror(int error); +/* return TRUE if host lookup failed because it didn't exist (ie. not + some error with name server) */ +int net_hosterror_notfound(int error); /* Get socket address/port */ int net_getsockname(int handle, IPADDR *addr, int *port); diff --git a/src/core/server.c b/src/core/server.c index 98cbce54..f46893e4 100644 --- a/src/core/server.c +++ b/src/core/server.c @@ -141,20 +141,22 @@ static void server_connect_callback_readpipe(SERVER_REC *server, int handle) server->connect_pipe[1] = -1; conn = server->connrec; - server->handle = iprec.error == -1 ? -1 : + server->handle = iprec.error != 0 ? -1 : net_connect_ip(&iprec.ip, conn->proxy != NULL ? conn->proxy_port : conn->port, conn->own_ip != NULL ? conn->own_ip : NULL); if (server->handle == -1) { /* failed */ - if (iprec.error != -1) { - /* reconnect only if connect() was the one that - failed, if host lookup failed we most probably - don't want to try reconnecting back. */ + if (iprec.error == 0 || !net_hosterror_notfound(iprec.error)) { + /* reconnect back only if either + 1) connect() failed + 2) host name lookup failed not because the host + wasn't found, but because there was some + other error in nameserver */ server->connection_lost = TRUE; } server_cant_connect(server, - iprec.error != -1 ? g_strerror(errno) : /* connect() failed */ + iprec.error == 0 ? g_strerror(errno) : /* connect() failed */ (iprec.errorstr != NULL ? iprec.errorstr : "Host lookup failed")); /* gethostbyname() failed */ g_free_not_null(iprec.errorstr); return; |