mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
If one server fails because of DNS error, don't stop reconnecting to
entire chatnet. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1361 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
9f28d16456
commit
4eb054f4bb
@ -36,6 +36,7 @@ char *last_invite; /* channel where you were last invited */
|
||||
unsigned int server_operator:1;
|
||||
unsigned int usermode_away:1;
|
||||
unsigned int banned:1; /* not allowed to connect to this server */
|
||||
unsigned int dns_error:1; /* DNS said the host doesn't exist */
|
||||
|
||||
time_t lag_sent; /* 0 or time when last lag query was sent to server */
|
||||
time_t lag_last_check; /* last time we checked lag */
|
||||
|
@ -16,5 +16,6 @@ time_t last_connect; /* to avoid reconnecting too fast.. */
|
||||
unsigned int autoconnect:1;
|
||||
unsigned int last_failed:1; /* if last connection attempt failed */
|
||||
unsigned int banned:1; /* if we're banned from this server */
|
||||
unsigned int dns_error:1; /* DNS said the host doesn't exist */
|
||||
|
||||
GHashTable *module_data;
|
||||
|
@ -158,15 +158,19 @@ server_connect_copy_skeleton(SERVER_CONNECT_REC *src, int connect_info)
|
||||
}
|
||||
|
||||
#define server_should_reconnect(server) \
|
||||
((server)->connection_lost && \
|
||||
((server)->connrec->chatnet != NULL || !(server)->banned))
|
||||
((server)->connection_lost && ((server)->connrec->chatnet != NULL || \
|
||||
(!(server)->banned && !(server)->dns_error)))
|
||||
|
||||
#define sserver_connect_ok(rec, net) \
|
||||
(!(rec)->banned && !(rec)->dns_error && (rec)->chatnet != NULL && \
|
||||
g_strcasecmp((rec)->chatnet, (net)) == 0)
|
||||
|
||||
static void sig_reconnect(SERVER_REC *server)
|
||||
{
|
||||
SERVER_CONNECT_REC *conn;
|
||||
SERVER_SETUP_REC *sserver;
|
||||
GSList *tmp;
|
||||
int found, through;
|
||||
int use_next, through;
|
||||
time_t now;
|
||||
|
||||
g_return_if_fail(IS_SERVER(server));
|
||||
@ -192,7 +196,8 @@ static void sig_reconnect(SERVER_REC *server)
|
||||
sserver->last_connect = server->connect_time == 0 ?
|
||||
time(NULL) : server->connect_time;
|
||||
sserver->last_failed = !server->connected;
|
||||
if (server->banned) sserver->banned = TRUE;
|
||||
if (server->banned) sserver->banned = TRUE;
|
||||
if (server->dns_error) sserver->dns_error = TRUE;
|
||||
}
|
||||
|
||||
if (sserver == NULL || conn->chatnet == NULL) {
|
||||
@ -222,9 +227,9 @@ static void sig_reconnect(SERVER_REC *server)
|
||||
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
||||
SERVER_SETUP_REC *rec = tmp->data;
|
||||
|
||||
if (rec->chatnet != NULL && g_strcasecmp(conn->chatnet, rec->chatnet) == 0 &&
|
||||
!rec->banned && (!rec->last_connect || !rec->last_failed ||
|
||||
rec->last_connect < now-FAILED_RECONNECT_WAIT)) {
|
||||
if (sserver_connect_ok(rec, conn->chatnet) &&
|
||||
(!rec->last_connect || !rec->last_failed ||
|
||||
rec->last_connect < now-FAILED_RECONNECT_WAIT)) {
|
||||
if (rec == sserver)
|
||||
conn->port = server->connrec->port;
|
||||
sserver_connect(rec, conn);
|
||||
@ -233,15 +238,14 @@ static void sig_reconnect(SERVER_REC *server)
|
||||
}
|
||||
|
||||
/* just try the next server in list */
|
||||
found = through = FALSE;
|
||||
use_next = through = FALSE;
|
||||
for (tmp = setupservers; tmp != NULL; ) {
|
||||
SERVER_SETUP_REC *rec = tmp->data;
|
||||
|
||||
if (!found && g_strcasecmp(rec->address, server->connrec->address) == 0 &&
|
||||
server->connrec->port == rec->port)
|
||||
found = TRUE;
|
||||
else if (found && !rec->banned && rec->chatnet != NULL &&
|
||||
g_strcasecmp(conn->chatnet, rec->chatnet) == 0) {
|
||||
if (!use_next && server->connrec->port == rec->port &&
|
||||
g_strcasecmp(rec->address, server->connrec->address) == 0)
|
||||
use_next = TRUE;
|
||||
else if (use_next && sserver_connect_ok(rec, conn->chatnet)) {
|
||||
if (rec == sserver)
|
||||
conn->port = server->connrec->port;
|
||||
sserver_connect(rec, conn);
|
||||
@ -261,7 +265,7 @@ static void sig_reconnect(SERVER_REC *server)
|
||||
}
|
||||
|
||||
tmp = setupservers;
|
||||
found = through = TRUE;
|
||||
use_next = through = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "rawlog.h"
|
||||
#include "settings.h"
|
||||
|
||||
|
||||
#include "chat-protocols.h"
|
||||
#include "servers.h"
|
||||
#include "servers-reconnect.h"
|
||||
@ -196,13 +195,10 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
||||
handle = ip == NULL ? NULL : net_connect_ip(ip, port, own_ip);
|
||||
if (handle == NULL) {
|
||||
/* failed */
|
||||
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;
|
||||
if (iprec.error != 0 && net_hosterror_notfound(iprec.error)) {
|
||||
/* IP wasn't found for the host, don't try to reconnect
|
||||
back to this server */
|
||||
server->dns_error = TRUE;
|
||||
}
|
||||
|
||||
if (iprec.error == 0) {
|
||||
@ -213,6 +209,7 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
||||
errormsg = iprec.errorstr != NULL ? iprec.errorstr :
|
||||
"Host lookup failed";
|
||||
}
|
||||
server->connection_lost = TRUE;
|
||||
server_connect_failed(server, errormsg);
|
||||
g_free_not_null(iprec.errorstr);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user